[gdal-dev] What is the empty pixel value for datasets?

Even Rouault even.rouault at spatialys.com
Wed Feb 7 09:26:28 PST 2024


Hi Sean,

good question.

gdal_create just calls GDALCreate(), and doesn't "burn" any pixel value 
by itself, unless you use the -burn switch

Which brings the question to the behavior of GDALCreate() itself. And I 
don't think this is specified indeed and behavior will be driver dependant.

I would expect most "raw" drivers to zero initialize the dataset, 
typically by seeking to the (size of the file - 1)th byte and writing a 
single zero, and relying on sparse file mechanisms of operating systems 
to also zero-initialize the areas of the file not explicitly written.

A few "smart" drivers like the GTiff one will write the nodata value (or 
0 if no nodata explicitly set). Either physically in default mode, or in 
SPARSE_OK=YES mode, the reading side of the driver will consider that 
sparse tiles are initialized to nodata. The GPKG raster driver will also 
behave like that (it has actually an optimization that if you burn a 
tile to the nodata value, it will detect that and will not physically 
write it).  The ERDAS Imagine one also honours implicitly burning the 
nodata value.

Hopefully drivers should implement one of the above 2 behaviors. I'd 
consider it a bug of a driver if you get random garbage

Even

Le 07/02/2024 à 18:13, Sean Gillies via gdal-dev a écrit :
> Hi all,
>
> I haven't found a specification for the empty pixel value of datasets 
> created by, say, gdal_create. Is it format specific?
>
> -- 
> Sean Gillies
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev

-- 
http://www.spatialys.com
My software is free, but my time generally not.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20240207/988723fb/attachment.htm>


More information about the gdal-dev mailing list