Extracting points with polygon in R

前端 未结 1 1237
别那么骄傲
别那么骄傲 2020-12-21 07:12

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 o         


        
相关标签:
1条回答
  • 2020-12-21 08:10

    Your plgn is a SpatialPolygonsDataFrame, and as such, is.na(over(d, plgn)) returns a logical matrix. This cannot be used to subset your SpatialPoints*. You can do the following to convert the logical matrix to a vector that the subsetting operation can accommodate:

    d[complete.cases(over(d, plgn)), ]
    
    0 讨论(0)
提交回复
热议问题