Core

class h3ronpy.ContainmentMode

Containment mode used to decide if a cell is contained in a polygon or not.

Modes:

  • ContainsCentroid: This mode will select every cells whose centroid are contained inside the polygon.

    This is the fasted option and ensures that every cell is uniquely assigned (e.g. two adjacent polygon with zero overlap also have zero overlapping cells).

    On the other hand, some cells may cover area outside of the polygon (overshooting) and some parts of the polygon may be left uncovered.

  • ContainsBoundary: This mode will select every cells whose boundaries are entirely within the polygon.

    This ensures that every cell is uniquely assigned (e.g. two adjacent polygon with zero overlap also have zero overlapping cells) and avoids any coverage overshooting.

    Some parts of the polygon may be left uncovered (more than with ContainsCentroid).

  • IntersectsBoundary: This mode will select every cells whose boundaries are within the polygon, even partially.

    This guarantees a complete coverage of the polygon, but some cells may belong to two different polygons if they are adjacent/close enough. Some cells may cover area outside of the polygon.

  • Covers: This mode behaves the same as IntersectsBoundary, but also handles the case where the geometry is

    being covered by a cell without intersecting with its boundaries. In such cases, the covering cell is returned.

ContainsBoundary = ContainmentMode.ContainsBoundary
ContainsCentroid = ContainmentMode.ContainsCentroid
Covers = ContainmentMode.Covers
IntersectsBoundary = ContainmentMode.IntersectsBoundary
h3ronpy.cells_area_km2(cellarray) Array
Return type:

Array

h3ronpy.cells_area_m2(cellarray) Array
Return type:

Array

h3ronpy.cells_area_rads2(cellarray) Array
Return type:

Array

h3ronpy.cells_parse(arr, set_failing_to_invalid: bool = False) Array

Parse H3 cells from string arrays.

Setting set_failing_to_invalid to true will trigger setting the validity bitmap according the successful parsing of an individual element. Having this set to false will cause the method to fail upon encountering the first unparsable value.

This function is able to parse multiple representations of H3 cells:

  • hexadecimal (Example: 8552dc63fffffff)

  • numeric integer strings (Example: 600436454824345599)

  • strings like [x], [y], [resolution] or [x]; [y]; [resolution]. (Example: 10.2,45.5,5)

Parameters:

set_failing_to_invalid (bool)

Return type:

Array

h3ronpy.cells_resolution(arr) Array

Generates a new array containing the resolution of each cell of the input array.

Parameters:

arr

Returns:

Return type:

Array

h3ronpy.cells_to_localij(cellarray, anchor, set_failing_to_invalid: bool = False) RecordBatch

Produces IJ coordinates for an index anchored by an origin anchor.

The coordinate space used by this function may have deleted regions or warping due to pentagonal distortion.

Coordinates are only comparable if they come from the same origin index.

The parameter anchor can be a single cell or an array of cells which serve as anchor for the cells of cellarray. In case it is an array, the length must match the length of the cell array.

The default behavior is for this function to fail when a single transformation can not be completed successfully. When set_failing_to_invalid is set to True, only the failing positions of the output arrays will be set to null.

Parameters:

set_failing_to_invalid (bool)

Return type:

RecordBatch

h3ronpy.cells_to_string(cellarray) Array
Return type:

Array

h3ronpy.cells_valid(arr, booleanarray: bool = False) Array

Validate an array of potentially invalid cell values by returning a new UInt64 array with the validity mask set accordingly.

If booleanarray is set to True, a boolean array describing the validity will be returned instead.

Parameters:

booleanarray (bool)

Return type:

Array

h3ronpy.change_resolution(arr, resolution: int) Array

Change the H3 resolutions of all contained values to resolution.

In case of resolution increases all child indexes will be added, so the returned value may contain more indexes than the input.

Invalid/empty values are omitted.

Parameters:

resolution (int)

Return type:

Array

h3ronpy.change_resolution_list(arr, resolution: int) Array

Change the H3 resolutions of all contained values to resolution.

The output list array has the same length as the input array, positions of the elements in input and output are corresponding to each other.

Invalid/empty values are preserved as such.

Parameters:

resolution (int)

Return type:

Array

h3ronpy.change_resolution_paired(arr, resolution: int) RecordBatch

Returns a table/dataframe with two columns: cell_before and cell_after with the cells h3index before and after the resolution change.

This can be helpful when joining data in different resolutions via dataframe libraries

Parameters:

resolution (int)

Return type:

RecordBatch

h3ronpy.compact(arr, mixed_resolutions: bool = False) Array

Compact the given cells

The cells are expected to be of the same resolution, otherwise this operation will fail unless mixed_resolutions is set to True. Setting this may lead to slight slow-downs.

Parameters:

mixed_resolutions (bool)

Return type:

Array

h3ronpy.directededges_parse(arr, set_failing_to_invalid: bool = False) Array

Parse H3 directed edges from string arrays.

Setting set_failing_to_invalid to true will trigger setting the validity bitmap according the successful parsing of an individual element. Having this set to false will cause the method to fail upon encountering the first unparsable value.

Parameters:

set_failing_to_invalid (bool)

Return type:

Array

h3ronpy.directededges_to_string(directededgearray) Array
Return type:

Array

h3ronpy.directededges_valid(arr, booleanarray: bool = False) Array

Validate an array of potentially invalid directed edge values by returning a new UInt64 array with the validity mask set accordingly.

If booleanarray is set to True, a boolean array describing the validity will be returned instead.

Parameters:

booleanarray (bool)

Return type:

Array

h3ronpy.grid_disk(cellarray, k: int, flatten: bool = False) Array
Parameters:
Return type:

Array

h3ronpy.grid_disk_aggregate_k(cellarray, k: int, aggregation_method: str) RecordBatch

Valid values for aggregation_method are “min” and “max”.

Parameters:
  • k (int)

  • aggregation_method (str)

Return type:

RecordBatch

h3ronpy.grid_disk_distances(cellarray, k: int, flatten: bool = False) RecordBatch
Parameters:
Return type:

RecordBatch

h3ronpy.grid_ring_distances(cellarray, k_min: int, k_max: int, flatten: bool = False) RecordBatch
Parameters:
Return type:

RecordBatch

h3ronpy.localij_to_cells(anchor, i, j, set_failing_to_invalid: bool = False) Array

Produces cells from i and j coordinates and an anchor cell.

The default behavior is for this function to fail when a single transformation can not be completed successfully. When set_failing_to_invalid is set to True, only the failing positions of the output arrays will be set to null.

Parameters:

set_failing_to_invalid (bool)

Return type:

Array

h3ronpy.uncompact(arr, target_resolution: int) Array

Uncompact the given cells to the resolution target_resolution.

All higher resolution cells contained in the input array than the given target_resolution will be omitted from the output.

Parameters:

target_resolution (int)

Return type:

Array

h3ronpy.version()

version of the module

h3ronpy.vertexes_parse(arr, set_failing_to_invalid: bool = False) Array

Parse H3 vertexes from string arrays.

Setting set_failing_to_invalid to true will trigger setting the validity bitmap according the successful parsing of an individual element. Having this set to false will cause the method to fail upon encountering the first unparsable value.

Parameters:

set_failing_to_invalid (bool)

Return type:

Array

h3ronpy.vertexes_to_string(vertexesarray) Array
Return type:

Array

h3ronpy.vertexes_valid(arr, booleanarray: bool = False) Array

Validate an array of potentially invalid vertex values by returning a new UInt64 array with the validity mask set accordingly.

If booleanarray is set to True, a boolean array describing the validity will be returned instead.

Parameters:

booleanarray (bool)

Return type:

Array