[GRASS-user] Using d.vect in python script
Glynn Clements
glynn at gclements.plus.com
Thu May 19 02:20:45 EDT 2011
Daniel Victoria wrote:
> It's my first grass python script using all the bells and whistles
> (g.parser gui construction and the grass.run_command) so I might be
> asking something silly.
>
> Can I use d.vect and d.rast commands in python script so that the map
> is displayed in the GUI? I'm running the grass script inside the
> command console window.
>
> For instance, if I type:
>
> d.vect munic
>
> in the command console, the munic vector is displayed in the GUI but,
> if I put grass.run_command("d.vect", map=munic) in a python script and
> run this from the command console, nothing happens.
The GUI has a hack where commands beginning with "d." are treated
specially.
If your script name begins with "d.", you may be able to get it to
work with your script. Otherwise, the correct way to display the
output from a script in the GUI is to add a new command layer.
Either way, if the script executes multiple display commands, you
need:
os.environ['GRASS_PNG_READ'] = 'TRUE'
after the first command in order to have subsequent commands render on
top of previous commands. Otherwise, each command will clear the
image, and you'll only see the result of the last one.
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-user
mailing list