I try to clip raster data with GDAL (in fact I am using QGIS, which produces me a command line for GDAL) The raster has been transformed to EPSG:3857, which is also the projection of the shapefile which contains the boundaries.

gdalwarp -dstnodata 0 -q -cutline D:\GIS\data\cutline_shape.shp 
 -crop_to_cutline -of GTiff D:\GIS\data\raster_3857.tif D:/GIS/data/clipped_raster.tif

The clipping processes without error, but the GDAL clips a wrong portion of the raster, it has the correct shape but is about 20 km to the north of the shapefile.

  • 1
    Have you checked both files with gdalsrsinfo? I had similar issues when using EPSG:900913 instead of EPSG:3857. – AndreJ May 31 '13 at 11:09

if I do not reproject the raster data (it is in EPSG:31468 - DHDN / Gauss-Kruger zone 4) and do the clipping based on vector data with the same projection, the clipping works fine.

| improve this answer | |

You can try reprojecting the raster data but to EPSG:102113 instead, don't use 3857.

This post may help: Reprojecting WGS 1984 Web Mercator (EPSG:3857) in Python with GDAL

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.