[gdal-dev] -srcnodata in gdalwarp and gdalbuildvrt

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[gdal-dev] -srcnodata in gdalwarp and gdalbuildvrt

rgreenwood
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?

Thanks
--
Richard W. Greenwood, PLS
www.greenwoodmap.com

_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: -srcnodata in gdalwarp and gdalbuildvrt

Even Rouault-2
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
_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: -srcnodata in gdalwarp and gdalbuildvrt

rgreenwood
Perfect. Thanks so much! And thank you for showing the syntax for gdalwarp as well as how to use gdal_edit.py. I would not have figured out these options without you help.

Best regards,
Rich


On Thu, Mar 29, 2018 at 1:23 PM, Even Rouault <[hidden email]> wrote:
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



--
Richard W. Greenwood, PLS
www.greenwoodmap.com

_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev