想從KML檔案中匯入坐標點
getwd()
library(classInt)
library(fpc)
library(leaflet)
library(maptools)
library(raster)
library(RColorBrewer)
library(rmarkdown)
library(sp)
library(spatstat)
library(rgeos)
LondonBorough<-readShapeSpatial("London_Borough_Excluding_MHW.shp")
qtm(LondonBorough)
summary(LondonBorough)
class(LondonBorough)
install.packages("rJava")
#stimulate operation of openstreetmap
if (Sys.info()['sysname'] == 'Darwin') {
libjvm <- paste0(system2('/usr/libexec/java_home',stdout = TRUE)[1],'/jre/lib/server/libjvm.dylib')
message (paste0('Load libjvm.dylib from: ',libjvm))
dyn.load(libjvm)
}
library(rJava)
library(OpenStreetMap)
library(rgdal)
data(simply_list.csv)
list<-read.csv("full_attributions_list.csv")
Borough <- readOGR(dsn="London_Borough_Excluding_MHW.shp")
ogrInfo(dsn="London_Borough_Excluding_MHW.shp", layer="London_Borough_Excluding_MHW")
crs(Borough)
ETRS89 <- "+init=epsg:25833"
proj4string(Borough) <- CRS(ETRS89)
plot(Borough)
attractions <- getKMLcoordinates(kmlfile="full_list.kml", ignoreAltitude=T)
summary(attractions)
crs(attractions)
attractionss_projection<-spTransform(attractions,CRS(ETRS89))
plot(Borough, lwd=0.7, border="grey40")
plot(attractions,add=TRUE,pch=16,col='red')
然后報錯是
> attractionss_projection<-spTransform(attractions,CRS(ETRS89))
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘spTransform’ for signature ‘"list", "CRS"’
以及繼續嘗試plot的報錯
> plot(attractions,add=TRUE,pch=16,col='red')
Error in xy.coords(x, y, xlabel, ylabel, log) :
'x' is a list, but does not have components 'x' and 'y'
但是KML坐標可以在Google map上看到的 除了坐標系不一樣不知道問題在哪里
summary出來是這樣
> summary(attractions)
Length Class Mode
[1,] 2 -none- numeric
[2,] 2 -none- numeric
[3,] 2 -none- numeric
[4,] 2 -none- numeric
[5,] 2 -none- numeric
[6,] 2 -none- numeric
[7,] 2 -none- numeric
[8,] 2 -none- numeric
[9,] 2 -none- numeric
在values里面也是可以看到兩個值的
求問大神們要怎么改QAQ
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/31728.html
標籤:地理信息系統
