Viewshed analysis of a line feature draped over a DEM.
First, obtain a raster digital elevation model. Edit the variable R_DEM
to point to it. Viewshed will be determined on this surface.
Secondly, obtain a line vector feature (a shapefile's good). Edit the variable LINE_SHP
to point to it. You may like to simplify the line or edit out the tunnels (where nothing is generally visible). The viewshed will be determined using a sample of points along this line as observer locations.
- In a terminal:
$ grass64
or$ grass70
as per what version of GRASS GIS you are using. (GRASS 7.0 will be faster for this task.) - Set up and/or connect to the GRASS workspace where your project data is available and will be stored.
- Type
$ sh generate_los.sh
or$ sh generate_los_70.sh
according to your GRASS GIS version, in the command line. Note that while GRASS 6.4 is the current stable release, the viewshed functionality in GRASS 7 is improved in performance and in cabability. Indeed, the maximum visible distance is adjusted in the GRASS 6.4 script to reflect the fact that the documentation ofr.los
suggests a maximum of 1000 rows and columns in the input raster used for the visibility analysis (given its resolution). The GRASS 7 script does not require this (r.viewshed
). - Add an argument to this statement: either
-train
or-road
depending on whether you want to run the intervisibility analysis for the road route, or the rail route. - Execute your command, and wait (probably a very long time).
- Examine your result (enter
exit
to quit GRASS). - Create tiles/tweak your slippy map.
- ????
- Profit.
Note that for a very long and/or detailed line feature and/or a high-resolution DEM and/or a large DIST_PTS
variable and/or a large MAX_VIS_DIST
the procedure can take several hours to complete. You might like to test with non-default values first.
generate_los.sh
assumes GRASS 6.4. For GRASS 7.0 (currently not the stable release), use generate_los_70.sh
or see original repo (by @pierreroudier).
I used QTiles, a QGIS plugin, to create tiles. There are other methods.
A long, beautiful train journey in New Zealand, the economics of choosing a train over driving, and this blog post on doing the same thing with R/GRASS.