Clip raster
Cuts a raster to a polygon mask or a bounding box.
Pitfall. Cells outside the mask become nodata; a raster without a nodata value turns them into real zeros.
| Also called | Clip Raster, Extract by Mask, Clip raster by mask layer, Clip raster by extent |
|---|---|
| Group | raster/extraction |
| Checks | crs.agreement, raster.nodata |
| Pitfalls | 1 listed above |
| Columbus tool | raster_op · clip |
| Notes | Not stated |
| Status | active |
| Broader | Not stated |
| Narrower | Not stated |
| Related |
Parameters
| Name | Type | Required | Default | Values | Note |
|---|---|---|---|---|---|
bbox | extent | no | Not stated | Not stated | Used when there is no mask. |
bbox_crs | crs | no | Not stated | Not stated | Not stated |
all_touched | boolean | no | Not stated | Not stated | Keep every cell the mask touches, not only cells whose centre is inside. |
Inputs and outputs
| Direction | Name | Type | Geometry | Note |
|---|---|---|---|---|
| Input | raster | raster | Not stated | Not stated |
| Input | mask | vector | polygon | Optional; a bbox can be given instead. |
| Output | output | raster | Not stated | Not stated |
In each engine
| Engine | Tool | Parameters | Differences |
|---|---|---|---|
gdal | gdal raster clip |
| None noted |
postgis-raster | st_clip |
| None noted |
qgis | gdal:cliprasterbymasklayer |
|
|
rasterio | rasterio.mask.mask |
|
Preset: {"crop":true} |
rioxarray | rioxarray.raster_array.RasterArray.clip |
|
|
terra | terra::crop |
|
Preset: {"mask":true} |
whiteboxtools | ClipRasterToPolygon |
| None noted |