Saturday, February 15, 2014

Where's the Sun?

It's a simple question, but one I haven't found a satisfying answer to: where's the sun?  How do you look at a map and figure out which areas are mostly sheltered from its rays and which ones receive strong midwinter sun?  When will your campsite first see direct light in the morning, and will it have a good view of the sunset or be smothered in shade hours beforehand?

When I built the viewshed layer, I realized that I could use the elevation data and techniques from it to create all kinds of cool terrain-driven visualizations.  One of the more obvious ones was a sunlight analysis layer that could answer the above questions without the need for napkin math and a protractor.  After a lot of work finding the right balance between accuracy and performance, it's finally live.

You can add a sunlight analysis layer just like viewsheds and slope shading:

Specify a date, and either pick a specific time or get an average across the entire day:

Click OK and it shows up as a layer checkbox, just like the other custom layers:

Testing these layers is always more fun than building them.  A good opportunity was heading out to the Sierra Club's Bradley Hut to check on snow conditions for an upcoming overnight trip, coupled with California's serious drought conditions.  Solar warming isn't a reliable predictor of snow depth, and my shading doesn't even factor in vegetation like trees.  Still, it seemed like a good test case.  The route follows the dashed black road in from the red highway, cuts North to a creek crossing, and then continues up the far side of the image below.

The layer uses a blue-yellow-red spectrum, where blue is completely shaded, red represents the maximum amount of sunlight a slope can have on that day, and yellow is 50%.  The coloration is based on how directly the sun shines on a slope, so glancing light counts less than direct, full-on illumination.  It doesn't account for all factors, but the goal was to provide a rough picture of the sun's effects, not exact measurements.

The blue areas in the picture below held snow well.  The red-tinted slopes beyond the bridge were melted out ("no snow") while the yellow spots on the approach were simply thin.  Rough correlation achieved.  Success?  Maybe.

Taking one of the last lifts up KT at Squaw on Friday, the sun was low enough to cast shadows across GS Bowl.  I noted the time, came home and punched it into CalTopo.  The first image shows the terrain with simple sun/shade coloring, the second has the "adjust for intensity" box checked.  The sunlight layer only provides 15 day and 15 minute increments, so I'm not expecting an exact match, but the top of Olympic Lady and upper part of Red Dog Ridge are in the sun, with the lower reaches shaded.  Close enough.

Yellow = direct sun, Blue = shaded

Blue->Yellow->Red spectrum "adjusted for intensity"
But wait, there's more . . .

Since I'd already done the hard work of computing the sun's position and tracing along its path, it didn't take long to throw together detailed year-round information for a specific point.  Right click on a map, choose Point Info and then Sun Exposure.

The dialog below shows day/night and sun/shade information for the current year.  The x axis is time of year, with Jan 1 on the left and Dec 31 on the right.  Y axis is time of day, ranging from earliest sunrise to latest sunset.  Gray = night, Blue = shaded and Yellow = direct sunlight.  Mouse over a point on the graph and you'll get the corresponding date/time as well as the sun's azimuth and altitude at that point.

Sun exposure for the Upper Pines campground in Yosemite

Back when the internet was far less mature and AltaVista ruled the search scene, one of the photographs I always wanted to take was of the sun setting across the Golden Gate Bridge.  At the time I could never figure out how to make that happen, except for watching the sun for months on end and waiting for it to align.

Although no longer on my to-do list, the project seemed like a good way to demo integrating sunlight information with other features on CalTopo.  Step 1 is to shoot a bearing from Treasure Island across the Golden Gate:

You can go back and forth with what part of Treasure Island you want to shoot from and where you want the sun to cross the bridge, but I got a bearing of 260 degrees:

Assuming you want the sun to be just over the horizon, the sun exposure table gives me an altitude of 3 degrees at an azimuth of 261 degrees on March 7:

The bridge is 746' high and Treasure Island is 29000' away, so the tower tops will be atan(746/29000) = 1.5 degrees above the horizon, so even this is maybe a couple days too late.  However most people would take the photograph from farther South on the island, in which case you'd want to go a little later.

From photographers to backcountry skiers to car campers, everyone can benefit from a good pre-plan.

Wednesday, February 5, 2014

CalTopo - Now With SNOTEL

The lack of recent posts doesn't mean a lack of development, only that the focus has been on bugfixes and minor improvements - from better compatibility with USB Mass Storage capable Garmins to decimal minute support in the PDF generator.  Still, for the last couple months two new layers were lurking in the background, getting brief bits of attention during downtime as I tried to wrap them up before the height of ski season.  The first of these is the SNOTEL data layer.

For those not in the know, here's the one-line description stolen from Wikipedia:
SNOTEL is an automated system of snowpack and related climate sensors operated by the Natural Resources Conservation Service (NRCS) of the United States Department of Agriculture in the Western United States.
SNOTEL has about 850 sensors, mostly in remote locations, that issue hourly reports on the snow depth, snow water equivalent and air temperature.  Some of those also record wind speed/direction, solar radiation and other measurements.  While the system was designed to track the nation's water supply, it also provides a wealth of information for winter time backcountry travel.

SNOTEL locations across the Pacific Northwest.  Blue sites have wind data.
In my experience, accessing real-time SNOTEL data is inconvenient enough that I often don't bother.  The web site requires you to visit each station separately and pull up a chart; there isn't a good way to survey nearby stations at a glance.  They publish a KML file with recent station data, but it emphasizes percent of normal snowpack rather than current snow depth.

This isn't a criticism of the folks running SNOTEL, as backcountry recreation is very much a secondary use of the system.  Plus, they've been kind enough to make all the data publicly accessible through a webservice, so that people like myself can pull it into their sites and chart, graph and display it every which way we want.

So enough with the background, I'm happy to announce SNOTEL as the first dynamic, data-driven map layer in CalTopo.  It should show up as a checkbox just like the other overlay map layers, but here's a link as well.  In order to avoid overwhelming the SNOTEL servers, at low zoom levels you'll just see a map of all stations.  Standard stations are in red, stations with wind sensors in blue.

SNOTEL stations around North Lake Tahoe
Zoom in a couple levels and each station gets a label with the snow depth in inches, the current snow density (10:1, 5:1 etc) and current temperature.  Hover over a station for a few more details.

Click on a station to bring up a dialog with the 7-day sensor history and a link to the station's official webpage, where you can check out all kinds of additional charts and tables.

Each station reports snow depth, water equivalent and temperature separately, and those updates can take a while to reach the main system.  CalTopo displays the oldest date between those 3 sensors; if the photo above were taken at 9:05, snow depth could easily be as of 9PM while air temp is as of 8PM.

Another important thing to know is that the SNOTEL data can be pretty noisy, especially the snow depth reading.  If anything looks funny, it's best to click on the station and get a detailed graph.  Notice how snow depth (black) for the station below appears to drop during daytime highs (red):