Table of Contents

Class H3Polygon

Namespace
H3.NET.Native
Assembly
H3.NET.Native.dll

Region operations that convert between GeoPolygon shapes and sets of H3 cells. All coordinates are in degrees.

public static class H3Polygon
Inheritance
H3Polygon
Inherited Members

Methods

FromCells(IEnumerable<H3Index>)

Merges a set of H3 cells into one or more polygons describing their outline, including holes.

public static IReadOnlyList<GeoPolygon> FromCells(IEnumerable<H3Index> cells)

Parameters

cells IEnumerable<H3Index>

The cells to merge. The Null sentinel is ignored.

Returns

IReadOnlyList<GeoPolygon>

The resulting polygons, with vertices in degrees. The first loop of each polygon is the exterior; any subsequent loops are holes.

Exceptions

ArgumentNullException

cells is null.

H3Exception

The native operation failed.

ToCells(GeoPolygon, int)

Returns the set of H3 cells of the given resolution whose centers fall within polygon.

public static H3Index[] ToCells(GeoPolygon polygon, int resolution)

Parameters

polygon GeoPolygon

The region to fill, in degrees.

resolution int

The target H3 resolution (0-15).

Returns

H3Index[]

The covering cells, with null padding slots removed. Order is not guaranteed.

Exceptions

ArgumentNullException

polygon is null.

H3DomainException

The resolution was rejected by the native library.

H3Exception

The native operation otherwise failed.

ToCellsExperimental(GeoPolygon, int, ContainmentMode)

Returns the set of H3 cells of the given resolution that satisfy the supplied mode containment predicate against polygon.

[Experimental("H3NET0001")]
public static H3Index[] ToCellsExperimental(GeoPolygon polygon, int resolution, ContainmentMode mode)

Parameters

polygon GeoPolygon

The region to fill, in degrees.

resolution int

The target H3 resolution (0-15).

mode ContainmentMode

The containment predicate selecting which cells are returned.

Returns

H3Index[]

The covering cells, with null padding slots removed. Order is not guaranteed.

Remarks

This API is experimental and may change in any future minor H3 version. Unlike the stable ToCells(GeoPolygon, int) (which always uses Center), this overload honors every ContainmentMode.

Exceptions

ArgumentNullException

polygon is null.

H3DomainException

The resolution was outside 0-15, or mode was an out-of-range cast (for example (ContainmentMode)99), which the native library rejects with E_OPTION_INVALID.

H3Exception

The native operation otherwise failed.