Spatial data coercion

Can anyone offer advice/example code on how to create a data frame from the coordinates of a SpatialPolygonsDataFrame?
I have a shapefile I read into R with readOGR() and I want to us it in a pip() function to filter out points that are outside of a certain region. When I try to put it into the pip() I get an error that says Error in as.points(poly) : Cannot make points from this object


So you have a polygon and you want to filter out areas that aren't in a region? A reproducible example would be useful.

Otherwise, have a look at the sf package. Just read in your shapefile, then filter out the points either spatially or based on some criteria in the dataset.

I found a package called FRK that has a SpatialPolygonsDataFrame_to_df() that did what I needed. Thanks!

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.