cropFAST crops a raster file to a spatial extent using GDAL. It is useful when working with large-scale, memory-intensive datasets.

cropFAST(file, ext, verbose = TRUE, ...)

Arguments

file

Path to raster file.

ext

Extent object or such from which an extent can be extracted.

verbose

logical, if TRUE, details on the function's progress will be visibile on the console. Default is TRUE.

...

additional arguments passed to writeRaster, e.g. filename.

Value

Raster* object.

Details

GDAL must be installed. If no GDAL installation is found, cropFAST is masking raster::crop. The input file on disk will not be changed.

See also

Examples

# NOT RUN {
library(raster)

## load a file
path_tiff <- "/path/to/file.tiff"
r_tiff <- stack(path_tiff)

## define an AOI
data("aoi_data")
aoi <- aoi_data[[2]] # example AOI

## if necessary, reproject AOI to file CRS
aoi <- spTransform(aoi, crs(r))

## crop (file on disk will not be changed)
r_crop <- cropFAST(path_tiff, ext = aoi)

## crop to a new file
r_crop <- cropFAST(path_tiff, ext = aoi, filename = "/path/to/file_cropped.tiff")
# }