2014-01-21 39 views
0

我有一個shape文件和spatialPointsDataframe ......我想選擇所有的多邊形,其中有一點(S)內,並在小水電合併點的信息@數據r選擇已用空間點多邊形內部

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) 
[email protected]<-merge([email protected],data2000geo) 

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

但之後我不知道如何選擇多邊形。我曾嘗試

vitiWord<-word[tps] 

,但它不適用於下載爲例工作

- >link

+0

你可以製作一個可重現的例子嗎?這將有很大的幫助 – dickoa

+0

我沒有嘗試,但可能word [tps,]可以工作 – dickoa

+0

不,它不工作絲毫[tps,]。 tps是一個邏輯向量,我沒有一個表中的變量來完成像[tps == TRUE] – delaye

回答

0

我必須找到一些東西...... 我不真的知道是否因爲工作我想使用ggplot後,它不能很好地工作,但惠特

jointure<-over(word,spdfxy) #over from sp library 
[email protected]<-cbind([email protected],jointure) 

你有所有的變量從spatialDataFrame點!