Graphic Lab/Resources/Optimizing relief
From Electrical Engineering TA Handbook
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.
- GRASS GIS (version used: winGRASS 6.3.0RC6): free multi platform GIS program; powerful but more delicate to use;
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.
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.<ref>Example: the file N48E001.hgt.zip, (decompressed: N48E001.hgt), covers the zone between the 48° and 49° North and 001° and 002° East.</ref>.
- 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 Wikipedia.
- 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.
Creation of shaded relief images
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 and leave the factor for exaggerating relief field at 1, 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. In the Map Display 1 window, click on the Display active layers button to display the map.
- 4. In the r.shaded.relief module window, change the azimuth to 275°. Change the output filename to Shadows_275, then click on the Run button. Repeat the operation for an illumination from 355°. Close the module.
- 5. Export the first shaded relief map in PNG format: File -> Export raster map -> PNG. In the r.out.png module window, select the file Shadows_315. In the field Name for new PNG file:, replace <rasterfilename> with Shadows_315, then click on the Run button. The file is saved by default in the C:\GRASS directory.
- 6. Modify the output filenames for the other two shaded relief maps. Exit GRASS.
- 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.
- 2. As the DEM has empty pixels<ref>A defect of SRTM files is that, in spite of the fact that practically all emerged zones have had at least two overflights, certain zones have remained blind to the oblique rays of the radar due to the exaggerated form of the relief.</ref>, they must be patched: press F7 and select the whole map with the mouse (1). Confirm the selection by pressing Enter. 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 Wikipedia map colouring convention, but changing the colours is not a required step in this tutorial.
|Changing the projection||The map showing a UTM projection|
- 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 F8 and select a smaller area with the mouse over the whole height of the map, then confirm by pressing ENTER. 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 F6 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 jpeg format (3), and choose a name for the image. Save. This map, compressed into .jpg 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 F3 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<ref>A defect of SRTM files is their lack of precision in coastal areas, particularly as a result of wave action which can produce a false radar reading. The SRTM Water Body Data (SWBD) files provided by NASA are intended to resolve this problem.</ref>, 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, F3, 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 Wikipedia because it renders these defaults practically invisible.
|Detail of a relief showing the SRTM zones considered as aquatic surfaces (circled in red). Here, the sea in 3DEM was coloured white; the coastal trace and the blue sea were taken from an SWBD map for comparison; the white zones circled in green are the flanks of mountains with saturated illumination (not a defect).||Select the option Mountain/Plain|
- 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 315.
- 10. Select File -> Save Map Image, and choose bmp format for an optimal quality, then save this image, for example with the name Shadows_315.
- 11. Select Color Scale -> Shaded Relief and this time change the Deg Azimuth field value to 275. Confirm, then save the image in BMP format with the name Shadows_275.
- 12. Change the illumination source again, this time to 355. Save this third image with the name Shadows_355. 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 Shadows_315.png (or .bmp) 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 (CTRL + ALT + O) the image Shadows_275, 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.
|Heighten the contrast of the North-South lines of relief||Appearance of the mask layer for <Shadows_275>|
- 4. Repeat points 2 and 3 for the image Shadows_355 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 .xcf format to preserve the layers in case it is necessary to modify them later. Export the image as a .png 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 (CTRL + M) - 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 png 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.
|Resizing to the original size||Appearance of the map after the operation|
- 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).
|Fusion of the two layers||Comparison of the original map / optimized map|
- Reliefshading.com: A site presenting the rules for graphics in cartography and which deals with the question of relief shadows.
- Shadedrelief.com: Tutorial giving further details of this technique.