[gdal-dev] ASCII Rasters and 'null' values in python-gdal

Oz Nahum nahumoz at gmail.com
Tue Mar 3 11:12:29 EST 2009


Hi,
Thank you all for your answers.
This was probably a bug in debian lenny:
python-gdal in lenny is 1.5.2-3
python-gdal in squeeze is 1.5.4-2

This behavior does not occur in debian squeeze, so I will look up if a bug
report on this exists in debian-lenny and report this internaly to the
debian guys.

Oz.

On Fri, Feb 27, 2009 at 5:40 PM, Frank Warmerdam <warmerdam at pobox.com>wrote:

> Oz Nahum wrote:
>
>> Hi, Thanks for the answer.
>> Ok, I admit the way I presented my first email is a bit confusing.
>> But the problem is not with the 'null' values. Rather the problem is with
>> the raster containing the no data values as -9999. This is a no data
>> representation like you said. My problem is that GDAL is converting the last
>> -9999 value to this value 31081.
>> raster2.asc and looks like this:
>>
>> in text editor:
>>    |ncols         6
>>    nrows         4
>>    xllcorner     3366820.0000019
>>    yllcorner     5814589.0300007
>>    cellsize      10
>>    NODATA_value -9999
>>    1 1 1 1 1 1
>>    1 1 1 1 1 1
>>    1 1 1 1 1 1
>>    1 1 1 1 -9999 -9999|
>>
>> |in python:      >>> dataset = gdal.Open('raster1.asc', GA_ReadOnly)
>>  >>> a = gdal_array.DatasetReadAsArray(dataset)
>>  >>> a
>> array([[    1,     1,     1,     1,     1,     1],
>>       [    1,     1,     1,     1,     1,     1],
>>       [    1,     1,     1,     1,     1,     1],
>>       [    1,     1,     1,     1, -9999, 31081]], dtype=int16)
>>
>
> Oz,
>
> I'm not seeing this behavior on my system:
>
> >>> a = gdalnumeric.DatasetReadAsArray(ds)
> >>> print a
> [[    1     1     1     1     1     1]
>  [    1     1     1     1     1     1]
>  [    1     1     1     1     1     1]
>  [    1     1     1     1 -9999 -9999]]
>
> I'd suggest filing a ticket on the issue and being very specific
> about the operating system platform, and GDAL version you are using.
> Also, make sure you zip and attach the grid file in case there is some
> issue with missing final newline or something that is having an influence.
>
> Best regards,
> --
>
> ---------------------------------------+--------------------------------------
> I set the clouds in motion - turn up   | Frank Warmerdam,
> warmerdam at pobox.com
> light and sound - activate the windows | http://pobox.com/~warmerdam<http://pobox.com/%7Ewarmerdam>
> and watch the world go round - Rush    | Geospatial Programmer for Rent
>
>


-- 


when one person suffers from a delusion it is called insanity. When many
people suffer from a delusion it is called religion."
Robert Pirsig, Zen and the Art of Motorcycle Maintenance
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20090303/59c270fe/attachment.html


More information about the gdal-dev mailing list