[GRASS-user] r.sun in python loop

Hello,

I want to run the r.sun command within a loop. First I've tried to do that
within a small shell-scrip, but recieved some error messages. Although the
loop is working within the linux terminal it doesnt in the GRASS GIS command
line.. (using GRASS GIS 6.4.2)
However, now I want to run the loop in the Python Shell command line. Sadly
I have no idea how.. ;/
I think its not a big challenge if you know the basics of python, but I dont
know them.
Maybe someone can help me, especially how to define variables and implement
the r.sun tool.

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/r-sun-in-python-loop-tp4986713.html
Sent from the Grass - Users mailing list archive at Nabble.com.

Read http://grass.osgeo.org/wiki/GRASS_and_Python
http://grass.osgeo.org/wiki/GRASS_and_Python
First, you need to set some environment variables:

export GISBASE="/usr/local/grass-6.4/"
export PATH="$PATH:$GISBASE/bin:$GISBASE/scripts"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$GISBASE/lib"
# for parallel session management, we use process ID (PID) as lock file
number:
export GIS_LOCK=$$
# path to GRASS settings file
export GISRC="$HOME/.grassrc6"

After that in the Python Shell:

   import grass.script as grass
   gisbase = os.environ['GISBASE']
   gisdb="/path/your grassdata"
   location="your location"
   mapset="your mapset"
   import grass.script.setup as gsetup
   gsetup.init(gisbase, gisdb, location, mapset)

and you are working in the chosen location and mapset
# for example list of vectors
res = g.parse_command("g.list", _type="vect")
for elem in res:
       print "element:" +elem
etc.

see
http://osgeo-org.1560.n6.nabble.com/Automatic-3D-geological-boreholes-representation-automate-v-extrude-from-a-table-my-solution-in-Pythn-td4978801.html
http://osgeo-org.1560.n6.nabble.com/Automatic-3D-geological-boreholes-representation-automate-v-extrude-from-a-table-my-solution-in-Pythn-td4978801.html
,
http://osgeo-org.1560.n6.nabble.com/access-vertices-coordinates-of-a-line-from-Python-td4983417.html
http://osgeo-org.1560.n6.nabble.com/access-vertices-coordinates-of-a-line-from-Python-td4983417.html
or
http://osgeo-org.1560.n6.nabble.com/GRASS-and-the-Python-geospatial-modules-Shapely-PySAL-td4985075.html
for some scripts and references

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/r-sun-in-python-loop-tp4986713p4986726.html
Sent from the Grass - Users mailing list archive at Nabble.com.