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 with split_by_polygons(): the file holds everything the graph builders read for that territory, including public-transport routes leaving it and, for osm_id, the boundary relation, so get_*_graph(osm_id=...) works on it in pbf mode.

Parameters:
  • osm_id (int | None) – OSM relation id of the territory. Without region its boundary is fetched once through Overpass (cached) to choose the extract; with region it 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 to osm_<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 its territories/ 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 in split_by_polygons(); an empty sequence gives a file of the public-transport routes touching the territory alone (default name ..._routes), for get_public_transport_graph() over a large area.

Return type:

Path

Returns:

Path of <name>.osm.pbf.

Raises:

ValueError – If neither osm_id nor territory is given, or no extract covers the territory.