Tuesday, February 12, 2013

Custom DEM Shading

While rendering the new slope shading layers, I also rendered data tiles for elevation, slope and aspect.  CalTopo can now use these to create custom shading for the continental US.  Want to color all north facing aspects above 7000' and steeper than 32 degrees blue?  Create an elevation relief map?  No problem.  Unfortunately I haven't had time to create a slick UI, so the purpose of this blog post is to serve as documentation.

Click the checkbox for the "Custom Shading" overlay layer and a text area will appear.  Use this to enter condition-color combinations, one per line.  The conditions can be any range of slope, aspect or elevation; the color is an RGB hex code.  This is best explained with some examples:

s15-30 FF0000
s30-45a90-270 0000FF

Slopes between 15 and 30 degrees shaded red, as per the first line

The first line will cause all slopes between 15 and 30 degrees to be colored red (#FF0000).  The second shades all slopes between 30 and 45 degrees, with aspects between 90 and 270, blue (#0000FF).  If you're not familiar with this notation, search for "hex color codes" or play with the W3Schools color picker.  You can also use elevation in meters, or append the number with an f for feet

e1000-2000 matches all elevations between 1000 and 2000 meters.
e5000-7000f matches all elevations between 5000 and 7000 feet.

Each line can match one range each of elevation, slope and aspect, represented by the letter e, a or s and followed by start and end numbers separated by a hyphen.  So e7000f-30000fs32-90a225-45 would match all north facing slopes greater than 7000' and 32 degrees or steeper.

North facing slopes above 7k and 32 degrees or steeper

If you have only one condition, you can specify a pair of colors to create a gradient.  The following creates two gradients: elevations between 5k and 7k are shaded white->blue, and elevations between 7k and 9k are shaded blue->red.

e5000f-7000 FFFFFF-0000FF
e7000f-9000 0000FF-FF0000

Mountains around Squaw Valley, CA shaded using the above gradients
You can also use the service to create nationwide visualizations.  And custom layers will also print using CalTopo's PDF generator as well!

A high level view of terrain 25 degrees and steeper in the Pacific Northwest.


  1. I can't find the Custom Shading checkbox. Can you post a screen shot?

    I have used this feature previously, but it looks like my saved maps have all gone back to the default colors.

    Nice web site, by the way. I have been recommending it to my backcountry ski friends in Colorado.


  2. Hi Tom -

    I had to modify the UI a bit in order to support some changes. At the bottom of the left bar, click on "+ Add New Layer" and then "Add DEM Shading" and you'll get a dialog that lets you input the colors. After that a checkbox will show up in the layers dropdown. One benefit to this is that you can create multiple custom shadings and either toggle between them quickly or turn more than one on at once.

    If you had custom shading saved on existing maps, it should still be there, although you may not be able to edit the parameters you set up. If that's not the case, please send me a link to your map (at info@caltopo.com) and I'll take a look.

  3. This comment has been removed by the author.

  4. This comment has been removed by the author.

  5. Matt Jacobs,
    Can you please provide information and insights about what we should know about the accuracy and precision of DEM shading on CalTopo, and the interpolation(s) involved with DEM shading on CalTopo?

    This question is in part inspired by this insight “Data Limitations: Elevation data is provided by the USGS at approximately 30' intervals, but the original data may have been sampled more coarsely and then interpolated. Slope and aspect calculations can only be as good as the source data, and may be off.”, at https://caltopo.blogspot.com/2012/02/avalanche-slope-analysis.html )

    I am wondering if the data used for the CalTopo "DEM shading" might be newer data, based on newer technologies (ex. LIDAR, etc.), with more precision and/or accuracy than the USGS data referred to above.

    Thank you!

    1. It's all the same data (US 1/3 arc-second National Elevation Dataset). I can't provide any meaningful insight on accuracy - some areas are clearly LIDAR based as they capture all sorts of micro terrain (e.g. the glaciers on Rainier) and others seem to be based on the same surveys as contour lines.