<div>Hi all,</div><div><br></div><div>I am going to calculate cumulative viewshed analysis by adding each viewshed result of several observer locations</div><div>with r.mapcalc using Python. Observer locations are read from a file. GenerateViewshed method is executed inside the Iterate</div>
<div>File method (see the methods below). When i execute this it fails create the output with following errors:</div><div><br></div><div><div>ERROR: Sorry, <r> is not a valid flag</div><div>ERROR: Sorry, <o> is not a valid flag</div>
<div>ERROR: Sorry, <u> is not a valid flag</div><div>ERROR: Sorry, <t> is not a valid flag</div><div>ERROR: Sorry, <p> is not a valid flag</div><div>ERROR: Sorry, <u> is not a valid flag</div><div>
ERROR: Sorry, <t> is not a valid flag</div><div>ERROR: Sorry, < > is not a valid flag</div><div>ERROR: Sorry, <=> is not a valid flag</div></div><div><br></div><div>and in the command console </div><div>
<br></div><div><div>Command 'd.rast map=brian@PERMANENT' failed</div><div>Details: Unknown display driver <cairo></div></div><div><br></div><div>The name of the output file i gave is brian which is referred by parameter routput in GenerateViewshed method. Any idea on the errors??</div>
<div><br></div><div>Cheers, Brian</div><div><br></div><div>----Python code-------------</div><div><br></div><div>def IterateFile(infile):</div><div>    </div><div>    i=0</div><div>    for line in fileinput.input(infile):        </div>
<div>        values = string.split(line,",")</div><div>        pid = values[0]</div><div>        print pid</div><div>        e = values[2]</div><div>        print e</div><div>        n = values[1]</div><div>        print n</div>
<div>        z = values[3]</div><div>        print z</div><div>        GenerateViewshed(e,n,1.5,25,i)</div><div>        i = i + 1</div><div><br></div><div>def GenerateViewshed(x,y,oelv,th,i):   </div><div>    grass.run_command('r.viewshed', input = rinput, output = 'viewshed', coordinate = [x,y], obs_elev = oelv, tgt_elev = th, memory = 4098, overwrite = True, quiet = True)<span class="Apple-tab-span" style="white-space:pre">     </span></div>
<div>    if i==0:</div><div>        grass.run_command('r.mapcalc', 'routput = viewshed + 0', overwrite = True, quiet = True)</div><div>    if i>=1:</div><div>        grass.run_command('r.mapcalc', 'routput = viewshed + routput', overwrite = True, quiet = True)</div>
<div><br></div>