Generating DEM color scales in ENVI format (.dsr)

This Python code generates a color scale in ENVI format (.dsr) adapted to the elevation range of a given digital elevation model. ENVI already provides tools to color a DEM, but the color scales are not gradual from one color to another. This code is a way to generate such a color scale.

In ENVI, .dsr files can be imported in the "Density Slice" tool.

Download (v1.2.3 - Sep 2014)

Example: how to produce a 3D view of a shaded, colored DEM with ENVI and Photoshop

  1. In ENVI:
    Apply the color scale generated by the python program to the DEM (Tools → Color Mapping → Density Slice → File → Restore Ranges)
    DEM
    colored DEM
  2. Save the image in TIFF/GeoTIFF format, with the default options (File → Save Image As → Image File)
  3. In parallel, display the DEM in a new Display and create a hill shade image (Topographic → Create Hill Shade Image ; choose the Display and select the DEM; set the Sun angle values)
  4. Save the shaded DEM in TIFF/GeoTIFF format (see 2.)
    DEM
    shaded DEM
  5. In Photoshop:
    Open both .tif files
  6. Set the luminosity, levels, etc.
  7. Copy the colored DEM and paste it on the shaded DEM
  8. Set the opacity of the colored DEM to make the shaded DEM appear
    colored DEM
    +
    shaded DEM
    shaded, colored DEM
  9. Save the image
  10. In ENVI:
    Open the .tif file that you just modified in Photoshop (make sure that the .tfw file has the same name as the .tif file; choose the same projection as the original one)
  11. Set the contrast stretch (to retrieve the Photoshop settings: Enhance → [Scroll] Linear 0-255)
  12. Visualize the shaded, colored DEM in 3D (Topographic → 3D SurfaceView)
    3D visualization