[GRASS-user] Python + GRASS 6.4.3 + r.viewshed

Büro Seling buero-seling at t-online.de
Mon Jul 21 02:45:28 PDT 2014


Dear Group,

I ran into a problem and can?t find a soloution for myself.
So if anybody has an idea or a hind it would help me a lot!!

So her now the description of my problem:

My task is to write a python script to run GRASS commands from the 
outside (without starting GRASS explicit).
I work with GRASS 6.4.3 and Ubuntu 12.4 (OSGEO Live 7.0).
At first I wrote a script using r.los and everything work fine, than I 
changed to the r.viewshed command (I have to !)
and it didn?t worked any more.
So, as You can see here in the script, the parameters are the same but 
when I use r.viewshed instead of r.los I?am in trouble!

Python script (also attached):

#!/usr/bin/python


import os
import sys
import csv

gisbase = os.environ['GISBASE'] = "/usr/lib/grass64"

sys.path.append(os.path.join(os.environ['GISBASE'], "etc", "python"))
import grass.script as grass
import grass.script.setup as gsetup



gisdbase = os.path.join(os.environ['HOME'], "GRASSDATA")
location = "Goelenkamp"
mapset   = "PERMANENT"

gsetup.init(gisbase, gisdbase, location, mapset)

print grass.gisenv()


input_map = 'DHM'

StandorteWEA = csv.DictReader(open("StandorteWEA.csv", "rb"), delimiter=",")
for row in StandorteWEA:
     WEA = row["WEA"]
     Windpark = row["Windpark"]
     output_map = 'tmp_' + WEA
     # HERE is the Problem:
     # the next line works only when the script es started from within 
the terminal window from the started GRASS session
     #grass.run_command('r.viewshed', input = input_map, output = 
output_map,  coordinate=[2560807,5823616], obs_elev=100, max_dist=3000, 
overwrite=True)

     # the next line works fine from "within" and from "without"
     grass.run_command('r.los', input = input_map, output = output_map, 
coordinate = '2560807,5823616', obs_elev = '100', max_dist = '300', 
overwrite=True)

     grass.run_command('r.null', map = ('tmp_' + WEA))



And here is the error message:

Screenshot Error Message


Thanks in advance!

Stefan


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20140721/4cd4cc9e/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: r_viewshed_error.png
Type: image/png
Size: 87725 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20140721/4cd4cc9e/attachment-0001.png>


More information about the grass-user mailing list