(English) Create your own Elevation Contourline Maps

Ci spiace, ma questo articolo è disponibile soltanto in Inglese Americano e Tedesco. Per ragioni di convenienza del visitatore, il contenuto è mostrato sotto nella lingua principale di questo sito. Puoi cliccare su uno dei links per cambiare la lingua del sito in un'altra lingua disponibile.


Now there are contourlines for most countries to download - if you still need to create contourlines maps yourself. Note this tutorial is outdated - I won't update it. Instead of points 1-6 you can simply install "phyghtmap" and save yourself a lot of work.

If you want to create your own contourline maps, here is a quick overview about the process I used - attention this is an advanced topic and will require you to install quite a lot of software - if you want to get contourlines for a large country (say Norway or France) I advise using x64 systems because on x86 systems you will run out of RAM - I will not provide a German translation here - because if you don't understand it in english, you are unlikely to succeed (all the required programs need basic command of English language).

When I compiled the contourlines osmconvert and srtm2osmsegmenter didn't exist yet - I will eventually update my contourlines using the approach described in 6b - for right now (december 2011) you can get better results yourself if you follow this guide and do everything correct. I did however by hand correct most of the errors - so maybe at some places your results will also be worse...


1. Get the coordinates of the left lower (south-west) edge and right upper edge (north-east). The easiest way to get hold of them is to put waypoints with Mapsource. To get the correct format go to preferences in Mapsource, tab position and use Grid: Lat/Lon hddd.dddddd°, datum as always WGS 84.


2. Transform the coordinates for srtm2osm. N47.41502 E11.02737 has to be changed to 47.41502 11.02737, S47.41502 W11.02737 becomes -47.41502 -11.02737.


3. Get srtm2osm from here: http://wiki.openstreetmap.org/wiki/Srtm2Osm and install it.


4. Srtm2osm downloads the needed *.hgt DEM information automatically from Nasa to subfolder srtm/srtmcache if not specified differently. Nasa data is however not very good in mountaineous regions. On viewfinderpanoramas.org you can get much better DEM data. Head over there and download all availble 3" DEM for the region you need (you know the coordinaties from step 2). Place them into subfolder srtm/srtmcache of you srtm2osm installation (create theese folders if they don't exist). Srtm2osm will not download DEM from NASA SRTM if we have placed other data to srtmcache beforehand.


5. Call up srtm2osm with the following command (if you don't know where to input this command, I recommend you stop reading here because you will not get far):

srtm2osm.exe -bounds1 57.71690 4.01368 71.19163 31.14427 -cat 400 100 -large -corrxy 0.0005 0.0006 -o no.srtm.osm

- bounds1 57.71690 4.01368 is the lower left edge, 71.19163 31.14427 is the upper right edge

-cat 400 100 specifies the interval for medium and major contourlines to 400 (major) 100 (medium).

-large is needed because big areas will otherwise make you run out of memory instantly.

-corrxy 0.0005 0.0006 is the correction factor I used because the SRTM data seems to be mal aligned/transformed to WGS 84.

-o specifies output file.

This above command would give you osm contourlines for Norway. You would need about 6GB of RAM to run it without swapping. The smaller the region, the fewer mountains - the easier the RAM requirements are.


6a) Quick and dirty... (see 6b for better possibility) .Optional -  If you want to cut the contourlines around some given shape, i.e. a country boundary instead of the square you got from above, you need to parse the file with osmosis. Install java sdk and osmosis (attention, this is not easy, best do it on Linux systems because with Windows it's messy) and run the following command:

java -Xmx1500M -jar osmosis.jar --read-xml enableDateParsing=no file="no.srtm.osm" --bounding-polygon file="norway.poly" --write-xml file="nocut.osm"

-Xmx1500M specifies that you give 1500 MB of RAM to osmosis.

file=* specifies your file from step 5.

--bounding-polygon specifies your boundary polygon. Geofabrik lists the boundary polygons they use here: http://download.geofabrik.de/readme.html so I advise you to use the same data.

Note that around the boundaries you are likely to get artefacts because osmosis does not close the contourlines at the boundary - it seems to be a bug that exists since a very long time. The option "completeWays" is not working as expected.

6b) Instead of osmosis use first srt2mosmsegmenter and then osmconvert. This way you omit to get artefacts on tile borders. See also here for instructions: Howto_render_Garmin_countour_layers_with_no_artefacts

7. Split the resulting file (either from step 5 or 6) with mkgmap splitter with the following command (note you need to have Java SDK installed):

--cache=folder (you have to create this subfolder in mkgmap directory) is given to speed up splitting if we notice that the maxnodes are to high.

--max-nodes=* specify the tile size. if 7500000 gives you "not enough space in .img" in step 8 you need to reduce this.

--mapid=%mapid% here functions as a placeholder for a 4 digit number. I advise you to use the %mapid% of the resulting openmtbmap country plus 1000. so for norway this would be 74010000

--mixed has to be given when splitting the output from srtm2osm.


Step 7 is not needed for very small areas - e.g.  the Netherlands.

%country%*.osm specifies the input file (output file from step 5 or 6)


8. Run mkgmap on the resulting output files of step 7. (again Java SDK needs to be installed).

--max-jobs=1 is given to restrict mkgmap to use only one CPU core. Calculate that you need up to 3GB of available RAM per Core if you want to increase here (you could decrease the max-nodes in step 7 if you get "out of memory" error here.

--mapname should be higher by 1000 in comparison to the tiles that you need the contourlines for. If this is lower, the contourlines will be displayed behind the maps in Mapsource - hence only visible on GPS.

--style-file=srtm get my srtm style-file from here and put it into mkgmap folder.


9. Optional - If you want to delete the worst artefacts from step 5, you can do so with gpsmapedit, save the corrected files to .mp (polish map) format and recompile with mkgmap

Leave a Reply