
Last chance! 50% off unlimited learning
Sale ends in
crop an sf object to a specific rectangle
st_crop(x, y, ...)# S3 method for sfc
st_crop(x, y, ..., xmin, ymin, xmax, ymax)
# S3 method for sf
st_crop(x, y, ...)
object of class sf
or sfc
numeric vector with named elements xmin
, ymin
, xmax
and ymax
, or object of class bbox
, or object for which there is an st_bbox method to convert it to a bbox
object
ignored
minimum x extent of cropping area
minimum y extent of cropping area
maximum x extent of cropping area
maximum y extent of cropping area
setting arguments xmin
, ymin
, xmax
and ymax
implies that argument y
gets ignored.
# NOT RUN {
box = c(xmin = 0, ymin = 0, xmax = 1, ymax = 1)
pol = st_sfc(st_buffer(st_point(c(.5, .5)), .6))
pol_sf = st_sf(a=1, geom=pol)
plot(st_crop(pol, box))
plot(st_crop(pol_sf, st_bbox(box)))
# alternative:
plot(st_crop(pol, xmin = 0, ymin = 0, xmax = 1, ymax = 1))
# }
Run the code above in your browser using DataLab