Hi all,<div><br></div><div>trying to rescale a map to 0:255 range, I run:</div><div><br></div><div><div>r.univar -g map</div><div>n=9599576</div><div>null_cells=0</div><div>cells=9599576</div><div>min=-1.55537462234497</div>
<div>max=274.231811523438</div><div>range=275.787186145782</div><div>mean=96.915776629461</div><div>mean_of_abs=96.915791505254</div><div>stddev=37.6540983935747</div><div>variance=1417.831125833</div><div>coeff_var=38.8523929778099</div>
<div>sum=930350363.3535346985</div><div><br></div><div>taking the max, i run:</div><div><br></div><div>r.mapcalc "map.invscaled = round((1.0 - map / 274.231811523438) * 255.0)"</div><div><br></div><div>But then:</div>
<div><br></div><div><div><a href="http://r.info">r.info</a> map.invscaled</div><div> +----------------------------------------------------------------------------+</div><div> | Layer:    map.invscaled                  Date: Fri Mar 15 20:36:38 2013    |</div>
<div> | Mapset:   PERMANENT                      Login of Creator: madi            |</div><div> | Location: massimozia                                                       |</div><div> | DataBase: /home/madi/grassdata                                             |</div>
<div> | Title:     ( map.invscaled )                                               |</div><div> | Timestamp: none                                                            |</div><div> |----------------------------------------------------------------------------|</div>
<div> |                                                                            |</div><div> |   Type of Map:  raster               Number of Categories: 0               |</div><div> |   Data Type:    CELL                                                       |</div>
<div> |   Rows:         4181                                                       |</div><div> |   Columns:      2296                                                       |</div><div> |   Total Cells:  9599576                                                    |</div>
<div> |        Projection: x,y                                                     |</div><div> |            N: 5170841.60115    S: 5045411.60115   Res:    30               |</div><div> |            E: 359567.587692    W: 290687.587692   Res:    30               |</div>
<div> |   Range of data:    min = 0  max = 256                                     |</div><div> |                                                                            |</div><div> |   Data Description:                                                        |</div>
<div> |    generated by r.mapcalc                                                  |</div><div> |                                                                            |</div><div> |   Comments:                                                                |</div>
<div> |    round((1 - map / 274.23181) * 255)                                      |</div><div> |                                                                            |</div><div> +----------------------------------------------------------------------------+</div>
</div><div><br></div><div>max = 256 must be an error in round() IMHO. Please let me know if I can't see the obvious.</div><div><br></div><div>Thanks,</div><div><br></div><div><br></div>-- <br><span style="border-collapse:separate;font-family:'Times New Roman';border-spacing:0px;font-size:medium"><span style="font-family:arial;font-size:small"><div>
<font color="#666666">Best regards,<br><br>Margherita DI LEO    </font></div><div><font color="#666666">Postdoctoral Researcher</font></div><div><font color="#666666"><br></font></div><div><font color="#666666">European Commission - DG JRC </font></div>
<div><font color="#666666">Institute for Environment and Sustainability (IES)</font></div><div><font color="#666666">Via Fermi, 2749</font></div><div><font color="#666666">I-21027 Ispra (VA) - Italy - TP 261</font></div><div>
<font color="#666666">       </font></div><div><font color="#666666">Tel. +39 0332 78 3600   </font></div><div><font color="#666666"><a href="mailto:margherita.di-leo@jrc.ec.europa.eu" target="_blank">margherita.di-leo@jrc.ec.europa.eu</a></font></div>
<div><font color="#666666"><br></font></div><div><font color="#666666">Disclaimer: The views expressed are purely those of the writer and may not in any circumstance be regarded as stating an official position of the European Commission.</font></div>
</span></span>
</div>