<br><br><div class="gmail_quote">2008/5/19 Hamish &lt;<a href="mailto:hamish_b@yahoo.com">hamish_b@yahoo.com</a>&gt;:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">&gt; Yann Chemin wrote:<br>
&gt; &gt; I have some data that reads as &quot;nan&quot;, while<br>
&gt; &gt; rare, it may happen when compressing/uncompressing<br>
&gt; &gt; GRASS Locations to ship them across Internet.<br>
<br>
</div>what method are you using to compress/decompress?<br>
..zip? .tar.gz? r.pack/r.unpack?<br>
</blockquote><div><br>Windows zip, ftp download across the World, then Linux unzip.<br><br>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
if r.pack I think it is safer to use the script in the trac wish patches which converts GRASS &lt;=6 raster dir layout to proposed GRASS 7 $MAPSET/raster/$NAME/element) then tarball up the map&#39;s dir, and vice versa. I should probably update r.pack not to use r.{in|out}.mat as that will lose some metadata for sure.<br>

</blockquote><div><br>We will use r.[,un]pack that from now on.<br>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<br>
places in the code to look for accidental creation of nan:<br>
- (x/y) where both the x and y variables could sometimes be 0.<br>
- tan(pi/2)<br>
- r.in.mat/r.out.mat use Matlab&#39;s NaN to store grass NULLs<br>
- GRASS nulls + non-core libgis functions meet mixed endian (?)<br>
- ?<br>
<div class="Ih2E3d"></div></blockquote><div><br>hmm, tan() is a suspect here. x==y==0 may also be, shall put tests but more complex.<br>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d"><br>
<br>
&gt; &gt; I would like to know how to deal with them in GRASS<br>
&gt; &gt; raster programming, so that they are:<br>
&gt; &gt; 1 - detected<br>
&gt; &gt; 2 - set to null<br>
<br>
</div>Glynn:<br>
<div class="Ih2E3d">&gt; &nbsp; &nbsp; &nbsp; if (x != x)<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; G_set_d_null_value(&amp;x, 1);<br>
&gt;<br>
&gt; There is also isnan(), which is in C99, and also specified<br>
&gt; by POSIX:<br>
&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/isnan.html" target="_blank">http://www.opengroup.org/onlinepubs/009695399/functions/isnan.html</a><br>
&gt;<br>
&gt; However, I don&#39;t know if it exists on all platforms<br>
&gt; which we care about. MSDN says that MSVCRT has _isnan() (with a<br>
&gt; leading underscore), but it&#39;s defined in &lt;float.h&gt; rather than<br>
&gt; &lt;math.h&gt;.<br>
&gt;<br>
&gt; The (x != x) test should be portable; OTOH, it&#39;s the<br>
&gt; kind of thing that compilers often get wrong, particularly when<br>
&gt; optimising (if you ignore NaN, x!=x is always false).<br>
<br>
<br>
</div>there is a longstanding wish that &#39;r.null setnull=&#39; could understand nan, so that you could get rid of them. e.g. very rarely r.in.xyz will create them, I am not sure why/how.<br>
<div class="Ih2E3d"></div></blockquote><div><br>would be useful to make coloring of output maps appear... right now nan intefers in the standard colors setup, it seems.<br>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d"><br>
<br>
&gt; For 7.0, I intend to change G_is_[fd]_null_value() to treat<br>
&gt; all NaN values as null, not just the specific bit patterns which<br>
&gt; it currently uses.<br>
<br>
</div>the only reason I could see to keep them as nan not grass-NULL would be for debugging (there is obviously a bug if you get them..).<br>
<font color="#888888"><br>
<br>
Hamish<br>
<br>
<br>
<br>
<br>
<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Yann Chemin<br>International Rice Research Institute<br>Office: <a href="http://www.irri.org/gis">http://www.irri.org/gis</a><br>Perso: <a href="http://www.freewebs.com/ychemin">http://www.freewebs.com/ychemin</a>