Wiki.GIS.com:Graphic Lab/Resources/Optimizing relief

Summary
The object of this tutorial is to optimize relief shadows resulting from a digital elevation model (DEM) created using the programs 3DEM or GRASS GIS.

In many cases, a single illumination source is inadequate for showing the main forms of a relief, particularly if it is oriented North-West - South-East in the axis of the main light source. In order to improve the result, it is possible to displace the virtual Sun across the map and create three views which will be assembled together to produce a composite shadow image of the map in question.

This page proposes a second optimization which could be applied to general maps covering a country. Where, on a large scale map such as those resulting from the files of the Shuttle Radar Topography Mission (SRTM) at their native resolution, each detail of the relief is useful and clearly visible, this may be of less use in a more general map where it is the principal forms which are of more interest.

The tools
or:
 * 3DEM (version used: 20.0): free and easy to use GIS editor;
 * GRASS GIS (version used: winGRASS 6.3.0RC6): free multi platform GIS program; powerful but more delicate to use;


 * GIMP (version used: 2.2.13): bitmap editor which allows optimization of relief shadows

Potential data sources
These are bitmap files released into the public domain, compressed into zip file format, which contain the digital topographic data of a given region. The zone covered by the DEMs resulting from the SRTM runs from latitude 56° South to latitude 60° North. These files must be decompressed before being used in 3DEM.
 * NASA Shuttle Radar Topography Mission (SRTM) Digital Elevation Model (DEM):

There are three SRTM file types:
 * SRTM1 (download here): the most precise data with a resolution of one arcsecond (31 m at the equator), but which are only available for the United States and its dependencies. Each file represents a rectangle of a degree of an arc to a side referenced according to the coordinates of the bottom left corner..


 * SRTM3 (download here): a precision of three arcseconds (93 m at the equator) which covers all emerged land between the latitudes indicated above. Filetypes and references identical to SRTM1.  These are the datasets which will be of most use for the needs of wiki.gis.com.


 * SRTM30 (download here): a precision of 30 arcseconds (926 m at the equator), adapted for maps covering more than one country or a continent.
 * Each map covers a region of 50° of latitude by 40° of longitude, referenced according to the coordinates of the upper left corner. Each map is contained in a specific folder which contains 12 separate files.  Only 10 of these will be of use to us; the remaining files *.jpg.zip and *.gif.zip are just preview files.  These 10 files must each be downloaded and decompressed before being used in 3DEM.  In the program, select the GTOPO30 Tile option, then in the new window representing the map of the world, centre the frame on the region of interest and specify Lat/Lon as the projection type.  Navigate through the tree and select the .DEM file.

With GRASS GIS

 * 1. Open GRASS and enter into the project that follows a UTM projection. Launch the module r.shaded.relief (Raster -> Terrain analysis -> Shaded relief).


 * 2. In the module window, click on the button of the Input elevation map: field and select the DEM map which has previously been imported into GRASS. By default, GRASS uses an illumination coming from the West (270° - from the left), but in cartography the norm has illumination coming from the North-West (upper left corner).  This illumination, impossible in reality for the northern hemisphere, has become a convention and in particular avoids the optical illusion of a relief inversion in which one has the impression of seeing valleys as mountains and vice versa. In the field Output shaded relief map name:, enter a name for the first shaded relief map which will be created; for example, Shadows_315.  In the field Altitude of the sun..., specify a value of around 60°.  For the azimuth, enter 315</tt> and leave the factor for exaggerating relief field at 1</tt>, unless the terrain is particularly flat which will result in low visibility shadows.  Click on the Run button to start the operation which is detailed in the Output - GIS.m window.


 * 3. When the operation has been completed (indicated by the phrase "Shaded relief map created and named <Shadows_315>."), you can preview these shadows to check whether the aspect is correct (the height of the Sun and thus the luminosity of the map, the factor of exaggeration of relief, etc). In the GRASS manager window, create a bitmap layer then click on the Base map button and select the file Shadows_315</tt>. In the Map Display 1 window, click on the Display active layers button to display the map.


 * 4. In the r.shaded.relief</tt> module window, change the azimuth to 275°</tt>. Change the output filename to Shadows_275</tt>, then click on the Run button.  Repeat the operation for an illumination from 355°</tt>.  Close the module.


 * 5. Export the first shaded relief map in PNG</tt> format: File -> Export raster map -> PNG. In the r.out.png</tt> module window, select the file Shadows_315</tt>.  In the field Name for new PNG file:, replace  </tt> with Shadows_315</tt>, then click on the Run button.  The file is saved by default in the C:\GRASS</tt> directory.


 * 6. Modify the output filenames for the other two shaded relief maps. Exit GRASS.

With 3DEM

 * 1. Open 3DEM. Click on File -> Load Terrain Model (1). Select the SRTM Data option (2) then in the new window files of type .hgt</tt>.


 * 2. As the DEM has empty pixels, they must be patched: press F7</tt> and select the whole map with the mouse (1). Confirm the selection by pressing Enter</tt>. 3DEM fills in these pixels by interpolating values from adjacent pixels. (2)


 * 3. Change the projection: Operation -> Change Projection -> Convert to UTM Projection (1). Select the WGS84 option (2) which is the norm used by the SRTM files. Click OK.  The map is redrawn and the meridians, which were previously parallel, now converge towards the poles.
 *  Note:  The following screen captures show the map with the colours recommended by the suggested wiki.gis.com map colouring convention, but changing the colours is not a required step in this tutorial.


 * 4. If, after confirming, a message appears indicating that the map is too large and that a smaller area must be chosen, this means that your map covers more than one UTM zone; an operation that 3DEM is currently not capable of displaying. In such cases it is necessary to crop the map: press <tt>F8</tt> and select a smaller area with the mouse over the whole height of the map, then confirm by pressing <tt>ENTER</tt>.  Continue with the modification of the projection as indicated in point 3.  This action must be repeated for the other part of the map, which requires reloading the relevant DEMs into 3DEM and repeating the operation from point 1.


 * 5. Resize the map: press <tt>F6</tt> and move the cursor to the required values for height and width.


 * 6. Export the map: check that the coordinate grid is visible (Geo Coordinates -> Lat-Lon Grid On) (1), then select File -> Save Map Image (2) and choose <tt>jpeg</tt> format (3), and choose a name for the image. Save. This map, compressed into <tt>.jpg</tt> format, is only intended to serve as a reference for the transformations required for the final map (rotation, layer alignment etc). Turn off the grid (Geo Coordinates -> Lat-Lon Grid Off).


 * 7. Press <tt>F3</tt> and modify the colorimetric terrain scale by specifying the colour white for each altitude range, in order to remove topographic information.


 * 8. As the DEMs of the SRTM are imprecise in coastal zones, we will force 3DEM to consider that there is no ocean to avoid the "stepped" appearance of the coastline in these areas in comparison with the trace produced by the SRTM Water Body Data (SWBD). In the Terrain Type section of the Terrain colors window, <tt>F3</tt>, select the option Mountain/Plain: 3DEM applies a grey colour, corresponding to a flat unshadowed plain, to all aquatic surfaces.  This method is empiric but adapted to the needs of wiki.gis.com because it renders these defaults practically invisible.


 * 9. Modify the illumination of the map: by default, 3DEM uses an illumination coming from South West (240° - the bottom left corner), which is natural but in cartography the norm is to have illumination coming from the North West (upper left corner). This illumination, impossible in reality for the northern hemisphere, has become a convention and in particular avoids the optical illusion of a relief inversion in which one has the impression of seeing valleys as mountains and vice versa.  Click on Color Scale -> Shaded Relief and change the Deg Azimuth field to <tt>315</tt>.


 * 10. Select File -> Save Map Image, and choose <tt>bmp</tt> format for an optimal quality, then save this image, for example with the name <tt>Shadows_315</tt>.


 * 11. Select Color Scale -> Shaded Relief and this time change the Deg Azimuth field value to <tt>275</tt>.  Confirm, then save the image in <tt>BMP</tt> format with the name <tt>Shadows_275</tt>.


 * 12. Change the illumination source again, this time to <tt>355</tt>. Save this third image with the name <tt>Shadows_355</tt>. Close 3DEM.

Optimization of relief forms
Translator's note: All illustrations from this point onwards are screenshots from the original author's French language version of GIMP


 * 1. Open the <tt>Shadows_315.png</tt> (or <tt>.bmp</tt>) image in GIMP. Create a duplicate layer and select <Multiply> mode to reinforce the density of the shadows resulting from this main illumination.


 * 2. Open as a layer (<tt>CTRL + ALT + O</tt>) the image <tt>Shadows_275</tt>, change its fusion mode to <Multiply> in the drop down Mode menu in the Layers, Channels, Paths window, and add a black mask (Layers > Mask > Add a layer mask).


 * 3. Zoom to 200% (View > Zoom > 200%). Select the fuzzy circle Paintbrush tool, with a scale of around 7 pixels and, on the mask layer, paint in white along the lines of the shadows of the main relief forms which are oriented North-South, in order to heighten the contrast of these lines.




 * 4. Repeat points 2 and 3 for the image <tt>Shadows_355</tt> in order to increase the contrast of the East-West lines. Take care not to reinforce the shadows on two flanks of the same mountain.


 * 5. Save the image in <tt>.xcf</tt> format to preserve the layers in case it is necessary to modify them later. Export the image as a <tt>.png</tt> format file in order to be able to use it as a layer above your map.  You may need to increase the contrast by using the Curves tool (<tt>CTRL + M</tt>) - do not use the Luminosity-Contrast tool as this does not allow for a precise control of the operation.
 *  Note: A simpler and more rapid solution is to add the layers with a Multiply fusion without adding a black mask, but this method is not very effective at optimizing the relief forms.

Reduction of the level of detail of a shaded relief
 Note: This optimization applies to small scale maps covering a large terrestrial and mountainous zone for which the excess of details obscures the reading of the general relief forms.


 * 1. In GIMP, open the <tt>png</tt> shaded relief image previously created. Note its dimensions in pixels.  Go to Image ->Scale and size of the image...  Specify a new size in <percent> and indicate a value of 20%.


 * 2. Resize the image again, this time with a value of <500%>, and check that the dimension indicated in pixels does correspond to the size of the original image. These operations have the effect of diminishing the details and to make the smallest valleys less visible.  Save the image under a different name to the image source.  Close the document.


 * 3. Open the original image of the shaded relief. Open as a layer (CTRL + ALT + O) the modified map which has just been created in point 2 and give it a transparence of around 50%, the aim being to obtain an image of the shadows which does not appear blurred but in which the smallest details will be hardly visible on the final map in order to optimize the general llines of the relief.  Increase the contrast if necessary by using the Curves tool (CTRL + M).