Friday, May 17, 2013

Viewshed Analysis

Viewshed analyses, typically the realm of expensive GIS software, show you all the areas that are visible from a given point.  They can be useful for estimating radio effectiveness, planning photographs or simply checking out the view from a high point.  CalTopo now supports them in easy, drag-and-drop form.

slowly growing list of data analysis layers

To start a viewshed, simply click Add New Layer and then Add Viewshed Analysis.

A bullseye target icon will appear on the map; drag it to the location you want to run the viewshed from.  You can also choose how high above ground the analysis should start from; the default is 20m, which helps when you don't drop the icon exactly on top of a high point.  Click save and presto, viewshed:

the view from Jigsaw Pass

Mt Diablo in California is (falsely, according to Wikipedia) rumored to have one of the largest viewsheds on the planet due to its prominence above flat terrain.  What does it look like?  Let's find out:

the Earth's curvature comes into play about 20 miles past the Farallon Islands

One of the things I learned while doing this is that it's actually pretty easy to write a viewshed analysis program.  Writing one that runs quickly over numerous zoom levels and a wide array of distances is a different story.  It's simply not feasible to check the elevations between Mt Diablo and Modesto at 10 meter intervals for every pixel on the screen; you need to do some kind of performance optimization, and that means it's possible for inaccuracies to creep in.

I spent a lot of time trying to find the right balance between performance and accuracy, and I think the end result is perfectly adequate for non-professional uses (obviously cell companies aren't going to be using CalTopo to research tower placement).  As QA tasks go, this was actually a pretty fun one.  As an example, photos of half dome from the central valley and bay area always elicit lots of discussion and occasional allegations of photoshopping.  So I decided to check the viewshed layer against known photo locations:

line-of-sight locations between the central valley and summit of Half Dome

This isn't perfect as it's line of sight only and doesn't account for atmospheric refraction, but the iconic photo location outside Turlock is well within the red zone.  What about the Lick Observatory on Mt Hamilton, site of another classic shot?

yes, you can see Half Dome from Mt Hamilton on a super clear day

The viewshed layer has the most precision at the origin point and the pixel being checked, and the least halfway in between.  While this normally works great, the place where it's most misleading is when a peak or narrow ridge is halfway between you and the location being checked.

Finally, without giving too much away about future projects, here's a texture-mapped visualization and viewshed from the same location.  Both use largely the same algorithm for determining visibility, so if the visualization looks good it helps confirm that the viewshed is working properly.  Castle peak is poking up to the left of the foreground and the frog lake cliffs are visible to the right:

And here's an actual photo from the same location, although from a slightly lower elevation (and through a very telephoto lens).  Because of trees, it's hard to tell whether the low ridge to the left of Castle is actually visible.  However, the photo seems to match well.

I'm pretty satisfied with the result of my viewshed QA efforts, but if you see anything that looks seriously off, please drop me a line.