In the previous posts we’ve created three different GeoTIFF images from a single Digital Elevation Model (DEM); hillshade, slopeshade and color relief. It’s time to combine the images into a single terrain map of Jotunheimen.
Mapnik is a great open source toolkit for map rendering, and we’ll use the RasterSymbolizer to blend the GeoTIFFs. The styles and layers (images) can be defined in an XML file (jotunheimen_terrain.xml):
The map projection (UTM 32N) is defined in the first line. Mapnik uses the PROJ.4 library, and you’ll find the srs code by clicking on the Proj4 link on spatialreference.org. Mapnik can’t alter the projection of raster images, so the images have to be in the desired projection before feeding them into Mapnik.
Next, I’ve defined two styles for this map with the RasterSymbolizer. The hillshade is going to be blended with the color relief image, using the multiply blend mode. The color numbers for each pixel of the hillshade are multiplied with the corresponding pixel for the shaded relief image. I’m also setting the opacity of the hillshade to 0.6, making it less dominant. The map layers are defined below the styles. Mapnik will render the layers in order, starting from the top.
You can use a simple Python script (jotunheimen_terrain.py) to render the map image (you can also use tools like TileCache and MapProxy):
#!/usr/bin/env python
import mapnik
map = mapnik.Map(3134, 3134)
mapnik.load_map(map, 'jotunheimen_relief.xml')
map.zoom_all()
mapnik.render_to_file(map, 'jotunheimen_relief.png')
This script will create this PNG image:
python jotunheimen_terrain.py
Let’s add the slopeshade image to our XML file (jotunheimen_terrain2.xml):
I’ve adjusted the opacity of the slope- and hillshade to create this blend:
Which terrain map you prefer is a matter of personal preference. The first map has more glow on the light facing slopes. In the last map, the steep mountains are more defined and the light facing slopes are more detailed.
On both maps, I miss two important features for Jotunheimen - lakes and glaciers. Adding land cover data is the topic of the next blog post.
Mapnik is a great open source toolkit for map rendering, and we’ll use the RasterSymbolizer to blend the GeoTIFFs. The styles and layers (images) can be defined in an XML file (jotunheimen_terrain.xml):
The map projection (UTM 32N) is defined in the first line. Mapnik uses the PROJ.4 library, and you’ll find the srs code by clicking on the Proj4 link on spatialreference.org. Mapnik can’t alter the projection of raster images, so the images have to be in the desired projection before feeding them into Mapnik.
Next, I’ve defined two styles for this map with the RasterSymbolizer. The hillshade is going to be blended with the color relief image, using the multiply blend mode. The color numbers for each pixel of the hillshade are multiplied with the corresponding pixel for the shaded relief image. I’m also setting the opacity of the hillshade to 0.6, making it less dominant. The map layers are defined below the styles. Mapnik will render the layers in order, starting from the top.
You can use a simple Python script (jotunheimen_terrain.py) to render the map image (you can also use tools like TileCache and MapProxy):
#!/usr/bin/env python
import mapnik
map = mapnik.Map(3134, 3134)
mapnik.load_map(map, 'jotunheimen_relief.xml')
map.zoom_all()
mapnik.render_to_file(map, 'jotunheimen_relief.png')
This script will create this PNG image:
python jotunheimen_terrain.py
![]() |
| [ Download image ] |
Let’s add the slopeshade image to our XML file (jotunheimen_terrain2.xml):
I’ve adjusted the opacity of the slope- and hillshade to create this blend:
![]() |
| [ Download image ] |
Which terrain map you prefer is a matter of personal preference. The first map has more glow on the light facing slopes. In the last map, the steep mountains are more defined and the light facing slopes are more detailed.
On both maps, I miss two important features for Jotunheimen - lakes and glaciers. Adding land cover data is the topic of the next blog post.



1 comment:
Thanks for sharing your knowledge. This article has helped me to improve my maps on http://alpenkarte.eu and http://skitourenkarte.eu.
Have added a link to this article on my blog: http://alpenkarte.blogspot.de/
Post a Comment