[gdal-dev] -srcnodata in gdalwarp and gdalbuildvrt

Even Rouault even.rouault at spatialys.com
Thu Mar 29 12:23:08 PDT 2018


On mercredi 28 mars 2018 18:16:45 CEST Richard Greenwood wrote:
> I have a question that is probably more "user" than "developer". Is there
> different place that I should post my question?
> 
> I don't think that I understand -srcnodata. I assume that -srcnodata "0 0
> 0" on a 3 band image means that all 3 bands have to be 0 to be "no data"
> but I think what I'm seeing is that if any to the 3 bands is 0 then that
> pixel is considered to be "no data". Am I mis-understanding -srcnodata?

Richard,

That depends on the utility / algorithm.

For gdalwarp, -srcnodata "0 0 0" will imply by default -wo UNIFIED_SRC_NODATA=YES
See http://www.gdal.org/structGDALWarpOptions.html#a0ed77f9917bb96c7a9aabd73d4d06e08

For gdalbuilvrt / VRT (and other raster formats in general), nodata is evaluated on each band independantly. 
Unless you specify the NODATA_VALUES metadata item.

gdalbuildvrt out.vrt in1.tif in2.tif
gdal_edit.py -mo "NODATA_VALUES=0 0 0"

Then utilities/algorithms that can use mask bands (not all can do however) will behave as you expect. 

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list