Last chance! 50% off unlimited learning
Sale ends in
Cut out a part of a SpatRaster with a SpatExtent, or another object from which an extent can be obtained. You can only extract rectangular areas, but see mask
for setting cell values within SpatRaster to NA
.
# S4 method for SpatRaster,ANY
crop(x, y, snap="near", filename="", overwrite=FALSE, wopt=list(), ...)
# S4 method for SpatVector,SpatVector
crop(x, y, ...)
SpatRaster or SpatVector
SpatExtent or other object that has a SpatExtent; or SpatVector if x
is a SpatVector
character. One of "near", "in", or "out"
character. Output filename. Optional
logical. If TRUE
, filename
is overwritten
list. Options for writing files as in writeRaster
additional arguments. None implemented
SpatRaster
# NOT RUN {
r <- rast(xmin=0, xmax=10, ymin=0, ymax=10, nrows=25, ncols=25)
values(r) <- 1:ncell(r)
e <- ext(-5, 5, -5, 5)
rc <- crop(r, e)
# }
Run the code above in your browser using DataLab