Download
OSMForge downloads PBF extracts from Geofabrik. Region paths mirror the Geofabrik URL structure.
CLI
The osmforge-download command is installed automatically with the package.
# Single region
osmforge-download europe/united-kingdom/england/isle-of-wight
# Multiple regions in one call
osmforge-download \
europe/united-kingdom/england/greater-london \
europe/united-kingdom/england/west-midlands
# Force re-download (overwrite existing file)
osmforge-download --force europe/united-kingdom/england/isle-of-wight
Files are saved to the OS user-data directory by default:
| OS | Default path |
|---|---|
| Linux | ~/.local/share/osmforge/ |
| macOS | ~/Library/Application Support/osmforge/ |
| Windows | %LOCALAPPDATA%\osmforge\ |
Override the destination with an environment variable:
export OSMFORGE_DATA_DIR=/data/osm
osmforge-download europe/united-kingdom/england/isle-of-wight
Example region paths
europe/united-kingdom/england/isle-of-wight
europe/united-kingdom/england/greater-london
europe/united-kingdom/england/west-midlands
europe/united-kingdom/scotland
europe/germany/berlin
north-america/us/california
Full index: https://download.geofabrik.de/
Python API
You can also call the download functions directly from Python:
from osmforge.download import download, get_data_dir
# Show where files will be saved
print(get_data_dir())
# /home/user/.local/share/osmforge
# Download a region (skips if already present)
path = download("europe/united-kingdom/england/isle-of-wight")
print(path)
# /home/user/.local/share/osmforge/isle-of-wight-latest.osm.pbf
# Force re-download
path = download("europe/united-kingdom/england/isle-of-wight", force=True)
API Reference
osmforge.download
Download OSM PBF extracts from Geofabrik.
Usage:
python3 osmforge/download.py
Examples: python3 osmforge/download.py europe/united-kingdom/england/isle-of-wight python3 osmforge/download.py europe/united-kingdom/england/greater-london python3 osmforge/download.py europe/united-kingdom/england/west-midlands europe/united-kingdom/england/staffordshire
Or via make: make download REGION=europe/united-kingdom/england/isle-of-wight make download REGION="europe/united-kingdom/england/west-midlands europe/united-kingdom/england/staffordshire"
get_data_dir()
Resolve the directory where PBF files are stored.
Priority: 1. OSMFORGE_DATA_DIR environment variable 2. OS user-data directory (~/.local/share/osmforge on Linux, ~/Library/Application Support/osmforge on macOS, etc.)
Source code in osmforge/download.py
32 33 34 35 36 37 38 39 40 41 42 43 44 | |
download(region_path, force=False)
Source code in osmforge/download.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |