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.pbfper polygon from a regional extract.- Parameters:
region_pbf (
str|PathLike) – Regional.osm.pbffile, 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.namebecomes 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.Noneselects 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]]) – OSMroutevalues of the relations to keep; defaults to every mode ofDEFAULT_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:
- Returns:
{name: path}of the written files.- Raises:
FileNotFoundError – When
region_pbfdoes not exist.ValueError – When
region_pbfis not an OSM.pbffile, or for an invalid name.FileExistsError – When an output exists and
overwriteis False.