Is there a function to crop sf map object, similar to maptools::pruneMap(lines, xlim= c(4, 10), ylim= c(10, 15))
used for SpatialPolygon or SpatialLine?
I am considering st_intersection()
but there can be proper way.
cliprsf
Is there a function to crop sf map object, similar to maptools::pruneMap(lines, xlim= c(4, 10), ylim= c(10, 15))
used for SpatialPolygon or SpatialLine?
I am considering st_intersection()
but there can be proper way.
Best Answer
Since today, there is a
st_crop
function in the github version ofsf
(devtools::install_github("r-spatial/sf")
, probably on CRAN in the near future too).Just issue:
The vector must be named with
xmin xmax ymin ymax
(in whichever order).You can also use any object that can be read by
st_bbox
as cropping limits, which is very handy.