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

Moritz Lennert mlennert at club.worldonline.be
Mon Mar 5 11:06:58 EST 2012


On 05/03/12 15:56, Johannes Radinger wrote:
> Hi,
>
> -------- Original-Nachricht --------
>> Datum: Fri, 02 Mar 2012 20:22:30 +0100
>> Von: Moritz Lennert<mlennert at club.worldonline.be>
>> An: Johannes Radinger<JRadinger at gmx.at>
>> CC: grass-user at lists.osgeo.org
>> Betreff: Re: [GRASS-user] Replace 0 by NULL in categorial raster map
>
>> On 02/03/12 15:56, Johannes Radinger wrote:
>>> Just for my personal interest two questions: 1) What if I want to
>>> replace the category "0" with NULL (not the values 0)
>>
>> Category 0 = value 0.
> sorry I meant the category named (with label) "0".
>

In that case you have to first use your label as a new category value. 
You can do that in r.mapcalc with the @ operator:

r.mapcalc labelmap = @categorymap

> But how can I simply use a rule in when calling r.reclass in  a python script???
>
> 		grass.run_command("r.reclass",
> 					input = "in",
> 					output = "out",
> 					rules = ???)


http://lists.osgeo.org/pipermail/grass-user/2011-November/062803.html

;-)

To make it easier, here's an example with r.colors that you can 
transform for r.reclass:

colorrules = '0 255:255:255 \n 1 165:42:42'
grass.write_command('r.colors', map=carte_diff, rules='-', 
stdin=colorrules, quiet=True)

Moritz


More information about the grass-user mailing list