iduedu.download_osm_pbf¶
- iduedu.download_osm_pbf(*, osm_id=None, territory=None, region=None, name=None, out_dir=None, update=False, overwrite=False, way_keys=('highway', 'railway', 'public_transport'))[source]¶
OSM file for a territory, cut out of a Geofabrik extract: a drop-in replacement for Overpass downloads.
The territory is given as in the graph builders. The smallest Geofabrik extract covering it is chosen automatically (or set with
region), downloaded once and cached, and the territory is cut out of it withsplit_by_polygons(): the file holds everything the graph builders read for that territory, including public-transport routes leaving it and, forosm_id, the boundary relation, soget_*_graph(osm_id=...)works on it in pbf mode.- Parameters:
osm_id (
int|None) – OSM relation id of the territory. Withoutregionits boundary is fetched once through Overpass (cached) to choose the extract; withregionit is read from the extract, so no Overpass request is made.territory (
Polygon|MultiPolygon|GeoDataFrame|GeoSeries|None) – Territory polygon in EPSG:4326, or a GeoDataFrame/GeoSeries in any CRS.region (
str|None) – Geofabrik region id to cut from; chosen automatically when omitted.name (
str|None) – Output file name without extension; defaults toosm_<osm_id>or a hash of the territory.out_dir (
str|PathLike|None) – Cache directory; defaults to<config.overpass_cache_dir>/geofabrik. Cut files go to itsterritories/subdirectory.update (
bool) – Refresh a cached regional extract when Geofabrik has a newer one and cut again.overwrite (
bool) – Cut again even if the territory file exists.way_keys (
Optional[Iterable[str]]) – Keys of the ways cut out with the territory, as insplit_by_polygons(); an empty sequence gives a file of the public-transport routes touching the territory alone (default name..._routes), forget_public_transport_graph()over a large area.
- Return type:
- Returns:
Path of
<name>.osm.pbf.- Raises:
ValueError – If neither
osm_idnorterritoryis given, or no extract covers the territory.