Hi,<div><br></div><div><div class="post-text">
        <p>I need to do integrated viewshed analysis of a target with 
several observer locations. I am going to use r.viewshed analysis 
function in GRASS. With this function, it is possible to perform 
analysis based on single observer location. My aim is to add output of 
each single observer location into integrated viewshed output. Each 
output, i am going to flag with -b where o denotes non-visible while 1 
denotes visible. Through a loop of observer locations, output of 
viewshed of each location can be integrated with r.mapcalc function. 
After integration, values = 0 in the rater map dentoes non-visible areas
 and value >= 1 denotes visible areas. Under the loop of observer locations I just used r.mapcalc function with each viewshed adding. After getting the 
integrated viewshed raster, i need to extract its boundary depicting 
visible area in vector format. How to do that in GRASS?</p><p><br></p><p>Using IterateFile method, i read observer locations and with GenerateViewshed method, i calculate each single viewshed of a particular location. Then with r.mapcalc, i integrated all viewsheds. I want to find if r.mapcalc python code i have used is correct. If it is correct, how to extract the boundary of the visible area in vector format?</p>
<p><br></p>

<p></p><p>def IterateFile(infile):</p><p>    i=0</p><p>    for line in fileinput.input(infile):        </p><p>        values = string.split(line,",")</p><p>        pid = values[0]</p><p>        print pid</p><p>
        e = values[2]</p><p>        print e</p><p>        n = values[1]</p><p>        print n</p><p>        z = values[3]</p><p>        print z</p><p>        GenerateViewshed(e,n,1.5,25,i)</p><p>        i = i + 1</p><p>            </p>
<p>def GenerateViewshed(x,y,oelv,th,i):</p><p>    standard_DEM = options['standardDEM']</p><p>    output = options['outputmap']</p><p>    grass.run_command('r.viewshed', input=standard_DEM, output='viewshed',coordinate=[x,y], obs_elev=oelv, </p>
<p>tgt_elev=th,memory=4098,b=True,overwrite=True,quiet=True)<span class="Apple-tab-span" style="white-space:pre">       </span></p><p>    if i==0:</p><p>        grass.mapcalc('output = viewshed + 0')</p><p>    if i>=1:</p>
<p>        grass.mapcalc('output = viewshed + output')</p><div><br></div><p></p></div></div>