Nodes¶
Create nodes (points) from a GeoDataFrame of lines.
The functions are used inside inside other functions, and aren’t needed to use explicitly.
- make_node_ids(gdf, wkt=True)[source]
Gives the lines unique node ids and returns lines (edges) and nodes.
Takes the first and last point of each line and creates a GeoDataFrame of nodes (points) with a column ‘node_id’. The node ids are then assigned to the input GeoDataFrame of lines as the columns ‘source’ and ‘target’.
- Parameters:
gdf (
GeoDataFrame
) – GeoDataFrame with line geometrieswkt (
bool
) – If True (default), the resulting nodes will include the column ‘wkt’, containing the well-known text representation of the geometry. If False, it will include the column ‘coords’, a tuple with x and y geometries.
- Return type:
tuple
[GeoDataFrame
,GeoDataFrame
]- Returns:
A tuple of two GeoDataFrames, one with the lines and one with the nodes.
Note
The lines must be singlepart linestrings.