Opened 9 years ago

Closed 9 years ago

#4222 closed defect (worksforme)

clipping with gdal_translate and gdal warp returns different pixels values

Reported by: lutra Owned by: warmerdam
Priority: normal Milestone:
Component: GDAL_Raster Version: 1.8.0
Severity: normal Keywords:


Pick a raster and a shapefile (you can use the sample data attached to this ticket ) and then try to clip the raster with gdal_translate or with gdalwarp using the shapefile as clip layer

gdal_translate -projwin 0.123237217937 44.0315093873 3.28820756354 40.6044095958 -of GTiff /home/gio/Downloads/srtm_37_04/srtm_37_04.tif /home/gio/Downloads/testmanualclip.tif
gdalwarp -q -cutline /home/gio/Downloads/FlxPyrAOI1/FlxPyrAOI1.shp -crop_to_cutline -of GTiff /home/gio/Downloads/srtm_37_04/srtm_37_04.tif /home/gio/Downloads/testshapeclip.tif

In the clipped rasters, the pixels values are identicla to the input one only when using gdal_translate. When clipping with the shapefile with gdal warp it is easy to see that many, but not all, pixels have a value that is different from the input one.

I'm using gdal 1.8 from the Ubuntugis repository under Ubuntu 11.04 64 bit

Change History (1)

comment:1 Changed 9 years ago by Even Rouault

Component: defaultGDAL_Raster
Milestone: 1.8.2
Priority: highnormal
Resolution: worksforme
Status: newclosed

Are you talking about the nodata areas ? Then you need to add -dstnodata -32768 to your gdalwarp command line.

Are you talking about the slight shift between srtm_37_04.tif and testshapeclip.tif ? I've verified it is below one pixel size, so it is due to the fact that the clipping doesn't occur exactly on a pixel edge of the input dataset, but that's expected.

So I don't see any outstanding issues there. Closing.

Note: See TracTickets for help on using tickets.