Visibility between polygons

Lars Schylberg larss at
Wed Mar 24 12:18:13 EST 1993

> My main uncertainty concerns how much I can get away with using scripts, and
> how much C programming I need to do. For example, I would like a routine which
> will go through every cell in a given polygon and return a co-ordinate list,
> which can then be passed to <r.los> item by item. To get that list, is
> somewhere like <r.neighbours> the best place to look for code which could be
> adapted, or am I missing an easier way of doing it? Last wishful extension:
> it would be nice to be able to nominate co-ords interactively with the mouse,
> and have visible cells highlighted (presumably by overlay) on the map. Does
> this involve a simple grafting of <d.where> onto <r.los>, or am I being naively
> optimistic? 

I think you surely could solve this with a nice little script.  You
could could select the raster area with r.mapcalc.  Make a inside out
operation with r.reclass. Use r.buffer to get all pixels on the border
of of the area.  Select those pixels on the border with r.mapcalc.
Then the coordinates for those pixels could be output via r.stats -g .
With a nice bourne shell for loop and and some use of awk I am sure
you could feed these coordinates into r.los for every x and y value
and output a map for time in the loop.  Save these mapnames in a
file(eg. mapnames).

Make a new "for $i in `cat mapnames | awk '{print $1}'`" -loop and
patch these maps together with r.patch.  r.patch can only handle 
10 maps each time so you have to split list to groups of 9 maps and 
save temporary maps.

I hope that I haven't been to cryptic.  But with a few experiments I
think you get going. I also think d.where will work fine for an
interactive version for you.

Good luck


Lars Schylberg                          Email: larss at  
Dept. of Geodesy and Photogrammetry 
Royal Institute of Technology (KTH)     Tel.   +46 8 790 86 33   
S-100 44  STOCKHOLM, SWEDEN             Fax.   +46 8 790 66 10

More information about the grass-dev mailing list