OSMDownloader - Open Street Map layers import

Download vector data from OSM and store it to file

Detailed description

The application connects to Open Street Map server, downloads the data corresponding to the spatial extent of the support image, and filters the geometries based on OSM tags to produce a vector data file.

This application can be used to download reference data to perform the training of a machine learning model (see for instance [1]).

By default, the entire layer is downloaded. The application has a special mode to provide the list of available classes in the layers. The downloaded features are filtered by giving an OSM tag ‘key’. In addition, the user can also choose what ‘value’ this key should have. More information about the OSM project at [2].


This section describes in details the parameters available for this application. Table [1] presents a summary of these parameters and the parameters keys to be used in command-line and programming languages. Application key is OSMDownloader .

[1]Table: Parameters table for Open Street Map layers import.
Parameter Key Parameter Name Parameter Type
out Output vector data Output vector data
support Support image Input image
key OSM tag key String
value OSM tag value String
elev Elevation management Group
elev.dem DEM directory Directory
elev.geoid Geoid File Input File name
elev.default Default elevation Float
printclasses Displays available key/value classes Boolean
inxml Load otb application from xml file XML input parameters file
outxml Save otb application to xml file XML output parameters file

Output vector data: Vector data file to store downloaded features.

Support image: Image used to derive the spatial extent to be requested from OSM server (the bounding box of the extent is used). Be aware that a request with a large extent may be rejected by the server.

OSM tag key: OSM tag key to extract (highway, building...). It defines a category to select features.

OSM tag value: OSM tag value to extract (motorway, footway...). It defines the type of feature to select inside a category.

[Elevation management]: This group of parameters allows managing elevation values. Supported formats are SRTM, DTED or any geotiff. DownloadSRTMTiles application could be a useful tool to list/download tiles related to a product.

  • DEM directory: This parameter allows selecting a directory containing Digital Elevation Model files. Note that this directory should contain only DEM files. Unexpected behaviour might occurs if other images are found in this directory.
  • Geoid File: Use a geoid grid to get the height above the ellipsoid in case there is no DEM available, no coverage for some points or pixels with no_data in the DEM tiles. A version of the geoid can be found on the OTB website(https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb-data/blob/master/Input/DEM/egm96.grd).
  • Default elevation: This parameter allows setting the default height above ellipsoid when there is no DEM available, no coverage for some points or pixels with no_data in the DEM tiles, and no geoid file has been set. This is also used by some application as an average elevation value.

Displays available key/value classes: Print the key/value classes available for the selected support image. If enabled, the OSM tag Key (-key) and the output (-out) become optional.

Load otb application from xml file: Load otb application from xml file.

Save otb application to xml file: Save otb application to xml file.


To run this example in command-line, use the following:

otbcli_OSMDownloader -support qb_RoadExtract.tif -key highway -out apTvUtOSMDownloader.shp

To run this example from Python, use the following code snippet:


# Import the otb applications package
import otbApplication

# The following line creates an instance of the OSMDownloader application
OSMDownloader = otbApplication.Registry.CreateApplication("OSMDownloader")

# The following lines set all the application parameters:
OSMDownloader.SetParameterString("support", "qb_RoadExtract.tif")

OSMDownloader.SetParameterString("key", "highway")

OSMDownloader.SetParameterString("out", "apTvUtOSMDownloader.shp")

# The following line execute the application


This application requires an Internet access.


This application has been written by OTB-Team.

See Also

These additional resources can be useful for further information:
[1] TrainImagesClassifier