[GRASS-dev] Incomplete raster history in r.mapcalc

Glynn Clements glynn at gclements.plus.com
Fri Apr 29 06:56:45 EDT 2011


Markus Neteler wrote:

> by chance I observed a detail:
> 
> GRASS 6.4.2svn (utm49n):~ > r.mapcalc "L5120060_06020060925_ndwi = 1.0
> * (L5120060_06020060925_toar.4 - L5120060_06020060925_toar.5) /
> (L5120060_06020060925_toar.4 + L5120060_06020060925_toar.5)"
>  100%
> 
> -> 1.0
> 
> GRASS 6.4.2svn (utm49n):~ > r.info -h L5120060_06020060925_ndwi
> Data Source:
> 
> Data Description:
>    generated by r.mapcalc
> Comments:
>    1 * (L5120060_06020060925_toar.4 - L5120060_06020060925_toar.5) /
>    (L5120060_06020060925_toar.4 + L5120060_06020060925_toar.5)
> 
> -> 1
> 
> ? I wonder where this get's eaten...

	static char *format_constant(const expression * e)
	{
	    char buff[64];
	
	    if (e->res_type == CELL_TYPE)
		sprintf(buff, "%d", e->data.con.ival);
	    else
		sprintf(buff, "%.8g", e->data.con.fval);
	
	    return strdup(buff);
	}

"%g" omits trailing zeros, and omits the decimal point if nothing
follows it. Using "%#.8g" would retain the decimal point and the
trailing zeros (G_trim_decimal() could be used to remove those).

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list