<div dir="ltr">Hi, Thanks for the answer. <br>Ok, I admit the way I presented my first email is a bit confusing. <br>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. <br>
My problem is that GDAL is converting the last -9999 value to this value 31081. <br>raster2.asc and looks like this:<br><dl><dt>in text editor:<br></dt><dd><code>ncols 6<br>
nrows 4<br>xllcorner 3366820.0000019<br>yllcorner 5814589.0300007<br>cellsize 10<br>NODATA_value -9999<br>1 1 1 1 1 1<br>1 1 1 1 1 1<br>1 1 1 1 1 1<br>1 1 1 1 -9999 -9999</code></dd></dl><code>in python: <br>
>>> dataset = gdal.Open('raster1.asc', GA_ReadOnly)<br>
>>> a = gdal_array.DatasetReadAsArray(dataset)<br>>>> a<br>array([[ 1, 1, 1, 1, 1, 1],<br> [ 1, 1, 1, 1, 1, 1],<br> [ 1, 1, 1, 1, 1, 1],<br>
[ 1, 1, 1, 1, -9999, 31081]], dtype=int16)<br>>>> <br></code><br>Thanks again, <br>Oz. <br><br><div class="gmail_quote">On Fri, Feb 27, 2009 at 3:26 AM, Chaitanya kumar CH <span dir="ltr"><<a href="mailto:chaitanya.ch@gmail.com">chaitanya.ch@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Oz,<br>
<br>
NODATA_VALUES is supposed to be a pixel value (integer or real)<br>
whereas "null" is a string. Try to convert all the "null" strings into<br>
an unused pixel value like -9999 in raster1.asc<br>
<br>
Regards,<br>
--<br>
Chaitanya kumar CH.<br>
<div><div></div><div class="h5"><br>
On Fri, Feb 27, 2009 at 2:34 AM, Oz Nahum <<a href="mailto:nahumoz@gmail.com">nahumoz@gmail.com</a>> wrote:<br>
> Hi,<br>
> I have to ascii raster that I created using a text editor:<br>
> the first is called raster1.asc and looks like this:<br>
> ncols 6<br>
> nrows 4<br>
> xllcorner 3366820.0000019<br>
> yllcorner 5814589.0300007<br>
> cellsize 10<br>
> NODATA_value -9999<br>
> 1 1 1 1 1 1<br>
> 1 1 1 1 1 1<br>
> 1 1 1 1 1 1<br>
> 1 1 1 1 -9999 -9999<br>
> The second is called raster2.asc and looks like this:<br>
> ncols 6<br>
> nrows 4<br>
> xllcorner 3366820.0000019<br>
> yllcorner 5814589.0300007<br>
> cellsize 10<br>
> NODATA_value null<br>
> 1 1 1 1 1 1<br>
> 1 1 1 1 1 1<br>
> 1 1 1 1 1 1<br>
> 1 1 1 1 null null<br>
><br>
> When I import them into python I find out the lower right corner of the<br>
> first raster is not giving the correct value: instead of 'null' qgis<br>
> displays the value '31081'.<br>
> The other raster is imported correctly and it showing 'null's for the two<br>
> last data cells.<br>
><br>
>>>> dataset = gdal.Open('raster2.asc', GA_ReadOnly)<br>
>>>> b = gdal_array.DatasetReadAsArray(dataset)<br>
>>>> b<br>
> array([[1, 1, 1, 1, 1, 1],<br>
> [1, 1, 1, 1, 1, 1],<br>
> [1, 1, 1, 1, 1, 1],<br>
> [1, 1, 1, 1, 0, 0]], dtype=int16)<br>
>>>> dataset = gdal.Open('raster1.asc', GA_ReadOnly)<br>
>>>> a = gdal_array.DatasetReadAsArray(dataset)<br>
>>>> a<br>
> array([[ 1, 1, 1, 1, 1, 1],<br>
> [ 1, 1, 1, 1, 1, 1],<br>
> [ 1, 1, 1, 1, 1, 1],<br>
> [ 1, 1, 1, 1, -9999, 31081]], dtype=int16)<br>
>>>><br>
><br>
><br>
> So before I go and open a bug, I just wanted to know - what is wrong ? Maybe<br>
> it's my system setup ? Maybe i don't write correct ascii rasters ? Also,<br>
> another thing I would like to bypass is the fact that 'null' values are<br>
> formed as zeros in gdal-numpy - this could lead to error when doing some<br>
> raster manipulations. Is there a way to by pass this (besides being<br>
> aware...)?<br>
><br>
> I use Debian Lenny the latest relevant packages from.<br>
><br>
> Thanks,<br>
> Oz N,<br>
> Grad Studend,<br>
> Universität Tübingen<br>
><br>
><br>
><br>
> --<br>
><br>
> ----<br>
> Imagine there's no countries<br>
> It isn't hard to do<br>
> Nothing to kill or die for<br>
> And no religion too<br>
> Imagine all the people<br>
> Living life in peace<br>
> ----<br>
> You all must read 'The God Delusion'<br>
> <a href="http://en.wikipedia.org/wiki/The_God_Delusion" target="_blank">http://en.wikipedia.org/wiki/The_God_Delusion</a><br>
> ---<br>
> when one person suffers from a delusion it is called insanity. When many<br>
> people suffer from a delusion it is called religion."<br>
> Robert Pirsig, Zen and the Art of Motorcycle Maintenance<br>
><br>
><br>
</div></div>> _______________________________________________<br>
> gdal-dev mailing list<br>
> <a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
> <a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
><br>
</blockquote></div><br><br clear="all"><br>-- <br><br>----<br> Imagine there's no countries<br> It isn't hard to do<br> Nothing to kill or die for<br> And no religion too<br>
Imagine all the people<br> Living life in peace <br>----<br> You all must read 'The God Delusion' <br> <a href="http://en.wikipedia.org/wiki/The_God_Delusion">http://en.wikipedia.org/wiki/The_God_Delusion</a><br>
---<br>when one person suffers from a delusion it is called insanity. When many people suffer from a delusion it is called religion."<br>Robert Pirsig, Zen and the Art of Motorcycle Maintenance<br><br>
</div>