iduedu.unique_segments

iduedu.unique_segments(urban_graph, *, precision=0.01)[source]

Return the straight segments the edge geometries are made of, each physical segment once.

Every pair of consecutive coordinates of an edge geometry is one segment. Segments are compared without direction and after rounding their end points to precision, so the two directions of a two-way street, parallel edges drawn over the same points, and stretches that a there-and-back pair of edges shares only in part are all counted once. Separately mapped carriageways, which have their own points, stay separate. The sum of length is the length of the network on the ground.

Parameters:
  • urban_graph (UrbanGraph) – Graph with line geometries in a projected (metric) CRS.

  • precision (float) – Grid, in CRS units, that end points are rounded to before comparing segments.

Return type:

GeoDataFrame

Returns:

GeoDataFrame in the graph CRS with one two-point LineString per unique segment and columns length, edge (label of the first edge in edges_gdf that contains the segment) and edge_count (how many edge pieces share it). Zero-length segments are left out.

Raises:

ValueError – If precision is not positive or the graph CRS is geographic.