[gdal-dev] GeoTiff null values

Chaitanya kumar CH chaitanya.ch at gmail.com
Fri Jul 30 04:08:43 EDT 2010


Filippo,

Please note that those values are called nodata values.

Nodata value is assigned a specific value during the creation of the raster
and all the pixels where data is unavailable are assigned that value.
Using the python interface, you can find the specified value with
GetNoDataValue(). You can compare it with "None" to check if a value is set.

if band.GetNoDataValue() != None:
    print band.GetNoDataValue()
else:
    print 'nodata not set'

You cannot reset all the nodata pixels of a raster band directly. You can
create a VRT file to do this. The VRT driver can translate the nodata value
from the underlying dataset to the value you specify with
<NoDataValue>99</NoDataValue>. http://www.gdal.org/gdal_vrttut.html

On Fri, Jul 30, 2010 at 11:44 AM, Filippo Corò <filippo.coro at alice.it>wrote:

>
> Hi List,
>
> I'm running tests with GDAL 1.7 and python  for achieving a function for
> the sum of GeoTIFF file. I found some difficulty in handling null values.
> I wanted to know if you can assign a specific value (like 99) to null when
> I call the Open function.
>
> The code is as follows:
>
> # Open the image 1
> primoDs=gdal.Open('eros.tif', GA_ReadOnly)
>
> primoBand=primoDs.GetRasterBand(1)
>
> If I use the following function:
>
> noval=primoBand.GetNoDataValue()
> print noval
>
> I get:
>
> 0.0 with null value:
>
> Is there any statement at this stage allow me to decide what value to
> assign to null, when I call gdal.open?
>
> Thanks in Advance
>
> Filippo Corò
>
>
> --
> Creato con il rivoluzionario client e-mail di Opera:
> http://www.opera.com/mail/
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>



-- 
Best regards,
Chaitanya kumar CH.
/tʃaɪθənjə/ /kʊmɑr/
+91-9494447584
17.2416N 80.1426E
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20100730/5dd8ce14/attachment-0001.html


More information about the gdal-dev mailing list