Rstudio中从KML提取坐标点

Grey_R 2018-01-04 12:09:41
想从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
...全文
995 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

2,141

社区成员

发帖
与我相关
我的任务
社区描述
它是一种特定的十分重要的空间信息系统。它是在计算机硬、软件系统支持下,对整个或部分地球表层(包括大气层)空间中的有关地理分布数据进行采集、储存、管理、运算、分析、显示和描述的技术系统。
社区管理员
  • 地理信息系统
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧