[gdal-dev] Crop raster without changing output pixel size

Alexander Bruy alexander.bruy at gmail.com
Wed Sep 25 01:58:46 PDT 2013


Hi all,

I have a georeferenced raster and want to crop it using shapefile as
mask layer. I use next command:

gdalwarp -q -cutline myshape.shp -crop_to_cutline -of GTiff input.tif output.tif

All fine except one thing: the output raster has another pixel size than input.
For example, input raster has pixel size 0.00833333,-0.00833333, and output
has 0.00833129,-0.00833387. I suspect this is related to rounding and 0.5
pixel offset (top left corner vs. pixel center).

When mask is rectangle, I can use gdal_traslate to clip, but often I need to
crop raster by non-rectangular mask.

Is it possible to do this without raster grid resampling? Keeping pixel size
is very important for further analysis.

Thanks
-- 
Alexander Bruy


More information about the gdal-dev mailing list