From OpenStreetMap Wiki
Jump to: navigation, search
Mount Etna (contours only)
OSM data together with contours
Zoomed in


Srtm2Osm tool uses Shuttle Radar Topography Mission (SRTM) digital elevation model (DEM) to generate elevation contours (isohypses) of a selected terrain. The tool writes contours as OSM ways into an OSM file. This then enables rendering of the terrain using Osmarender XSLT transformations or other OSM renderers.

NOTE: It is not intended to upload such contours into OSM database, but to improve OSM output. So do not try to upload the generated data to OSM server!

The tool was originally developed by Igor Brejc (User:Breki), but is no longer supported by him. The current version 1.11 is working and was built by Michael Bemmerl (User:Michi2). The tool is only available in Windows. See Running On Linux for notes relating to running Srtm2Osm on Linux. For alternatives you may want to look at GroundTruth, gdal_contour, mkgmap, or GRASS GIS's, r.contour, and v.out.gpsbabel modules. None of these are a direct replacement for Srtm2Osm though. For an alternative look at Phyghtmap.


A great example of using Srtm2Osm generated contours in slippy map is in the Freemap Slovakia.

You can see some other examples of terrain generated by Srtm2Osm and rendered using Osmarender on this page. The area shown is around Maribor - Slippy map link


The latest version of the tool can be downloaded from here (signature). You need to have either:

  • Windows: Microsoft .NET 2.0 (available here)
  • Linux: Mono

installed on your computer in order to run Srtm2Osm.


Version 1.11

  • added support for new slippymap URL syntax.
  • added support for splitting isohypse ways after a certain amount of nodes.

Version 1.10

  • using 64 bit integers for element IDs.
  • node / way element IDs start at 2^63-1 and are counted down: No need for updating the starting ID in future (like in version 1.8 ext).
  • added console logging of download phase.
  • output is now compatible to XML output of API 0.6.
  • added "upload=false" attribute to "osm" tag.
  • added support for slippymap URLs with bbox parameter.

Version 1.9

  • improved error handling on incomplete SRTM cell files.
  • check if the download of a SRTM cell was complete.
  • fixed exception on malformed URIs when using the -source option.
  • improved error handling on network errors.
  • fixed possible Exception on network errors.
  • fixed missing "timestamp" XML attribute on exports which were made with the -large option.
  • fixed missing "lon" / "lat" XML attribute when nodes were at 0° longitude or latitude.
  • do not crash when no bounds were specified by the user.

Version 1.8 ext

  • node ID range starts at 2 billion now, this fixes overlapping with real OSM node ID's (User:Michi2)

Version 1.8

  • set download base url with parameter -source (User:Bomm)
  • correct offset of contour lines (60m to SW) with parameter -corrxy. A setting of -corrxy 0.0005 0.0005 appears to give good results. (User:Bomm)
  • improved error handling (User:Bomm)

Older entries are available in the release notes file.


Srtm2Osm works from a command line. You specify an area to cover and some additional options. You can specify the coverage area in two ways:

  • By using -bounds1 option, you specify minimum and maximum latitude/longitude of the area, for example:
-bounds1 46.51 15.57 46.5385 15.6356
  • By using -bounds2 option, you specify the latitude and longitude of the center of the area and the area size (in kilometers), example:
-bounds2 46.51 15.57 10
  • By using -bounds3 option, you specify the slippymap URL of the area (the URL must be enclosed in quotes). The tool will take into account the zoom level in determining the area size. Example:
-bounds3 ""

Attention: 46.51 is interpreted as 46.51 degrees, not 46 degrees 51 minutes.

Covering Large Areas

If you want to cover a large area, use -large option, which turns on 'large area mode'. In this mode each contour is written to OSM file immediately upon discovery. This prevents 'out-of-memory' errors, but some other options (like -merge) cannot be used in this mode.

Experiment when selecting the area size, first try with the small area (up to 50 km). If the area is large and hilly, the generated OSM file could become very big and basically useless for further processing by renderers. As an experiment, I ran the tool on the area which covered the whole of Sicily and it produced an OSM XML file with 450 MB in size.

Downloading SRTM Data

The tool does this automatically. It connects to the NASA FTP server and downloads the zipped tiles which it needs to process your request. It then unzips the files and stores them in a cache directory, so that it doesn't have to download the same tiles the next time it needs them. The first time you use the tool it will create an index file of all SRTM tiles present on the FTP server. This is needed because the tiles on the server are organized into subfolders corresponding to continents and Srtm2Osm has no way of knowing which tile belongs to which continent.

Elevation In Feet

If you want to have contours generated in feet instead of meters, specify -feet option. You should also set an appropriate elevation step.

Elevation Step

You can specify the step size (in meters or feet, depending on the usage of -feet option) between adjacent contour lines by using -step option.

OSM Output

Srtm2Osm stores elevation contours as OSM ways tagged with contour = elevation tag. Also, the ele tag contains the elevation of the contour (in elevation units). The nodes and ways have ID numbers starting from 2,000,000,000 in order to avoid the conflict with the actual data from the OSM server.

Categorizing Contours For Mkgmap

By using -cat option, the tool will set an additional contour_ext tag for all contours. The value of the tag will represent the category of the contour (either elevation_major, elevation_medium or elevation_minor). This is useful if you want to use contour data with the Mkgmap tool. Example:

-cat 400 100

will mark all elevations which are multiples of 400 as major, all other multiples of 100 as medium and all other as minor. The units of elevation are determined by the usage (or non-usage) of -feet option. You can also use the -cat option in combination with the -step option. Example:

-feet -step 150 -cat 1350 450

will produce contours in feet, with elevation step of 150 feet. Elevations of 1350, 2700 feet etc will be tagged as contour_ext = elevation_major. Elevations of 450, 900, 1800 feet etc will be tagged as contour_ext = elevation_medium. All other contours will be tagged as contour_ext = elevation_minor.

Note: the order might be the opposite of what you expect! - major before medium ---- [[User:Tms13]] 22:23, 17 January 2009 (UTC)

The article Topographic maps for garmin devices describes how to use srtm2osm to generate topographic maps for Garmin devices.

Merging Data

If you want to merge your existing OSM file that you have downloaded from the server using JOSM with the contour data, you can use -merge option to specify that file.

Output file

The -o option allows you to specify the output path:

-o <path>: specifies an output OSM file (default: 'srtm.osm')

Rendering Contours

Rendering Using Maperitive

Maperitive includes rendering rules for elevation contours generated by Srtm2Osm. No additional rules are necessary.

Rendering Using Osmarender

The following rules can be used to render elevation contours using Osmarender (version 6):

<!-- elevation countours -->
<rule e="way" k="contour" v="elevation">
   <rule k="ele" v="100|200|300|400|500|600|700|800|900|1000|1100|1200|1300|1400|1500|1600|1700|1800|1900|2000|2100|2200|2300|2400|2500|2600|2700|2800|2900|3000|3100|3200|3300|3400|3500|3600|3700|3800|3900|4000|4100|4200|4300|4400|4500|4600|4700|4800|4900|5000">
      <line style="stroke-width: 0.2px; stroke: #502D16;" fill="none"/>
      <text k="ele" startOffset='25%' dy="-1.5px" font-family='Verdana' font-size='3.5px' font-style='bold' fill='#502D16'/>
      <text k="ele" startOffset='75%' dy="-1.5px" font-family='Verdana' font-size='3.5px' font-style='bold' fill='#502D16'/>
      <line style="stroke-width: 0.1px; stroke: #502D16;" fill="none"/>

Notes On Rendering

  • This rule will draw contours as polylines, with contours of 100's drawn thicker.
  • The rule will also show elevation of those thicker lines.
  • If you want this to apply to elevations higher than 5000 meters, you have to extend the selection list in the rule.
  • I added this rule after "man-made areas" and before "Airfields and airports" since I think this is the most logical way to place contours on maps (the contours should be visible over land features, but not over roads, for example).
  • I tried this on new (alpha) 0.5 rules, see examples
  • I'm not an expert on Osmarender, so if anybody knows a better way to define render rules, please contribute :). Using SVG Bezier lines would make it look much nicer.


The tool is currently in beta mode. I tested it on certain areas and it worked OK. If you see any errors, please report them in the discussion page.

  • Currently the tool only supports SRTM3 data.

Things Still To Do

Development of this application has been abandoned by the original author, don't expect any further features.

  • Automatic splitting of generated contours into several OSM files (as tiles). This would make working with the resulting OSM contours much easier. (You can use splitter for this, with the --mixed option.)
  • Support SRTM1 data
  • Using smaller elevation steps to show relief in plains. This should be activated automatically for plains, based on some algorithm.
  • Support for SRTM Water Body Dataset (SWBD)?
  • Rendering through Osmarender using Bezier curves
See --Stefanb 17:01, 15 October 2007 (BST)

Running On Linux

I've had success running Srtm2Osm on Ubuntu Gutsy (7.10). I simply downloaded & extracted, then made Srtm2Osm.exe executable. I have various mono libraries installed, and I suspect having these is what allows it to work. If you know more about getting this to run on Linux, please add it here. Avantman42

To run Srtm20sm on Debian GNU/Linux, apt-get install mono-runtime libmono-corlib2.0-cil libmono-system-runtime2.0-cil libmono-system2.0-cil, then run the program with "mono Srtm20sm.exe". --Bgm 02:37, 15 January 2008 (UTC)

Also needed to install the packages mono-gmcs and libmono-i18n2.0-cil to fix a 'Cannot open assembly' and 'CodePage not supported' error in a Linux/Debian environment. --Lambertus 20:07, 12 March 2008 (UTC)

On Ubuntu Hardy Heron (8.10) srtm2osm worked after I had installed the two packages mentioned by Lambertus (and only those). --Winlemski 17:18, 12 October 2008 (UTC)

I confirm that it runs on Kubuntu 8.04 as well. Followed above instructions and installed all mentioned packages. --GoemonGPS 26 March 2009

Ubuntu 8.04, 9.10, Debian

aptitude install mono-runtime libmono-corlib2.0-cil libmono-system-runtime2.0-cil libmono-system2.0-cil mono-gmcs libmono-i18n2.0-cil
Confirmed working on Debian Sid —Granjow 16:10, 15 December 2009 (UTC)
Confirmed working on Ubuntu 9.10 —Yvecai 06 February 2010

Lenny 64bit, Debian

aptitude install mono-runtime libmono-corlib2.0-cil libmono-system-runtime2.0-cil libmono-system2.0-cil libmono-i18n2.0-cil
Confirmed working Lenny 64bit (kernel 2.6.26-2-amd64) —DirkS 28 February 2010

Fedora 12

 # yum install mono-tools

And then you should be able to run srtm20sm as

 # mono Srtm20sm.exe ...


 # zypper install mono-core mono-web mono-winforms mono-data mono-data-sqlite

And then you able to run srtm20sm as

 # mono Srtm20sm.exe ...

(Verified on openSUSE 11.4.)


I added Srtm2Osm project code to the OSM SVN server. See Srtm2Osm Development for more.


Alternatives exist that do not require a .NET/Mono environment and may offer other advantages in some circumstances: