[GRASS-windows] grass.run_command issue for display a vector and its labels

Glynn Clements glynn at gclements.plus.com
Tue Nov 6 15:49:32 PST 2012


Liu, Huili wrote:

> I am running an issue to display a vector and overlay its label on
> the top by using grass.run_command (WinGrass-6.4).
> For example,
> grass.run_command('d.vect', map='my_shape')
> grass.run_command('d.labels', labels='my_shape_labels')
> 
> First one created a default.png but second command overwrote
> default.png with the labels only.
> Can anyone point to me if one grass.run_command can handle multiple
> commands like
> grass.run_command(('d.vect', map='my_shape'; 'd.labels',
> labels='my_shape_labels') to generate one default.png with two
> layers information such as vector and its labels? Or is there any
> better way to do it? I was thinking about v.overlay but I look for
> the above possibility.

If the environment contains the setting GRASS_PNG_READ=TRUE, d.*
commands should overlay their output on an existing image. So the
following should work:

grass.run_command('d.vect', map='my_shape')
env = os.environ.copy()
env['GRASS_PNG_READ'] = 'TRUE'
grass.run_command('d.labels', labels='my_shape_labels', env = env)

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-windows mailing list