I'd recommend using gdalwarpgdalwarp
as you can increase the efficiency of the process. Imagine
For example, if you want to cut a raster inraster.tifinraster.tif
with a shapefile extent.shpextent.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
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 1) a multicore implementation and 2) setting the cache available to the function.:
- A multicore implementation.
- Setting the cache available to the function.