leaf_engine.utils.h3
This module contains various pure functions for manipulating H3 indices.
Attributes
Functions
|
|
|
Given a set of H3 indices, returns a list of H3 indices representing |
|
Returns the k-ring of a given H3 index (i.e., the k-"disk"). Optionally, |
|
|
|
|
|
Converts a set of H3 indices to shapely Polygon or WKT. Raises an exception |
|
Returns whether area defined by a set of H3 indices is contiguous. |
|
|
|
|
|
Module Contents
- leaf_engine.utils.h3.geometry_to_h3_indices(geometry: str | shapely.geometry.Polygon, resolution: int = H3_RESOLUTION) Iterable
- leaf_engine.utils.h3.get_contiguous_areas(indices: set) list[set]
Given a set of H3 indices, returns a list of H3 indices representing contiguous areas in the provided list of indices.
- leaf_engine.utils.h3.get_k_ring(index: str, k: int, exclude_k: int | None = None) set
Returns the k-ring of a given H3 index (i.e., the k-“disk”). Optionally, allows the specification of an internal k-ring to exclude from the return set (which will return a k-“doughnut” instead of a k-“disk”).
- leaf_engine.utils.h3.h3_index_to_geometry(h3_index: str, as_string=False) str | shapely.geometry.Polygon
- leaf_engine.utils.h3.h3_indices_to_geometry(indices: Iterable, as_string: bool = False) str | shapely.geometry.Polygon
Converts a set of H3 indices to shapely Polygon or WKT. Raises an exception if the conversion produces a MultiPolygon instead of contiguous Polygon.
- leaf_engine.utils.h3.is_contiguous_area(indices: set) bool
Returns whether area defined by a set of H3 indices is contiguous.
- leaf_engine.utils.h3.polygon_to_h3_indices(polygon: shapely.geometry.Polygon, resolution=H3_RESOLUTION)
- Parameters:
polygon (shapely.geometry.Polygon) –
- leaf_engine.utils.h3.H3_POLYFILL_BUFFER
- leaf_engine.utils.h3.H3_RESOLUTION = 5