Add visibility analysis tutorial (r.viewshed)#135
Conversation
New intermediate tutorial covering viewshed/visibility analysis: - a single-observer viewshed and measuring the visible area - the effect of observer height (ground vs 40 m tower) and max_distance - cumulative visibility from multiple sites with r.series Uses the North Carolina sample dataset and the grass.tools API (GRASS 8.5). Categories: raster, terrain, visualization, intermediate, Python.
|
The example developed is pretty basic, and the images are not visually appealing. They are too big, the legend and scale bar overlap. I would like to read a more compelling story, i.e., the observer in the center of the map is easy, but why are they there? Perhaps you could pick a different dataset or a different area and still make the tutorial reproducible by using r.in.usgs or i.eodag, and place the observer and the towers in places that actually mean something, not just in the center of the region. Please have a look at https://github.com/ncsu-geoforall-lab/grass-gis-workshop-foss4gna-2023, esp. notebooks 2 and 3, which cover similar analysis. |
Address review feedback: replace the synthetic center-of-map observer with a real story. The tutorial now uses three historic fire lookout towers in the Nantahala National Forest (Wayah Bald, Wesser Bald, Albert Mountain, verified coordinates on the Appalachian Trail) and downloads real USGS 1 arc-second elevation via the r.in.usgs addon into a new EPSG:32617 project, with a pinned tile for reproducibility. Content changes: - observer height: standing on the bald vs the 16 m cab (165 vs 277 km2) - Earth curvature with -c at a lookout's 32 km range, and why the effect is small in ridge-limited terrain - target_elevation as a rising smoke column (277 to 412 km2 detectable) - three-tower network summed with r.series, coverage reported as a table from r.report JSON output (44% of the region) - new worked section on siting a fourth tower: the best candidate recovers under 4% of the blind area because the gaps are valleys Figures regenerated at 600 px with labeled towers (d.text), shaded relief bases, non-overlapping legend and scale bar, and zoomed extents for the single-tower maps. Get-started link now points to the Python quick start; callouts are spread out; area estimation commands are shown in the text.
|
Thanks @veroandreo, this was the right push. I reworked the tutorial from scratch around a real story: the historic fire lookout towers of the Nantahala National Forest (Wayah Bald, Wesser Bald, and Albert Mountain, all still standing along the Appalachian Trail near Franklin, NC). The terrain now comes from the USGS via the The observers now mean something. These towers were sited for visibility, so each section answers a question their builders actually faced:
On the images: regenerated at 600 px with labeled towers, shaded relief bases, non-overlapping legend and scale bar, and zoomed extents for the single-tower maps. The get-started link now points to the Python quick start, the callouts are spread out, and the area estimation commands are shown in the text. Happy to adjust anything else. |
veroandreo
left a comment
There was a problem hiding this comment.
This version reads much better and it is more interesting too. I leave some comments and suggestions here and there before merging.
There was a problem hiding this comment.
Legend is not readable, please adjust the size
There was a problem hiding this comment.
In all cases, labels overlap the tower symbol, try moving them a little bit to the right so it looks better.
| Use r.viewshed and real USGS terrain to explore why fire lookout towers stand | ||
| where they do, how far they could see, and how well a network of them covered |
There was a problem hiding this comment.
| Use r.viewshed and real USGS terrain to explore why fire lookout towers stand | |
| where they do, how far they could see, and how well a network of them covered | |
| Use r.viewshed and USGS terrain data to explore why fire lookout towers stand | |
| where they do, how far they can see, and how well a network of them cover |
| ```bash | ||
| # One-time: create the project and install the add-on | ||
| grass -c EPSG:32617 ~/grassdata/nantahala -e | ||
| grass ~/grassdata/nantahala/PERMANENT --exec g.extension extension=r.in.usgs | ||
| ``` |
There was a problem hiding this comment.
You can use python for this too; see the create_project() function and how it is used in other tutorials
|
|
||
| # Download and import the National Elevation Dataset for this region | ||
| tools.r_in_usgs(product="ned", ned_dataset="ned1sec", ned_release="all", | ||
| title_filter="20220725", output_name="elevation", |
There was a problem hiding this comment.
| title_filter="20220725", output_name="elevation", | |
| output_name="elevation", |
There was a problem hiding this comment.
Better remove this so the default dataset is downloaded, even if in the future the data itself is different, it will always download something.
| detection_maps.append(out) | ||
|
|
||
| tools.r_series(input=detection_maps, output="coverage_sum", method="sum") | ||
| tools.r_mapcalc(expression="coverage = int(coverage_sum)") |
| | 2 | 214.8 | 13.7% | | ||
| | 3 | 61.1 | 3.9% | | ||
|
|
||
| The three towers between them watch about 692 km², or 44% of this 1,560 km² region. Only |
There was a problem hiding this comment.
| The three towers between them watch about 692 km², or 44% of this 1,560 km² region. Only | |
| The three towers together allow to watch about 692 km², or 44% of this 1,560 km² region. Only |
| test a tower there. | ||
|
|
||
| ```{python} | ||
| # cells no tower currently sees, and their elevation |
There was a problem hiding this comment.
| # cells no tower currently sees, and their elevation | |
| # cells no tower currently see, and their elevation |
| gs.write_command("r.colors", map="covered_now", rules="-", stdin="1 150:180:200") | ||
| gs.write_command("r.colors", map="recovered", rules="-", stdin="1 215:25:28") | ||
| gs.write_command("v.in.ascii", input="-", output="candidate", separator="pipe", | ||
| columns="x double precision, y double precision", x=1, y=2, | ||
| stdin=f"{cx:.0f}|{cy:.0f}") |
There was a problem hiding this comment.
I think this can also be translated into tools API
|
|
||
| # Summary | ||
|
|
||
| You have used |
There was a problem hiding this comment.
| You have used | |
| We have used |
- create the project in Python with create_project() and install the add-on with g.extension, instead of a shell block - read the tower coordinates (and the candidate site) with StringIO so v.in.ascii runs through the Tools API - report visible areas with r.report instead of a custom helper - redraw the figures: tower labels shifted clear of the markers, larger legends, smaller file sizes - wording fixes from the review; comment the integer coverage step The NED tile stays pinned with title_filter for reproducible numbers; the download note explains how to drop it to fetch the current data.
|
Thanks @veroandreo, glad the story landed! Pushed a round addressing the review:
One point I did not apply, and wanted to flag with data: removing Happy to switch to the unpinned default if you'd still prefer that; just wanted you to see the tradeoff first. |
The suggestion was to use the default |
Per review: drop ned_release=all and title_filter and let r.in.usgs fetch the current 1 arc-second tile (the default). For this footprint the current tile is identical to the previously pinned one, so all figures and reported areas are unchanged; the download note now says the numbers may shift slightly if USGS republishes the data.
|
You're right, and thanks for the nudge, I had it wrong. I switched to the default tools.r_in_usgs(product="ned", ned_dataset="ned1sec", output_name="elevation",
memory=1000, nprocs=2)The ±45 m difference was an artifact of |
Adds a new intermediate tutorial on visibility analysis with
r.viewshed — a topic
not currently covered in the tutorial set.
What it covers
max_distance(a 3 km radius).Details
elevationDEM) and the grass.tools API (GRASS 8.5), consistent with the recent NumPy/Landlab tutorial.eval: false, following the other Python tutorials).raster,terrain,visualization,intermediate,Python.Feedback on scope, wording, or the choice of observer sites is very welcome.