The conversion Module¶
Fig. 20 compact_cells: a uniform resolution 5 polyfill of a polygon
(left) and the same set of cells after compaction (right), where any
nine siblings all present in the set are replaced by their parent,
repeatedly. The interior collapses to coarse cells while the edge
detail is preserved exactly – here 518 cells become 182. The change
of texture partway down is the boundary between the equatorial Q
cells (longitude-latitude rectangles) and the south polar S cells
(skew quads and darts, which are not).¶
|
Cells covering a polygon, found by refining a bounding cell. |
|
Compact a set of rHEALPix DGGS cells by repeatedly merging complete groups of |
|
Compress and sort a collection of cells. |
|
Finds the finest DGGS Cell containing a given cartesian polygon |
- class rhealpixdggs.conversion.CellZoneFromPoly(feature: tuple[str, ~shapely.geometry.polygon.Polygon | ~shapely.geometry.multipolygon.MultiPolygon], res_limit: int, return_cells: bool, file: ~typing.TextIO | None = None, bounding_cell: ~rhealpixdggs.cell.Cell | None = None, rdggs: ~rhealpixdggs.dggs.RHEALPixDGGS = <rhealpixdggs.dggs.RHEALPixDGGS object>)[source]¶
Bases:
objectCells covering a polygon, found by refining a bounding cell.
This is a producer, not a collection: it walks down from a cell that contains the geometry, keeping cells the geometry contains outright and recursing into ones it merely overlaps, until
res_limit. For a set of cells to hold and operate on afterwards – union, intersection, difference, the hierarchy walks of OGC Topic 21 – seerhealpixdggs.zoneset.ZoneSet.
- rhealpixdggs.conversion.compact_cells(cells: Iterable[str], N_side: int = 3) set[str][source]¶
Compact a set of rHEALPix DGGS cells by repeatedly merging complete groups of
N_side ** 2siblings into their parent until no further merging is possible.N_sidedefaults to 3 (the default for RHEALPixDGGS and most presets, e.g.WGS84_003); pass theN_sideof the DGGS the cells actually belong to if it’s not 3 (e.g. 2 forWGS84_002), otherwise a complete sibling group will never be recognised as complete and nothing will compact.All input cells must be at the same resolution (equal string length). Raises ValueError if the input contains cells at mixed resolutions. Returns a set; if the caller needs ordering, sort the result separately.
- rhealpixdggs.conversion.compress_order_cells(cells: list[str], recursive: bool = False, N_side: int = 3) list[str][source]¶
Compress and sort a collection of cells.
Each complete group of
N_side ** 2siblings is replaced by their parent cell.N_sidedefaults to 3 (the default for RHEALPixDGGS and most presets, e.g.WGS84_003); pass theN_sideof the DGGS the cells actually belong to if it’s not 3 (e.g. 2 forWGS84_002), otherwise a complete sibling group will never be recognised as complete and nothing will compress. By default only one level of compression is performed. Passrecursive=Trueto repeat until no further compression is possible. The result is always deduplicated and sorted alphanumerically.
- rhealpixdggs.conversion.get_finest_containing_cell(polygon: Polygon | MultiPolygon, rdggs: RHEALPixDGGS = <rhealpixdggs.dggs.RHEALPixDGGS object>) Cell | None[source]¶
Finds the finest DGGS Cell containing a given cartesian polygon