[GRASS-user] simple Grass.script python script, how to?
Martin Landa
landa.martin at gmail.com
Fri Jan 28 06:56:27 EST 2011
Hi,
2011/1/28 Johannes Radinger <JRadinger at gmx.at>:
> After reading the grass-website about python scripts, I still don't know how to start. I just want to create a .py file which i than want to run.
>
> This python script should do following simple grass command:
>
> v.to.rast input=river output=river_raster use=val value=1 --o
> but how does a pyhton script look like for this command?
use run_command from `core` module [1].
grass.run_command('v.to.rast', overwrite = True, input = 'river',
output = 'river_raster', use = 'val' value = 1)
> I first need to define my location and my mapset and I have to import or define somehow the variable river. How do I set the region? In Grass I just do g.region vect=river res=10 save=region_river.
same as above use run_command().
Martin
[1] http://grass.osgeo.org/programming7/namespacepython_1_1core.html#af6691d41ff96f1e0f8c6c1822c6b808c
--
Martin Landa <landa.martin gmail.com> * http://geo.fsv.cvut.cz/~landa
More information about the grass-user
mailing list