iduedu.add_elevation¶
- iduedu.add_elevation(urban_graph, elevation, *, column='elevation', method='linear', sample_distance=20.0, structure_columns=('bridge', 'tunnel'), band=1)[source]¶
Add node heights and edge grades to a graph.
Nodes get
elevation(metres). Every edge is sampled along its geometry at steps of at mostsample_distanceand gets, in the direction fromutov:grade: rise over length between its ends, positive uphill;grade_max: the steepest absolute grade between two neighbouring samples;ascentanddescent: metres climbed and descended along the edge, both non-negative.
Edges on a bridge or in a tunnel (a
structure_columnstag other thanno) get a straight profile between their ends, and the nodes inside such structures get heights interpolated between the ends of the structure instead of the ground below or above them.- Parameters:
urban_graph (
UrbanGraph) – Graph in a projected (metric) CRS.elevation (
Union[str,PathLike,GeoDataFrame,Callable]) – Source of heights: a raster file (read with rasterio, bilinear interpolation, any CRS), a GeoDataFrame of points or contour lines with heights incolumn, or a functionf(x, y) -> zof coordinate arrays in the graph CRS.column (
str) – Height column of an elevation GeoDataFrame.method (
Literal['linear','nearest','idw']) – Interpolation between the heights of a GeoDataFrame:"linear"on a triangulation (the nearest height outside the data),"nearest"or"idw"(inverse squared distance to the eight nearest points).sample_distance (
float) – Largest step, in metres, between samples along an edge, and between points taken from contour lines.structure_columns (
Iterable[str]) – Edge columns that mark bridges and tunnels.band (
int) – Band of a raster file.
- Return type:
- Returns:
A new
UrbanGraphwith the added columns. Nodes without data haveNaNand so do the edges that touch them.- Raises:
ImportError – If
elevationis a raster path and rasterio is not installed.ValueError – If the graph CRS is missing or geographic, or the source does not cover the graph.