All Projects → aspectumapp → Osm2geojson

aspectumapp / Osm2geojson

Licence: mit
Convert OSM and Overpass JSON to GeoJSON

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Osm2geojson

Blender Osm
One click download and import of OpenStreetMap and terrain for Blender! Global coverage! Source code is in the branch 'release'.
Stars: ✭ 588 (+2252%)
Mutual labels:  osm, openstreetmap
Vectiler
A vector tile, terrain and city 3d model builder and exporter
Stars: ✭ 394 (+1476%)
Mutual labels:  osm, openstreetmap
Hootenanny
Hootenanny conflates multiple maps into a single seamless map.
Stars: ✭ 264 (+956%)
Mutual labels:  osm, openstreetmap
basemaps
Scripts to generate MapServer mapfiles based on OpenStreetMap data. Please submit pull requests to the 'main' branch.
Stars: ✭ 51 (+104%)
Mutual labels:  openstreetmap, osm
Mapsui
Mapsui is a .NET Map component for WPF, Xamarin.Forms, Xamarin.Android, Xamarin.iOS and UWP
Stars: ✭ 447 (+1688%)
Mutual labels:  osm, openstreetmap
is-osm-uptodate
Find outdated nodes in OpenStreetMap
Stars: ✭ 16 (-36%)
Mutual labels:  openstreetmap, osm
Name Suggestion Index
Canonical common brand names, operators, transit and flags for OpenStreetMap.
Stars: ✭ 332 (+1228%)
Mutual labels:  osm, openstreetmap
o.map
Open Street Map app - KaiOS
Stars: ✭ 51 (+104%)
Mutual labels:  openstreetmap, osm
Overpass Turbo
A web based data mining tool for OpenStreetMap using the Overpass API.
Stars: ✭ 435 (+1640%)
Mutual labels:  osm, openstreetmap
Vector Datasource
Tilezen vector tile service - OpenStreetMap data in several formats
Stars: ✭ 427 (+1608%)
Mutual labels:  geojson, openstreetmap
accessibility-cloud
👩🏽‍🦯🦮👩🏻‍🦽👩🏿‍🦼 the platform to exchange physical accessibility data in a standardized, future-proof, easy-to-use way.
Stars: ✭ 37 (+48%)
Mutual labels:  openstreetmap, osm
Osmtogeojson
convert osm to geojson
Stars: ✭ 493 (+1872%)
Mutual labels:  geojson, openstreetmap
bexhill-osm
A local mapping project using data from OpenStreetMap. Includes overlays, walking directions and historical information.
Stars: ✭ 16 (-36%)
Mutual labels:  openstreetmap, osm
Osm4j Core
Core components of osm4j
Stars: ✭ 16 (-36%)
Mutual labels:  osm, openstreetmap
MapComplete
A small and easy OpenStreetMap editor
Stars: ✭ 101 (+304%)
Mutual labels:  openstreetmap, osm
Tilemill
TileMill is a modern map design studio
Stars: ✭ 2,952 (+11708%)
Mutual labels:  osm, openstreetmap
osmcha
Python package to detect suspicious OSM changesets
Stars: ✭ 33 (+32%)
Mutual labels:  openstreetmap, osm
query-overpass
Query the OpenStreetMap Overpass API.
Stars: ✭ 17 (-32%)
Mutual labels:  openstreetmap, osm
Mapbox Gl Native
Interactive, thoroughly customizable maps in native Android, iOS, macOS, Node.js, and Qt applications, powered by vector tiles and OpenGL
Stars: ✭ 4,091 (+16264%)
Mutual labels:  geojson, openstreetmap
Osrm Backend
Open Source Routing Machine - C++ backend
Stars: ✭ 4,716 (+18764%)
Mutual labels:  osm, openstreetmap

osm2geojson

Test package

Parse OSM and Overpass JSON with python. This library is under development!

Usage

Install this package with pip:

$ pip install osm2geojson

If you want to convert OSM xml or Overpass json/xml to Geojson you can import this lib and use one of 4 methods:

  • json2shapes(dict json_from_overpass) - to convert Overpass json to *Shape-objects
  • xml2shapes(str xml_from_osm) - to convert OSM xml or Overpass xml to *Shape-objects
  • json2geojson(dict json_from_overpass) - to convert Overpass json to Geojson
  • xml2geojson(str xml_from_osm) - to convert OSM xml or Overpass xml to Geojson

Additional parameters for all functions:

  • filter_used_refs - (default: True) defines geometry filtration strategy (will return all geometry if set as False)
  • log_level - (default: 'ERROR') controlls logging level (will print all logs if set as 'INFO'). More details here

Other handy methods:

  • overpass_call(str query) - runs query to overpass-api.de server (retries 5 times in case of error).
  • shape_to_feature(Shape shape, dict properties) - Converts Shape-object to GeoJSON with passed properties.

*Shape-object - for convinience created simple dict to save Shapely object (geometry) and OSM-properties. Structure of this object:

shape_obj = {
    'shape': Point | LineString | Polygon ...,
    'properties': {
        'type': 'relation' | 'node' ...,
        'tags': { ... },
        ...
    }
}

Examples

Convert OSM-xml to Geojson:

import codecs
import osm2geojson

with codecs.open('file.osm', 'r', encoding='utf-8') as data:
    xml = data.read()

geojson = osm2geojson.xml2geojson(xml, filter_used_refs=False, log_level='INFO')
# >> { "type": "FeatureCollection", "features": [ ... ] }

Convert OSM-json to Shape-objects:

import codecs
import osm2geojson

with codecs.open('file.json', 'r', encoding='utf-8') as data:
    json = data.read()

shapes_with_props = osm2geojson.json2shapes(json)
# >> [ { "shape": <Shapely-object>, "properties": {...} }, ... ]

Development

Clone project with submodules

$ git clone --recurse-submodules https://github.com/aspectumapp/osm2geojson.git

Setup package

$ python setup.py develop

Run tests

$ python -m unittest tests

Run single test

$ python tests/main.py TestOsm2GeoJsonMethods.test_barrier_wall

Update osm-polygon-features to last version (if you want last version)

$ ./update-osm-polygon-features.sh
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].