Srtm2Osm

From OpenStreetMap

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

Contents

Introduction

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 is developed by Igor Brejc (User:Breki) and is currently only available in Windows. See Running On Linux for notes relating to running Srtm2Osm on Linux.

Examples

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

Download

The latest version of the tool can be downloaded from here. You need to have Microsoft .NET 2.0 (available here) installed on your computer in order to run Srtm2Osm.

Version 1.4

  • -large option added for covering large areas
  • fixed a bug which prevented correct usage of Srtm2Osm south of the equator or west of Greenwich

Usage

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 qoutes). The tool will take into account the zoom level in determining the area size. Example:
-bounds3 "http://www.openstreetmap.org/?lat=47.63168944724306&lon=9.396385580645727&zoom=10&layers=0BF"

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 1,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.

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 Kosmos

Kosmos 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">
      <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'/>
   </rule>
   <else>
      <line style="stroke-width: 0.1px; stroke: #502D16;" fill="none"/>
   </else>
</rule>	

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 2000 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.

Limitations

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

  • Automatic splitting of generated contours into several OSM files (as tiles). This would make working with the resulting OSM contours much easier.
  • 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 lines2curves.pl --Stefanb 17:01, 15 October 2007 (BST)
  • Support for CGIAR-CSI void-filled SRTM data

Running On Linux

I've had success running Srtm2Osm on Ubuntu Gutsy (7.10). I simply downloaded & extracted Srtm2Osm-1.4.25.1.zip, 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)

Development

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

Links

Personal tools
recent changes