繁体   English   中英

R选择内部具有点的空间多边形

[英]R select spatial polygon with point inside

我有一个shapeFile和spatialPointsDataframe ...我想选择内部有点的所有多边形,然后在shp @ data中合并点信息

word<-readOGR(dsn="data/world/ne_110m_admin_0_countries.shp", layer="ne_110m_admin_0_countries")
xy<-cbind(geoloc$longitude,geoloc$latitude)
spxy<-SpatialPoints(xy)
spdfxy<-SpatialPointsDataFrame(spxy,geoloc)
spdfxy@data<-merge(spdfxy@data,data2000geo)

tps<-!is.na(over(spdfxy,word)) ##retourne the indexe of atribut of y renvois les atribut de word

但是之后,我不知道如何选择多边形。 我努力了

vitiWord<-word[tps]

但这是行不通的

下载示例-> 链接

我已经找到了一些东西...我真的不知道它是否有效,因为我想在以后使用ggplot,但是效果不佳,但是

jointure<-over(word,spdfxy) #over from sp library
word@data<-cbind(word@data,jointure)

您已经从spatialDataFrame中的所有点开始了!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM