[GRASS-user] Replace 0 by NULL in categorial raster map

Moritz Lennert mlennert at club.worldonline.be
Fri Mar 2 09:39:04 EST 2012


On 02/03/12 15:09, Johannes Radinger wrote:
> Hi,
>
> I'd like to replace all values/categories "0" by real NULL values.
> Furthermore I want to do that in a Python script. I tried to do it
> with mapcalc in the script but then I loose the category labels:
>
>
> grass.mapcalc("$out= if($in==0,null(),$in)",
> 				out = "in",
> 				in = "in")
>
> I am not sure if r.reclass or r.recode can be the right module here?
> Anyway if yes, how can they be used with a rule supplied
> in the python script (sstdin?). The desired approach should keep the other categories and their labels.
>
> grass.run_command("r.reclass", input="in", output="out", rules=??)

Any reason not to use r.null with parameter setnull= ?

Moritz


More information about the grass-user mailing list