[GRASS-user] simple Grass.script python script, how to?

Hello grass users!

I am quite new to use grass gis via a python script from outside.
I am runnning grass gis on windows and I can call grass.script in python.

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?
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.

Can someone just give me an example for these two commands and how such a .py will look like...

Thank you very much

Johannes
--
Sicherer, schneller und einfacher. Die aktuellen Internet-Browser -
jetzt kostenlos herunterladen! http://portal.gmx.net/de/go/atbrowser

Hi,

2011/1/28 Johannes Radinger <JRadinger@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