osm2geojson
Parse OSM and Overpass JSON
What it is and what it does
osm2geojson is a parser that transforms geographic data from OpenStreetMap and Overpass API into standard GeoJSON or Shapely geometry objects. It accepts both JSON and XML input formats and provides four main conversion functions: json2geojson, xml2geojson, json2shapes, and xml2shapes. The library depends on shapely for geometric operations and requests for API calls.
You use it when you have OSM or Overpass data and need it in GeoJSON format for web mapping, or as Shapely objects for geometric analysis. It includes an Overpass API query helper (overpass_call) with automatic retries, and supports customization via options like filter_used_refs, log_level, and polygon feature definitions. The package also exposes a command-line interface for batch conversions.
Use it for:
- Convert Overpass API query results to GeoJSON for display in web mapping libraries like Leaflet or Mapbox.
- Parse OSM XML export files into Shapely geometry objects for spatial analysis or geometric operations.
- Query the Overpass API directly and convert results to GeoJSON in a single workflow.
- Extract specific OSM feature types (amenities, roads, buildings) and convert to standardized geographic formats.
- Build geographic data pipelines that ingest OSM data and output GeoJSON for downstream processing.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Converts OpenStreetMap and Overpass API data (JSON or XML) into GeoJSON FeatureCollections or Shapely geometry objects with properties.
Yes, with conditions. Install if you need to convert OSM or Overpass data to GeoJSON or Shapely objects and accept that the library is in active development (Beta status). No known security vulnerabilities, low install friction, and active maintenance make it a reasonable choice. However, verify that the current API and feature set meet your needs, as the documentation notes ongoing development work and incomplete CLI testing.
Install
osm2geojson on PyPI
pip
pip install osm2geojsonuv
uv add osm2geojsonpoetry
poetry add osm2geojsonInstalling osm2geojson
Before you install
Low friction: pure Python wheel with only two runtime dependencies (shapely, requests). Repository is active with recent commits and no archived status.
License in practice
MIT license is permissive; you may use, modify, and distribute this package freely with minimal restrictions.
Quickstart
import osm2geojson
# From Overpass JSON
geojson = osm2geojson.json2geojson(overpass_json)
# From OSM/Overpass XML
geojson = osm2geojson.xml2geojson(osm_xml)
# To Shape objects (Shapely geometries + properties)
shapes = osm2geojson.json2shapes(overpass_json)
Verify before relying
- Stability and API maturity: description states 'This library is under development' but classifiers show Beta status; current production-readiness level unclear.
- Performance characteristics with large OSM datasets: no documented limits or benchmarks provided.
- CLI tool completeness: documentation notes 'Add tests and examples for cli tool' as a to-do item.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — shapely, requests |
| Maintenance | actively maintained — 163 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 112,204/month — #12,377 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: osm2geojson-0.3.2-py3-none-any.whl
Keywords: geometry, gis, osm, parsing
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
kml2geojsonConverts KML files to GeoJSON format,…
permissive · top 15,000 on PyPI
overpyA Python wrapper for querying the Overpass API…
permissive · top 15,000 on PyPI
osmiumosmium provides Python bindings for the…
permissive · top 15,000 on PyPI
topojsontopojson encodes spatial data into TopoJSON…
permissive · top 15,000 on PyPI
arcgis2geojsonConverts ArcGIS JSON format to GeoJSON format,…
permissive · top 15,000 on PyPI
antimeridianFixes Shapely geometries and GeoJSON features…
permissive · top 15,000 on PyPI
geojsonEncodes, decodes, and represents GeoJSON…
permissive · top 5,000 on PyPI
osmnxOSMnx downloads, models, and analyzes street…
permissive · top 15,000 on PyPI
staticmapGenerates static map images with geographic…
unclear · top 15,000 on PyPI
pygeoifPyGeoIf provides lightweight, pure-Python…
copyleft · top 15,000 on PyPI