The function crops the spatial extent of raster objects or other spatial objects based on bounding box coordinates.
spatial_crop(data, bbox)
spatial object, cropped to bounding box
raster
object, spatial data set to be processed.
Numeric
vector of length four, bounding box coordinates
in the form c(xmin, xmax, ymin, ymax)
Michael Dietze
## create example data set
x <- raster::raster(nrows = 100,
ncols = 100,
xmn = 0,
xmx = 10,
ymn = 0,
ymx = 10)
raster::values(x) <- 1:10000
## create crop extent vector
bbox <- c(3, 7, 3, 7)
## crop spatial object
y <- spatial_crop(data = x,
bbox = bbox)
## plot both objects
raster::plot(x)
raster::plot(y, add = TRUE)
Run the code above in your browser using DataLab