[gdal-dev] Cropping a raster by a polygon - only nodata outside polygon wanted

mathieu mathieu.rajerison at gmail.com
Wed Jan 14 02:08:12 PST 2015


Hello,

I crop a 3 band raster by a polygon with the following formula :
/gdalwarp -of GTiff -cutline polygon.shp -cl polygon input.tif output.tif
/
But pixels outside my polygon are assigned the 0 value. I'd like them to
have nodata

If I put the -dstnodata 0 option :
/gdalwarp -of GTiff -cutline polygon.shp -cl polygon input.tif output.tif
-dstnodata 0/, all the pixels in each of the 3 bands that contain the 0
value will be turned to nodata, even if they are contained in my polygon.

Hence, 127 0 222 will become 127 nodata 222
or 0 127 222 will become nodata 127 222

How to put the nodata value only outside my polygon ?

Thanks a lot in advance !

Mathieu



--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Cropping-a-raster-by-a-polygon-only-nodata-outside-polygon-wanted-tp5181426.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.


More information about the gdal-dev mailing list