I have a shapeFile and a spatialPointsDataframe ... I would like to select all polygon where there is point(s) inside, and merge points information in 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

But after that I don't know how select polygones. i have tried

vitiWord<-word[tps]

but it's doesn't work

for download exemple -> link

有帮助吗?

解决方案

I 'have find some thing... I don't realy know if it work because I would like to use ggplot after and it doesn't work well, but whit

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

You have all variable from point in the spatialDataFrame !!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top