[GRASS-windows] Integrated viewshed analysis

Brian Sanjeewa Rupasinghe jinkabs at gmail.com
Sat Jan 5 07:39:38 PST 2013


Hi,

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?


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?


def IterateFile(infile):

    i=0

    for line in fileinput.input(infile):

        values = string.split(line,",")

        pid = values[0]

        print pid

        e = values[2]

        print e

        n = values[1]

        print n

        z = values[3]

        print z

        GenerateViewshed(e,n,1.5,25,i)

        i = i + 1



def GenerateViewshed(x,y,oelv,th,i):

    standard_DEM = options['standardDEM']

    output = options['outputmap']

    grass.run_command('r.viewshed', input=standard_DEM,
output='viewshed',coordinate=[x,y], obs_elev=oelv,

tgt_elev=th,memory=4098,b=True,overwrite=True,quiet=True)

    if i==0:

        grass.mapcalc('output = viewshed + 0')

    if i>=1:

        grass.mapcalc('output = viewshed + output')
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-windows/attachments/20130105/7553eeca/attachment.html>


More information about the grass-windows mailing list