buffer_line_with_variable_width

buffer_line_with_variable_width#

zeroheliumkit.src.utils.buffer_line_with_variable_width(line: LineString, distance: list, widths: list, normalized: bool, join_style: str = 'flat') Polygon[source]#

Returns a buffered a line with variable widths along its length.

Parameters:
  • line (LineString) – The input line to buffer.

  • distance (list) – A list of distances along the line where the widths are defined.

  • widths (list) – A list of widths corresponding to the distances.

  • normalized (bool) – Flag indicating whether the distances are normalized.

  • join_style (str, optional) – The style of joining the buffered polygons. Valid options are ‘flat’ and ‘round’. Defaults to ‘flat’.

Returns:

Buffered line with variable widths along its length.

Return type:

polygon (Polygon)

Raises:

ValueError – If join_style is not either ‘flat’ or ‘round’.

Example

>>> line = LineString([(0, 0), (1, 1), (2, 0)])
>>> distance = [0.2, 0.5, 0.8]
>>> widths = [1, 2, 1]
>>> normalized = True
>>> join_style = 'flat'
>>> polygon = buffer_line_with_variable_width(line, distance, widths, normalized, join_style)