I'm trying to extract points by a polygon using the 'sp' package function 'over'
library(sp)
library(rgeos)
#my polygon plgn (many polygon features in one)
plot(plgn)
proj4string(plgn) = CRS("+proj=utm +zone=46 +datum=WGS84 +units=m +no_defs")
#giving spatial reference to point data d
coordinates(d) <- ~X+Y
proj4string(d) = CRS("+proj=utm +zone=46 +datum=WGS84 +units=m +no_defs")
#USE overlay (there are many NAs)
overlay=d[!is.na(over(d, plgn)),]
Unfortunately, I'm getting an ERROR
Error in d[!is.na(over(d, plgn)), ] :
matrix argument not supported in SpatialPointsDataFrame selection
Any idea?? Is it because my polygon contains 100s of features?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…