skillfed

osm2geojson

Parse OSM and Overpass JSON

osm2geojson v0.3.2 112.2K downloads/30d#12,377 on PyPI113
Permissive license MIT Active released

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 osm2geojson

uv

uv add osm2geojson

poetry

poetry add osm2geojson

Installing 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

Development Status :: 4 - BetaIntended Audience :: DevelopersProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Scientific/Engineering :: GISTopic :: Software Development :: Libraries :: Python Modules

Tags

osm to geojson converteroverpass api parseropenstreetmap json conversionshapely geometry from osmosm xml to geojsonoverpass query results parsergeographic data format conversion
geospatial-dataopenstreetmapformat-conversion

More Python Modules packages