mosaic_clip | R Documentation |
Quickly partition a large raster mosaic into individual tiles using a
polygon layer. Each tile is clipped by either the polygon's bounding box
or (optionally) the exact feature geometry, and written to disk as a separate
GeoTIFF named by the feature's unique_id
.
mosaic_clip(
mosaic,
shapefile,
unique_id = "unique_id",
out_dir = NULL,
overwrite = TRUE,
verbose = TRUE,
exact = FALSE,
parallel = FALSE,
workers = NULL
)
mosaic |
A terra::SpatRaster object or a file path pointing to a raster. In-memory rasters are first written to a temporary GeoTIFF. |
shapefile |
An sf::sf, terra::SpatVector, or path to a vector file. Must
contain a column named |
unique_id |
A column present in |
out_dir |
Directory where clipped rasters will be saved. Defaults to the current working directory. Created recursively if it does not exist. |
overwrite |
Logical; if |
verbose |
Logical; if |
exact |
Logical; if |
parallel |
Logical; if |
workers |
Integer; number of parallel daemons to launch when |
Clip a Raster Mosaic by Polygons
This function wraps GDAL's warp
utility for efficient raster clipping.
When parallel = TRUE
, it will spawn multiple workers via mirai
and
process tiles in batches. Use exact = TRUE
to clip to the true polygon
shape (at some extra cost), or leave exact = FALSE
for a faster
bounding-box crop.
Invisibly returns a character vector of file paths to all clipped GeoTIFFs.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.