transitio.fetch_pbf#
- transitio.fetch_pbf(aoi, *, crop=True, directory=None, cache_dir=None, update=False, transport=None)#
Download (and by default crop) the OSM extract covering an AOI.
Resolution and cropping build on pyrosm: the smallest Geofabrik extract whose extent covers the AOI is picked from pyrosm’s bundled extract index, its
.osm.pbfis downloaded into the transitio cache, and by default the result is cropped to the AOI geometry (the true polygon, not just its envelope). A.provenance.jsonsidecar records the source extract URL, checksums and retrieval timestamp.- Parameters:
aoi (geometry, GeoDataFrame/GeoSeries, tuple or str) – Area of interest: a shapely geometry, a GeoDataFrame/GeoSeries, a
(minx, miny, maxx, maxy)tuple in WGS84, or a place name to geocode via Nominatim.crop (bool, default True) – Crop the downloaded extract to the AOI geometry;
Falsereturns the full covering extract.directory (str or pathlib.Path, optional) – Directory for the returned file; defaults to the transitio cache. Full extracts backing a crop always stay in the cache.
cache_dir (str or pathlib.Path, optional) – Cache directory for full extracts. Defaults to the platform user cache directory for transitio.
update (bool, default False) – Re-download the extract (and refresh the extract index) even when a cached copy exists.
transport (httpx.BaseTransport, optional) – Custom transport, mainly for testing.
- Returns:
Path of the
.osm.pbffile.- Return type:
pathlib.Path