[GRASS-user] How to create+use reclass or recode rules in a python script

Moritz Lennert mlennert at club.worldonline.be
Thu Dec 1 04:53:51 EST 2011

On 01/12/11 07:40, Glynn Clements wrote:
> Moritz Lennert wrote:
>> I'm pretty sure someone has already answered this, but cannot get my
>> hands on the relevant mail: which grass python lib function should I use
>> and how in order to be able to feed r.recode, r.reclass, r.colors, etc
>> rules on the fly ?
> feed_command() or write_command().
> The former returns a Popen object, so you can write to its .stdin
> member. You need to call p.stdin.close() and p.wait() once you're
> done.
> The latter accepts the input as a string via the stdin= parameter,
> waits for completion and returns the exit status.

Thanks, write_command() is perfect for me !

Just one question using it with r.recode:

When I use it without a rules parameter it works, but when I use it with 
rules='-' it gives me 'ERROR :Unable to open file <->'. Is this expected 
behaviour ?


More information about the grass-user mailing list