iduedu.split_by_polygons

iduedu.split_by_polygons(region_pbf, polygons, out_dir, *, way_keys=('highway', 'railway', 'public_transport'), route_values=None, keep_relations=None, overwrite=False)[source]

Write one compact, referentially complete <name>.osm.pbf per polygon from a regional extract.

Parameters:
  • region_pbf (str | PathLike) – Regional .osm.pbf file, as distributed by Geofabrik.

  • polygons (Mapping[str, Polygon | MultiPolygon]) – {name: polygon} in EPSG:4326. Use the polygons (or larger ones) you will later build graphs for; as with Overpass, only the exterior ring counts. name becomes the file name and must not contain path separators.

  • out_dir (str | PathLike) – Output directory, created if missing.

  • way_keys (Optional[Iterable[str]]) – Ways carrying at least one of these keys are selected spatially. None selects every way, an empty sequence none: then a route enters a file by a node member (a stop or a platform) in its polygon, and the file holds the routes alone, with their members. Ways without the keys still enter a city file as members of selected relations.

  • route_values (Optional[Iterable[str]]) – OSM route values of the relations to keep; defaults to every mode of DEFAULT_REGISTRY_W_TRAIN (bus, trolleybus, tram/light_rail, subway, monorail, train, taxi/share_taxi).

  • keep_relations (Optional[Mapping[str, Iterable[int]]]) – {name: [relation ids]} relations to copy complete into that city’s file, e.g. its boundary relation.

  • overwrite (bool) – Replace existing output files.

Return type:

dict[str, Path]

Returns:

{name: path} of the written files.

Raises: