[GRASS-user] Error with r.mapcalc
Glynn Clements
glynn at gclements.plus.com
Tue Oct 26 10:55:33 EDT 2010
António Rocha wrote:
> I have a Python script with the following:
> # Conversion to at-sensor brightness temperature
> grass.mapcalc("$raster_file= $K2/log(($K1/$L)+1)", raster_file=raster_file, K2=K2, K1=K1,L= tempL)
> grass.mapcalc("$raster_file= if($raster_file < 0, null(), $raster_file)", raster_file=raster_file)
>
> When it runs the second grass.mapcalc I get the following error:
> ERROR: Unable to close raster map
> ERROR: An error occurred while running r.mapcalc
>
> Why am I obtaining this error? and How can I avoid it?
Because you're using the same map as both input and output, which
won't work. Either use a temporary name for the intermediate map, or
replace the second grass.mapcalc call with r.null, e.g.:
grass.run_command('r.null', setnull = '-2147483647--1')
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-user
mailing list