combine_lines

Contents

combine_lines#

zeroheliumkit.src.utils.combine_lines(line1: LineString, line2: LineString, tol: float = 1e-06) LineString[source]#
Combines two LineStrings by joining them together at their endpoints

if they are within a distance defined by the tolerance.

Parameters:
  • line1 (LineString) – The first LineString.

  • line2 (LineString) – The second LineString.

  • tol (float, optional) – The distance within which to merge the lines. Defaults to 1e-6.

Raises:

ValueError – If the distance between all boundary points is not within the tolerance.

Example

>>> line1 = LineString([(0, 0), (1, 1)])
>>> line2 = LineString([(1, 1), (2, 2)])
>>> result = merge_lines_with_tolerance(line1, line2, tol=0.5)
>>> print(result)
    LINESTRING (0 0, 1 1, 2 2)