transitio.OsmEditor

Contents

transitio.OsmEditor#

class transitio.OsmEditor(path, *, network_type=None, custom_filter=None, filter_type='keep')#

Edit the routable network of an OSM extract and save it as a PBF.

Geometry follows the OSM model: node coordinates are authoritative and a way is an ordered list of member node ids, so moving a node moves every way through it and a way is reshaped through its member list, not its (derived) LineString. New elements get provisional negative ids that are stable for the life of the editor and become the ids in the written file.

Parameters:
  • path (str or pathlib.Path) – The source *.osm.pbf extract.

  • network_type (str, optional) – pyrosm network type (walking, driving, all, …). Give this to load a single mode instead of the default broad network.

  • custom_filter (dict, optional) – pyrosm Overpass-style tag filter selecting the editable network (e.g. {"highway": True, "railway": ["tram", "rail"]}), applied with network_type="all" and filter_type — matching snap_to_network(). When neither custom_filter nor network_type is given, the default is a broad network of all highway ways plus tram/rail/light_rail/ subway railways, so walk-, road- and rail-editing all have their features.

  • filter_type (str, default "keep") – pyrosm filter mode for custom_filter: "keep" restricts the network to the matching ways, "remove" drops them and keeps the rest.

Notes

Ways whose members extend beyond the extract keep their full member list; the out-of-extract members have no coordinates here and are re-emitted from the source on save. save() writes a network-only file (subset_only), so editing a shared node can never silently deform a feature that was not loaded.