I'd recommend using gdalwarp
as you can increase the efficiency of the process.
For example, if you want to cut a raster inraster.tif
with a shapefile extent.shp
:
gdalwarp -cutline extent.shp -crop_to_cutline -of GTiff -dstnodata 255 inraster.tif inraster_cropped.tif -co COMPRESS=LZW -co TILED=YES --config GDAL_CACHEMAX 2048 -multi
The last two parameters allows you to boost the process using:
- A multicore implementation.
- Setting the cache available to the function.