How can I do spatial selections or filters in R? I can do this in PostGIS using (e.g.):
SELECT * FROM mypoint, mypoly
WHERE ST_Within(mypoint.geom, mypoly.geom);
and it is similarly a piece of cake in most other GIS software. So I'd expect something in R to look like:
mypoint[within(mypoint, mypoly),]
but I can't find any leads anywhere. I'm looking for something that uses the common spatial predicate terminology used in PostGIS/GEOS/JTS/Shapely (within, contains, intersects, overlaps, touches, etc.; DWithin would be bonus). Does this functionality or library exist for R? If not, is there something that is similar?
Note: In R, I use the sp
class for my objects (SpatialPointsDataFrame
, etc).