Skip to content

transitlos.network

Build (or load a cached) simplified, AOI-cropped walking street network.

Thin wrapper around UrbanAccessAnalyzer.api.StreetNetwork: downloads (or reads a local PBF), simplifies, and crops to the AOI -- unless a previously saved+simplified network already exists at cache_dir, in which case it is loaded instead of rebuilt.

prepare_street_network(aoi, cache_dir=None, cluster_distance=10.0, pbf_path=None, network_type='all', ignore_oneway=True)

Return a simplified, AOI-cropped StreetNetwork, using a cache if available.

Parameters:

Name Type Description Default
aoi AreaOfInterest

Area of interest the network is built/cropped for.

required
cache_dir Optional[str]

Directory to load a previously .save()d network from (via StreetNetwork.load), and to .save() a freshly built one to. If None, no caching is attempted -- the network is always rebuilt and never persisted.

None
cluster_distance float

Cluster distance (meters) passed to StreetNetwork.simplify.

10.0
pbf_path Optional[str]

Path to a local .osm.pbf file, forwarded to StreetNetwork.from_pbf. If it doesn't exist, it is downloaded for aoi via Geofabrik (see StreetNetwork.from_pbf's docstring). Required when cache_dir is None or has no cached network yet.

None
network_type str

Defaults to "all" -- every public road included regardless of walk-permission, including highway/trunk. This was briefly "walk" (2026-09-04, an explicit request to exclude highway/trunk roads except where needed for connectivity), reverted the same day (explicit follow-up: "delete this idea of excluding highway and only include edges really needed for the graph. Include all public roads regardless if they are walk or not including highway"). No highway-tag filter at all -- see osm_io.NETWORK_PROFILES["all"].

'all'
ignore_oneway bool

Defaults to True -- forwarded to StreetNetwork.from_pbf/osm_io.load_pbf so every included edge is traversable in both directions for this walking-access graph, regardless of any OSM oneway tag (a vehicle-traffic restriction pedestrians aren't bound by).

True

Returns:

Type Description
StreetNetwork

A StreetNetwork already simplified and cropped to aoi.

Raises:

Type Description
ValueError

If no cached network is found and pbf_path is None.