glacier_lengths.core module

Core functions in the glacier_lengths package.

glacier_lengths.core.buffer_centerline(centerline: shapely.geometry.LineString, glacier_outline: shapely.geometry.MultiPolygon, min_radius: float = 1.0, max_radius: float = 50, buffer_count: int = 20)[source]

Return buffered glacier centerlines (lines parallel to the centerline).

Note that the centerline coordinates should be ordered from glacier start to glacier end.

Parameters
  • centerline – The glacier centerline.

  • glacier_outline – The glacier outline polygon.

  • min_radius – The minimum buffer radius in georeferenced units.

  • max_radius – The maximum buffer radius in georeferenced units.

  • buffer_count – The amount of buffers to create. Will return approximately twice the count (one for each side).

Returns

Multiple buffered glacier centerlines.

glacier_lengths.core.cut_centerlines(centerlines: Union[shapely.geometry.LineString, shapely.geometry.MultiLineString], cutting_geometry: Union[shapely.geometry.LineString, shapely.geometry.Polygon, shapely.geometry.MultiPolygon], max_difference_fraction: float = 0.2, warn_if_not_cut: bool = True) Union[shapely.geometry.LineString, shapely.geometry.MultiLineString][source]

Cut glacier centerlines with another geometry.

The other geometry could be a glacier outline or a glacier front line.

Parameters
  • centerlines – One or multiple glacier centerlines.

  • cutting_geometry – A supported geometry to cut the centerlines with.

  • max_difference_fraction – The maximum difference of a centerline compared to the longest centerline. This is a filtering step to not include extremely small cut centerlines. A larger value will allow more centerlines to be valid. Defaults to 0.2 (80% of the longest centerline length).

  • warn_if_not_cut – Issue a warning if any of the centerlines were not cut by the cutting geometry.

Returns

Cut glacier centerlines.

glacier_lengths.core.geometry_to_line(geometry) Union[shapely.geometry.LineString, shapely.geometry.MultiLineString][source]

Try to convert a given geometry to a line.

Parameters

geometry – A shapely geometry object.

Raises

ValueError – If the geometry is in an unsupported format.

Returns

A LineString or MultiLineString representing the given geometry.

glacier_lengths.core.iter_geom(geometry) Iterable[source]

Return an iterable of the geometry.

Use case: If ‘geometry’ is either a LineString or a MultiLineString. Only MultiLineString can be iterated over normally.

glacier_lengths.core.measure_lengths(centerlines: Union[shapely.geometry.LineString, shapely.geometry.MultiLineString]) np.ndarray[source]

Measure the lengths of the given glacier centerlines.

Parameters

centerlines – One or multiple glacier centerlines.

Returns

An array of lengths with shape (N,) where N is the amount of centerlines.