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

Johannes Radinger JRadinger at gmx.at
Fri Mar 2 09:56:06 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= ?

Thank you, I wasn't aware of this module r.null, but thats what I was looking for as my values and my category is 0 (which I want to replace).

Just for my personal interest two questions:
1) What if I want to replace the category "0" with NULL (not the values 0)
2) What would be the correct module if I want to assign another category than NULL to certain values? Is hat module r.category? And how can that be used in pyhton (how are the rules supplied)? Eg. assign all values greater than 0 to 1 all other values NULL.

cheers
Johannes


> 
> Moritz
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user

-- 
NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone!                                  
Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a


More information about the grass-user mailing list