[gdal-dev] ASCII Rasters and 'null' values in python-gdal
Frank Warmerdam
warmerdam at pobox.com
Fri Feb 27 11:40:36 EST 2009
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
and watch the world go round - Rush | Geospatial Programmer for Rent
More information about the gdal-dev
mailing list