lair.geo.points_along_line#
- lair.geo.points_along_line(multiline, spacing, resolution_factor=None)[source]#
Generates Euclidean spaced points covering a single Line or a MultiLineString network.
The algorithm works as follows: 1. Topology Fixing: The input MultiLineString is processed to ensure that all
intersections are properly represented as nodes in the graph. This is done using unary_union to split lines at intersections, followed by linemerge to stitch simple paths back together.
Graph Construction: A high-resolution graph is built from the cleaned geometry. Each line is segmentized into small segments based on the resolution_factor, and edges are added to the graph with weights corresponding to the Euclidean distance between nodes.
Point Generation: A breadth-first search (BFS) is performed on the graph to generate points. The BFS ensures that points are placed at least spacing distance apart. When a point is placed, it becomes the “origin” for measuring distance to subsequent points. If a candidate point is too close to any previously placed point (not just the parent), it is skipped, but the BFS continues to explore neighbors to find valid locations further along the network.
Global State Management: The function maintains a global list of placed points to enforce the spacing constraint across the entire network, even between disconnected components.
- Parameters:
multiline (shapely.geometry.MultiLineString) – The input MultiLineString geometry representing the network.
spacing (float) – The minimum Euclidean distance between generated points.
resolution_factor (float, optional) – A factor to control the density of the underlying graph. Smaller values create a denser graph, which can better capture curves but may be slower to process. Default is 0.1.
- Returns:
list[shapely.geometry.Point] – A list of Points generated along the MultiLineString network, spaced at least spacing distance apart.
- Return type:
list[Point]