Lightweight Python client for discovering and downloading OpenStreetMap extracts from Geofabrik.
Project description
geofabrik-downloader
A lightweight, dependency-light Python client for discovering and downloading OpenStreetMap extracts from Geofabrik.
Status: alpha. The public API may change before
1.0.
Why this exists
Geofabrik publishes daily OpenStreetMap extracts for every continent, country, and many sub-national regions. The existing Python tooling around it is either:
- Bloated —
pydriosmis the closest equivalent, but it pulls inpandas,numpy,shapely,bs4,pyhelpers,pyrcs, and a PostgreSQL I/O layer just to download a file. It is also GPLv3-licensed, which blocks adoption in many commercial codebases. - Indirect —
osmnxqueries the Overpass API;pyrosmreads PBF files but expects you to source them yourself.
geofabrik-downloader does one thing: list available regions and download their files. Pair it with pyrosm, pyosmium, or geopandas for parsing.
Features
- Region discovery via Geofabrik's structured
index-v1.json— no HTML scraping - Browse, search, and walk the region hierarchy (
list_regions,search_regions,children_of,get_region) - Locally cached index with a configurable TTL and an explicit
refresh_index() - Download
.osm.pbf,.shp.zip,.gpkg.zip,.osm.bz2,.poly,.kml - MD5 checksum verification using the published
.md5sidecars - Resumable downloads via HTTP
Rangerequests, with a progress callback hook - Optional spatial lookup:
find_by_point/find_by_bboxwhen the geometry-bearing index is loaded - Selective shapefile-layer extraction from
.shp.zip(list_layers,extract_layer) — no shapely/geopandas required - Type hints throughout, MIT-licensed, single runtime dependency (
httpx)
Installation
pip install geofabrik-downloader
Quick start
from geofabrik import Client
with Client() as client:
# List top-level continents
for region in client.list_regions(parent=None):
print(region.id, region.name)
# Inspect a specific region
turkey = client.get_region("turkey")
print(turkey.available_formats) # e.g. frozenset({'pbf', 'shp', 'poly', 'kml'})
# Download with MD5 verification (default)
result = client.download(turkey, format="pbf", dest="./data")
print(f"Saved {result.bytes_written} bytes to {result.path}")
Searching and walking the hierarchy
with Client() as client:
matches = client.search_regions("bavaria")
for region in client.children_of("germany"):
print(region.id)
Spatial lookup
Spatial helpers require the full index (≈50 MB) to be loaded:
with Client(include_geometry=True) as client:
# Smallest region containing the point first
hits = client.find_by_point(lat=41.0, lon=29.0)
print(hits[0].id)
Extracting a single shapefile layer
with Client() as client:
zip_path = client.download("monaco", format="shp", dest="./data").path
print(client.list_layers(zip_path)) # which layers are present
client.extract_layer(zip_path, "roads", "./out") # only the roads layer
CLI
A geofabrik console-script entry point is declared in pyproject.toml but the CLI
module is not implemented yet. The cli extras (typer, rich) are reserved for it.
Until then, use the Python API above. Tracking the design in IMPLEMENTATION.md.
What this package does not do
- Parse PBF or Shapefile content — use
pyrosm,pyosmium, orgeopandas - Write to a database — roll your own with
sqlalchemyorpsycopg - Query the OSM Overpass / Nominatim APIs — use
osmnxoroverpy - Download from BBBike or other OSM mirrors
These are deliberate scope choices, not roadmap items.
Contributing
See IMPLEMENTATION.md for the technical design and the current open questions. Issues and pull requests are welcome.
License
MIT. OpenStreetMap data itself is licensed under the ODbL by the OpenStreetMap Foundation.
Acknowledgements
Inspired by pydriosm. This package borrows the problem statement and nothing else.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file geofabrik_downloader-0.1.0.tar.gz.
File metadata
- Download URL: geofabrik_downloader-0.1.0.tar.gz
- Upload date:
- Size: 29.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03a76faf13847ddcc792660fd63b0a67119cec5ee11418c500817a004c83d576
|
|
| MD5 |
4139a5a01cfba14c7244cad908c7510d
|
|
| BLAKE2b-256 |
ebbad34d4e6b6251e59a193c79c1978b19d1a5020972256a7eaed8ed773c7603
|
Provenance
The following attestation bundles were made for geofabrik_downloader-0.1.0.tar.gz:
Publisher:
publish.yml on uucokgis/Geofabrik-Downloader
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
geofabrik_downloader-0.1.0.tar.gz -
Subject digest:
03a76faf13847ddcc792660fd63b0a67119cec5ee11418c500817a004c83d576 - Sigstore transparency entry: 1570822224
- Sigstore integration time:
-
Permalink:
uucokgis/Geofabrik-Downloader@9dad75f7dd33f8934f759ffa7ea83121ff8a4a4e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/uucokgis
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9dad75f7dd33f8934f759ffa7ea83121ff8a4a4e -
Trigger Event:
push
-
Statement type:
File details
Details for the file geofabrik_downloader-0.1.0-py3-none-any.whl.
File metadata
- Download URL: geofabrik_downloader-0.1.0-py3-none-any.whl
- Upload date:
- Size: 21.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3febf1f7a566b9d8476e3d58d756e062f1fe671ad22c2ceda5f3f36145453022
|
|
| MD5 |
aa0afd44781fc87ab804b08bdfb37c53
|
|
| BLAKE2b-256 |
4158787e1d2699308b7d1adcfbbf7ee0953f294ee970c23511d549982753301f
|
Provenance
The following attestation bundles were made for geofabrik_downloader-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on uucokgis/Geofabrik-Downloader
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
geofabrik_downloader-0.1.0-py3-none-any.whl -
Subject digest:
3febf1f7a566b9d8476e3d58d756e062f1fe671ad22c2ceda5f3f36145453022 - Sigstore transparency entry: 1570822306
- Sigstore integration time:
-
Permalink:
uucokgis/Geofabrik-Downloader@9dad75f7dd33f8934f759ffa7ea83121ff8a4a4e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/uucokgis
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9dad75f7dd33f8934f759ffa7ea83121ff8a4a4e -
Trigger Event:
push
-
Statement type: