Skip to main content

raygeo.geo.algo.polylabel

Functions

find_largest_circle()

find_largest_circle(
shell: Sequence[tuple[float, float]],
holes: Sequence[Sequence[tuple[float, float]]] = [],
precision: float = 0.5,
) -> tuple[tuple[float, float], float] | None

Find the centre and radius of the largest inscribed circle.

ParameterTypeDescription
shellSequence[tuple[float, float]]Outer boundary polygon.
holesSequence[Sequence[tuple[float, float]]] = []List of hole polygons to exclude (default []).
precisionfloat = 0.5Desired precision (default 0.5).
Returnstuple[tuple[float, float], float] | None((x, y), radius) or None for degenerate polygons.

get_polylabel()

get_polylabel(
shell: Sequence[tuple[float, float]],
holes: Sequence[Sequence[tuple[float, float]]] = [],
precision: float = 0.5,
) -> tuple[float, float] | None

Find the pole of inaccessibility of a polygon (with optional holes).

Uses the Polylabel algorithm (Mapbox): a priority-queue of grid cells repeatedly subdivided until the cell radius drops below precision.

ParameterTypeDescription
shellSequence[tuple[float, float]]Outer boundary polygon.
holesSequence[Sequence[tuple[float, float]]] = []List of hole polygons to exclude (default []).
precisionfloat = 0.5Desired precision (default 0.5).
Returnstuple[float, float] | None(x, y) of the most interior point, or None for degenerate polygons.
ComplexityO(n log n) where n is the number of cells explored.