All Projects → hotosm → osm-export-tool-python

hotosm / osm-export-tool-python

Licence: BSD-3-Clause license
command line tool + Python library for exporting OSM in various file formats.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to osm-export-tool-python

Mapsui
Mapsui is a .NET Map component for WPF, Xamarin.Forms, Xamarin.Android, Xamarin.iOS and UWP
Stars: ✭ 447 (+1296.88%)
Mutual labels:  openstreetmap, gis
Osm Export Tool
Web service to download customised OSM data in various file formats
Stars: ✭ 99 (+209.38%)
Mutual labels:  openstreetmap, gis
Urbansprawl
Open framework for calculating spatial urban sprawl indices and performing disaggregated population estimates using open data
Stars: ✭ 48 (+50%)
Mutual labels:  openstreetmap, gis
Osmnx
OSMnx: Python for street networks. Retrieve, model, analyze, and visualize street networks and other spatial data from OpenStreetMap.
Stars: ✭ 3,357 (+10390.63%)
Mutual labels:  openstreetmap, gis
qgis-outdoor-map
QGIS project for an outdoor map based on OpenStreetMap data.
Stars: ✭ 20 (-37.5%)
Mutual labels:  openstreetmap, gis
Fmm
Fast map matching, an open source framework in C++
Stars: ✭ 359 (+1021.88%)
Mutual labels:  openstreetmap, gis
gazetteer
OSM ElasticSearch geocoder and addresses exporter
Stars: ✭ 93 (+190.63%)
Mutual labels:  openstreetmap, gis
a11yjson
A11yJSON: A standard to describe the accessibility of the physical world.
Stars: ✭ 58 (+81.25%)
Mutual labels:  openstreetmap, gis
GeoArrays.jl
Simple geographical raster interaction built on top of ArchGDAL, GDAL and CoordinateTransformations
Stars: ✭ 42 (+31.25%)
Mutual labels:  gis, gdal
Go Staticmaps
A go (golang) library and command line tool to render static map images using OpenStreetMap tiles.
Stars: ✭ 246 (+668.75%)
Mutual labels:  openstreetmap, gis
Offroad-routing-engine
Off-road Navigation System
Stars: ✭ 16 (-50%)
Mutual labels:  openstreetmap, gis
osm4scala
Scala and Spark library focused on reading OpenStreetMap Pbf files.
Stars: ✭ 62 (+93.75%)
Mutual labels:  openstreetmap, gis
accessibility-cloud
👩🏽‍🦯🦮👩🏻‍🦽👩🏿‍🦼 the platform to exchange physical accessibility data in a standardized, future-proof, easy-to-use way.
Stars: ✭ 37 (+15.63%)
Mutual labels:  openstreetmap, gis
Blendergis
Blender addons to make the bridge between Blender and geographic data
Stars: ✭ 4,642 (+14406.25%)
Mutual labels:  openstreetmap, gis
osmcha
Python package to detect suspicious OSM changesets
Stars: ✭ 33 (+3.13%)
Mutual labels:  openstreetmap, gis
Openrouteservice R
🌐 R package to query openrouteservice.org
Stars: ✭ 57 (+78.13%)
Mutual labels:  openstreetmap, gis
cloud-tileserver
Serve mapbox vectortiles via AWS stack
Stars: ✭ 48 (+50%)
Mutual labels:  openstreetmap, gis
HMap
:earth: HMap | 基于openlayers的封装组件
Stars: ✭ 64 (+100%)
Mutual labels:  openstreetmap, gis
Pytsp
A 2D/3D visualization of the Traveling Salesman Problem main heuristics
Stars: ✭ 122 (+281.25%)
Mutual labels:  openstreetmap, gis
GeoNotes
A simple app to create georeferences notes.
Stars: ✭ 37 (+15.63%)
Mutual labels:  openstreetmap, gis

OSM Export Tool

This project is in a usable state on Linux and Mac. The current Export Tool web service repository is at hotosm/osm-export-tool.

Motivation

This program filters and transforms OpenStreetMap data into thematic, tabular GIS formats. Filtering of features is specified via SQL embedded in a YAML mapping file, for example:

buildings_with_addresses:  # creates a thematic layer called "buildings_with_addresses"
  types:
    - polygons
  select:
    - building
    - height
    - addr:housenumber
  where:
    - building = 'yes' and addr:housenumber IS NOT NULL

It can also create files in non-tabular formats such as those for Garmin GPS devices or the OSMAnd Android app. (coming soon)

Installation

  • install via pip install osm-export-tool. Python 3 and a working GDAL installation are required. GDAL can be installed via Homebrew on Mac or the ubuntugis PPAs on Ubuntu.

PyOsmium is used to read OSM files and GDAL/OGR is used to write GIS files, so this program should be reasonably fast and light on memory. There is a built-in OSM reader available for GDAL/OGR, but this program is much more flexible.

This library will not automatically install GDAL because it needs to match the version on your system. You will need to separately run pip install GDAL==2.3.2 (change 2.3.2 to match gdalinfo --version)

Running with Docker

If you want to avoid installing the right version of GDAL on your system you can run the program as a docker container instead.

To build the docker image, use the following command.

docker build -t osm-export-tool .

To run the tool as a container, using your current directory as working directory, use the following command.

docker run -it --rm -v $(pwd):/work osm-export-tool INPUT_FILE.pbf OUTPUT_NAME

Example usage

osm-export-tool INPUT_FILE.pbf OUTPUT_NAME

will create OUTPUT_NAME.gpkg.

All the below flags are optional.

  • -m, --mapping : specify a mapping YAML. Defaults to osm_export_tool/mappings/defaults.yaml, which is a very broad selection of OSM tags ported from the imposm3 defaults.
  • -f, --formats : a comma-separated list of formats such as gpkg,shp. Defaults to just gpkg.
  • --omit-osm-ids: By default, every table will have an osm_id column. Relation IDs are negative.
  • --clip <file>: either a .poly or GeoJSON file.
    • The GeoJSON must be either a Polygon or MultiPolygon geometry, or a FeatureCollection with one Polygon or MultiPolygon feature.
    • Clipping is performed by Shapely and can be slow. It is recommended to filter the input PBF with a tool like osmium-tool.

YAML Mapping

  • SQL statements must be comparisons of keys to constants with the key first.
    • Valid examples:
      • height > 20
      • amenity='parking' OR (building = 'yes' and height > 5)
    • Invalid examples:
      • 20 < height
      • building > height
  • More examples can be found in the mappings directory.
  • if the types key is omitted, it defaults to points, lines and polygons.
  • At least one tag is required as a child of the select key.
  • If the where key is omitted, it defaults to choosing all features where any of the selected keys are present.
  • if where is a list of SQL, it is equivalent to joining each SQL in the list with OR.

Output formats

  1. OGC GeoPackage (gpkg)
  • This is the default export format, and the most flexible for modern GIS applications.
  • tables will be created with the wkbUnknown geometry type, which allows heterogeneous geometry types.
  1. Shapefile (shp)
  • Each layer and geometry type is a separate .SHP file. This is because each .SHP file only supports a single geometry type and column schema.
  1. KML (kml)
  • Each layer and geometry type is a separate .KML file. This is because the GDAL/OGR KML driver does not support interleaved writing of features with different geometry types.
  1. Maps.ME (coming soon)

  2. OsmAnd (coming soon)

  3. Garmin (coming soon)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].