Points in polys with sf

2018/04/19

Suppose we want to know what which points (points.shp, here) lie within any of a set of polygons (polys.shp, here) using sf.

points.shp <- points.shp[apply(st_intersects(points.shp, polys), 1, any),]

This isn’t an MWE but you get the idea. Of course, make sure they are using the same projection.