OSMWayLoader
srai.loaders.OSMWayLoader(
network_type,
contain_within_area=False,
preprocess=True,
wide=True,
metadata=False,
osm_way_tags=constants.OSM_WAY_TAGS,
)
¶
srai.loaders.OSMWayLoader(
network_type,
contain_within_area=False,
preprocess=True,
wide=True,
metadata=False,
osm_way_tags=constants.OSM_WAY_TAGS,
)
Bases: Loader
OSMWayLoader downloads road infrastructure from OSM.
OSMWayLoader loader is a wrapper for the osmnx.graph_from_polygon()
and osmnx.graph_to_gdfs()
that simplifies obtaining the road infrastructure data
from OpenStreetMap. As the OSM data is often noisy, it can also take an opinionated approach
to preprocessing it, with standardisation in mind - e.g. unification of units,
discarding non-wiki values and rounding them.
PARAMETER | DESCRIPTION |
---|---|
network_type |
Type of the network to download.
TYPE:
|
contain_within_area |
defaults to False Whether to remove the roads that have one of their nodes outside of the given area.
TYPE:
|
preprocess |
defaults to True Whether to preprocess the data.
TYPE:
|
wide |
defaults to True Whether to return the roads in wide format.
TYPE:
|
metadata |
defaults to False Whether to return metadata for roads.
TYPE:
|
osm_way_tags |
defaults to constants.OSM_WAY_TAGS Dict of tags to take into consideration during computing.
TYPE:
|
Source code in srai/loaders/osm_way_loader/osm_way_loader.py
¶
Load road infrastructure for a given GeoDataFrame.
PARAMETER | DESCRIPTION |
---|---|
area |
(Multi)Polygons for which to download road infrastructure data.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
ValueError
|
If provided GeoDataFrame has no crs defined. |
ValueError
|
If provided GeoDataFrame is empty. |
TypeError
|
If provided geometries are not of type Polygon or MultiPolygon. |
LoadedDataIsEmptyException
|
If none of the supplied area polygons contains any road infrastructure data. |
RETURNS | DESCRIPTION |
---|---|
tuple[gpd.GeoDataFrame, gpd.GeoDataFrame]
|
Tuple[gpd.GeoDataFrame, gpd.GeoDataFrame]: Road infrastructure as (intersections, roads) |