Skip to main content

Fetch OpenStreetMap road, waterway, and water-body data for a bounding box.

Project description

TinyOSM: Lightweight OpenStreetMap GeoJSON Fetcher

PyPI Conda License: MIT Binder

codecov CI Documentation Downloads

Fetch OpenStreetMap data for a bounding box as GeoJSON. One function, one dependency, minimal footprint.

Why

OSMnx is the go-to tool for working with OpenStreetMap data in Python. It handles street-network analysis, building footprints, amenity lookups, graph-theoretic routing, and more. But it pulls in geopandas, shapely, and networkx, a heavy dependency stack, that can be slow to install in constrained environments like AWS Lambda, minimal Docker images, or CI runners.

tiny-osm exists for the narrower case where you just need OSM features as clean GeoJSON. It ships with presets for roads, waterways, and water bodies, and accepts any Overpass QL tag-filter for custom queries. It has one runtime dependency (httpx), installs in seconds, and returns standards-compliant GeoJSON that works with any downstream tool such as geopandas, shapely, or even a JavaScript map library.

tiny-osm osmnx
Dependencies 1 (httpx) 7+ (geopandas, shapely, networkx, ...)
Output format GeoJSON dicts GeoDataFrames/networkx graphs
Scope Any Overpass tag-filter Full OSM toolkit
API surface 1 function Dozens of modules

Installation

pip install tiny-osm

Or with conda/pixi:

pixi add tiny-osm

Tip: If orjson is installed, tiny-osm uses it automatically for faster JSON parsing of Overpass API responses.

Usage

import tiny_osm

# Each call returns a GeoJSON FeatureCollection dict
bbox = (-97.75, 30.25, -97.70, 30.30)
highways = tiny_osm.fetch(*bbox, osm_filter=tiny_osm.OSMFilters.HIGHWAY)
waterways = tiny_osm.fetch(*bbox, osm_filter=tiny_osm.OSMFilters.WATERWAY)
water_bodies = tiny_osm.fetch(*bbox, osm_filter=tiny_osm.OSMFilters.WATER_BODY)

# Load into geopandas (optional - tiny-osm doesn't require it)
import geopandas as gpd

gdf = gpd.GeoDataFrame.from_features(highways, crs=4326)

# Custom Overpass QL filter
parks = tiny_osm.fetch(*bbox, osm_filter='["leisure"="park"]')

Filters

osm_filter What it queries
OSMFilters.HIGHWAY highway=* ways (excluding areas, abandoned, planned, raceway)
OSMFilters.WATERWAY waterway=* ways
OSMFilters.WATER_BODY Closed water features: ponds, lakes, reservoirs, detention/retention basins
any string Raw Overpass QL tag-filter (e.g. '["amenity"="restaurant"]')

What it handles

  • Auto-subdivides large bounding boxes into tiles
  • Retries across multiple Overpass API mirrors with automatic failover
  • Assembles multi-polygon relations (ring stitching, hole assignment)
  • Deduplicates elements across tile boundaries
  • Applies the OSM polygon-features rule tree (area=yes/no, coastline exceptions, etc.)

Contributing

Contributions are welcome! See CONTRIBUTING.md for details.

License

MIT License. See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tiny_osm-0.1.0.tar.gz (1.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tiny_osm-0.1.0-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file tiny_osm-0.1.0.tar.gz.

File metadata

  • Download URL: tiny_osm-0.1.0.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tiny_osm-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ae795dd870931830b7ce46a072316c24c7229dd6207b700a95545e765b26afc0
MD5 08174f7fc127ede3967c1c714b97802c
BLAKE2b-256 b5d9830ace9bbe32c62ff8401b2fd2cf95cf1dc3035ac5467e822e64e6a9e658

See more details on using hashes here.

Provenance

The following attestation bundles were made for tiny_osm-0.1.0.tar.gz:

Publisher: release.yml on cheginit/tiny-osm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tiny_osm-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: tiny_osm-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tiny_osm-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1fcbf7a7c4db6a6414668426e0b75e53925da241bfc8eeba32dd648ee9e0a5e5
MD5 869b8f808ce48bdf5cdacda26156b970
BLAKE2b-256 75d04d8cd4d4bf89f51265ca464b7a1aea283e5a0beb2f2adc9039db9ad58c94

See more details on using hashes here.

Provenance

The following attestation bundles were made for tiny_osm-0.1.0-py3-none-any.whl:

Publisher: release.yml on cheginit/tiny-osm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page