Table of Contents

Struct H3Index

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

A 64-bit H3 cell index. This is the primary handle for an H3 cell; all public coordinates exposed through its members are in degrees.

public readonly record struct H3Index : IEquatable<H3Index>
Implements
Inherited Members

Constructors

H3Index(ulong)

A 64-bit H3 cell index. This is the primary handle for an H3 cell; all public coordinates exposed through its members are in degrees.

public H3Index(ulong Value)

Parameters

Value ulong

The raw 64-bit H3 index value.

Properties

BaseCellNumber

Gets the base cell number (0-121) of this cell.

public int BaseCellNumber { get; }

Property Value

int

Exceptions

H3InvalidIndexException

This is not a valid H3 cell.

IsNull

Gets a value indicating whether this is the Null sentinel (raw value 0).

public bool IsNull { get; }

Property Value

bool

IsPentagon

Gets a value indicating whether this cell is one of the twelve pentagons at its resolution.

public bool IsPentagon { get; }

Property Value

bool

Exceptions

H3InvalidIndexException

This is not a valid H3 cell.

IsResClassIII

Gets a value indicating whether this cell is a Class III cell, that is, one whose resolution is odd. Class III cells are rotated and slightly distorted relative to Class II (even-resolution) cells.

public bool IsResClassIII { get; }

Property Value

bool

Exceptions

H3InvalidIndexException

This is not a valid H3 cell.

Null

Gets the sentinel "null" index (raw value 0), representing an invalid or absent cell.

public static H3Index Null { get; }

Property Value

H3Index

Resolution

Gets the resolution (0-15) of this cell.

public int Resolution { get; }

Property Value

int

Exceptions

H3InvalidIndexException

This is not a valid H3 cell.

Value

The raw 64-bit H3 index value.

public ulong Value { get; init; }

Property Value

ulong

Methods

CellAreaKm2()

Returns the area of this cell in square kilometers.

public double CellAreaKm2()

Returns

double

The cell area in square kilometers.

Exceptions

H3InvalidIndexException

This is not a valid H3 cell.

CellAreaM2()

Returns the area of this cell in square meters.

public double CellAreaM2()

Returns

double

The cell area in square meters.

Exceptions

H3InvalidIndexException

This is not a valid H3 cell.

CellAreaRads2()

Returns the area of this cell in steradians (square radians).

public double CellAreaRads2()

Returns

double

The cell area in steradians.

Exceptions

H3InvalidIndexException

This is not a valid H3 cell.

CellToCenterChild(int)

Returns the center child cell of this cell at the given finer resolution.

public H3Index CellToCenterChild(int childResolution)

Parameters

childResolution int

The target child resolution (0-15); must be greater than or equal to this cell's resolution.

Returns

H3Index

The center child H3Index at childResolution.

Exceptions

H3DomainException

childResolution is outside the range 0-15.

H3Exception

childResolution is coarser than this cell's resolution, or the native operation failed.

CellToChildPos(int)

Returns the position of this cell within an ordered traversal of all children of its parent at the given coarser resolution. Inverse of ChildPosToCell(long, int).

public long CellToChildPos(int parentResolution)

Parameters

parentResolution int

The parent resolution (0-15); must be less than or equal to this cell's resolution.

Returns

long

The zero-based child position of this cell within its parent at parentResolution.

Exceptions

H3DomainException

parentResolution is outside the range 0-15.

H3Exception

parentResolution is finer than this cell's resolution, or the native operation failed.

CellToChildren(int)

Returns all child cells of this cell at the given finer resolution.

public H3Index[] CellToChildren(int childResolution)

Parameters

childResolution int

The target child resolution (0-15); must be greater than or equal to this cell's resolution.

Returns

H3Index[]

The child cells, with null padding slots removed (pentagon parents yield fewer than the hexagon maximum). Order is not guaranteed.

Exceptions

ArgumentOutOfRangeException

childResolution implies a result so large that it would exceed MaxLength.

H3DomainException

childResolution is outside the range 0-15.

H3Exception

childResolution is coarser than this cell's resolution, or the native operation failed.

CellToChildrenInto(int, Span<H3Index>)

Fills destination with the child cells of this cell at the given finer resolution, packing non-null cells to the front.

public int CellToChildrenInto(int childResolution, Span<H3Index> destination)

Parameters

childResolution int

The target child resolution (0-15); must be greater than or equal to this cell's resolution.

destination Span<H3Index>

The destination span. Its length must be at least the maximum child count for childResolution (see the upstream cellToChildrenSize).

Returns

int

The number of non-null child cells written to the front of destination.

Exceptions

ArgumentOutOfRangeException

childResolution implies a result that would exceed MaxLength, or destination is too small.

H3DomainException

childResolution is outside the range 0-15.

H3Exception

childResolution is coarser than this cell's resolution, or the native operation failed.

CellToLocalIJ(H3Index)

Returns the local IJ coordinates of target relative to this cell as the anchoring origin.

public CoordIJ CellToLocalIJ(H3Index target)

Parameters

target H3Index

The cell to locate relative to this origin.

Returns

CoordIJ

The local IJ coordinates of target.

Remarks

Local IJ coordinates are only meaningful relative to this origin and are not guaranteed to be defined across pentagons or the antimeridian.

Exceptions

H3InvalidIndexException

Either cell is not a valid H3 cell.

H3Exception

The cells are different resolutions, target is too far from the origin, or pentagon distortion prevents a local coordinate.

CellToParent(int)

Returns the parent cell of this cell at the given coarser resolution.

public H3Index CellToParent(int parentResolution)

Parameters

parentResolution int

The target parent resolution (0-15); must be less than or equal to this cell's resolution.

Returns

H3Index

The parent H3Index at parentResolution.

Exceptions

H3DomainException

parentResolution is outside the range 0-15.

H3Exception

parentResolution is finer than this cell's resolution, or the native operation failed.

ChildPosToCell(long, int)

Returns the child cell of this (parent) cell at the given child position and resolution. Inverse of CellToChildPos(int).

public H3Index ChildPosToCell(long childPosition, int childResolution)

Parameters

childPosition long

The zero-based child position, in [0, cellToChildrenSize).

childResolution int

The child resolution (0-15); must be greater than or equal to this cell's resolution.

Returns

H3Index

The child H3Index at childPosition and childResolution.

Exceptions

H3DomainException

childResolution is outside the range 0-15, or childPosition is outside the valid range.

H3Exception

childResolution is coarser than this cell's resolution, or the native operation failed.

CompactCells(ReadOnlySpan<H3Index>)

Compacts a set of cells into the smaller, mixed-resolution set of cells that covers the same area. Inverse of UncompactCells(ReadOnlySpan<H3Index>, int).

public static H3Index[] CompactCells(ReadOnlySpan<H3Index> cells)

Parameters

cells ReadOnlySpan<H3Index>

The cells to compact. All must be the same resolution and duplicate-free.

Returns

H3Index[]

The compacted, mixed-resolution set of cells. Order is not guaranteed.

Exceptions

H3Exception

The input contains mixed resolutions or duplicates, or the native operation failed.

CompactCellsInto(ReadOnlySpan<H3Index>, Span<H3Index>)

Compacts a set of cells into destination, packing non-null cells to the front. Inverse of UncompactCellsInto(ReadOnlySpan<H3Index>, int, Span<H3Index>).

public static int CompactCellsInto(ReadOnlySpan<H3Index> cells, Span<H3Index> destination)

Parameters

cells ReadOnlySpan<H3Index>

The cells to compact. All must be the same resolution and duplicate-free.

destination Span<H3Index>

The destination span. Its length must be at least cells.Length (compaction never grows the set).

Returns

int

The number of cells written to the front of destination.

Exceptions

ArgumentOutOfRangeException

destination is too small.

H3Exception

The input contains mixed resolutions or duplicates, or the native operation failed.

Construct(int, int, ReadOnlySpan<int>)

Constructs an H3 cell from its base cell number and per-resolution indexing digits.

public static H3Index Construct(int resolution, int baseCellNumber, ReadOnlySpan<int> digits)

Parameters

resolution int

The target resolution (0-15).

baseCellNumber int

The base cell number (0-121).

digits ReadOnlySpan<int>

The indexing digits (each 0-6), one per resolution. Its length must equal resolution.

Returns

H3Index

The constructed H3Index.

Exceptions

ArgumentException

The length of digits does not equal resolution.

H3DomainException

The resolution, base cell number, or a digit was rejected by the native library (including a pentagon base cell with a leading K-axis digit).

DirectedEdgeTo(H3Index)

Returns the directed edge from this cell to destination.

public H3DirectedEdge DirectedEdgeTo(H3Index destination)

Parameters

destination H3Index

The neighbor cell the edge points to; must be an adjacent neighbor at the same resolution.

Returns

H3DirectedEdge

The H3DirectedEdge from this cell to destination.

Exceptions

H3Exception

The two cells are not neighbors, or are different resolutions.

FromLatLng(LatLng, int)

Converts a geographic coordinate to the containing H3 cell at the given resolution.

public static H3Index FromLatLng(LatLng latLng, int resolution)

Parameters

latLng LatLng

The coordinate, in degrees.

resolution int

The target H3 resolution (0-15).

Returns

H3Index

The H3 cell containing latLng.

Exceptions

ArgumentOutOfRangeException

The coordinate components are outside their valid ranges.

H3DomainException

The resolution or coordinate was rejected by the native library.

FromString(string)

Parses an H3 index from its hexadecimal string representation using the native library. Unlike Parse(string), an unparseable string surfaces as an H3Exception rather than a FormatException.

public static H3Index FromString(string value)

Parameters

value string

The hexadecimal index string.

Returns

H3Index

The parsed H3Index.

Exceptions

ArgumentNullException

value is null.

H3Exception

value could not be parsed by the native library.

GetBoundary()

Returns the boundary vertices of this cell in counter-clockwise order.

public IReadOnlyList<LatLng> GetBoundary()

Returns

IReadOnlyList<LatLng>

The boundary vertices, in degrees (5 vertices for pentagons, 6 for hexagons, more when edges cross icosahedron faces).

Exceptions

H3InvalidIndexException

This is not a valid H3 cell.

GetDirectedEdges()

Returns the directed edges originating at this cell, one per adjacent neighbor.

public H3DirectedEdge[] GetDirectedEdges()

Returns

H3DirectedEdge[]

The directed edges (6 for a hexagon, 5 for a pentagon). Order is not guaranteed.

Exceptions

H3InvalidIndexException

This is not a valid H3 cell.

H3Exception

The native operation failed.

GetDirectedEdgesInto(Span<H3DirectedEdge>)

Fills destination with the directed edges originating at this cell, packing the non-null edges to the front.

public int GetDirectedEdgesInto(Span<H3DirectedEdge> destination)

Parameters

destination Span<H3DirectedEdge>

The destination span. Its length must be at least 6 (the per-cell maximum).

Returns

int

The number of directed edges written to the front of destination (6 for a hexagon, 5 for a pentagon).

Exceptions

ArgumentOutOfRangeException

destination is too small.

H3InvalidIndexException

This is not a valid H3 cell.

H3Exception

The native operation failed.

GetHexagonAreaAvgKm2(int)

Returns the average area of a hexagonal cell at the given resolution, in square kilometers.

public static double GetHexagonAreaAvgKm2(int resolution)

Parameters

resolution int

The H3 resolution (0-15).

Returns

double

The average hexagon area at resolution, in square kilometers.

Exceptions

H3DomainException

resolution is outside the range 0-15.

GetHexagonAreaAvgM2(int)

Returns the average area of a hexagonal cell at the given resolution, in square meters.

public static double GetHexagonAreaAvgM2(int resolution)

Parameters

resolution int

The H3 resolution (0-15).

Returns

double

The average hexagon area at resolution, in square meters.

Exceptions

H3DomainException

resolution is outside the range 0-15.

GetHexagonEdgeLengthAvgKm(int)

Returns the average edge length of a hexagonal cell at the given resolution, in kilometers.

public static double GetHexagonEdgeLengthAvgKm(int resolution)

Parameters

resolution int

The H3 resolution (0-15).

Returns

double

The average hexagon edge length at resolution, in kilometers.

Exceptions

H3DomainException

resolution is outside the range 0-15.

GetHexagonEdgeLengthAvgM(int)

Returns the average edge length of a hexagonal cell at the given resolution, in meters.

public static double GetHexagonEdgeLengthAvgM(int resolution)

Parameters

resolution int

The H3 resolution (0-15).

Returns

double

The average hexagon edge length at resolution, in meters.

Exceptions

H3DomainException

resolution is outside the range 0-15.

GetIcosahedronFaces()

Returns the icosahedron face numbers (0-19) that this cell intersects.

public int[] GetIcosahedronFaces()

Returns

int[]

The distinct face numbers the cell touches (1-2 for hexagons, 5 for pentagons).

Exceptions

H3InvalidIndexException

This is not a valid H3 cell.

H3Exception

The native operation failed.

GetIcosahedronFacesInto(Span<int>)

Fills destination with the icosahedron face numbers (0-19) that this cell intersects, packing the valid faces to the front.

public int GetIcosahedronFacesInto(Span<int> destination)

Parameters

destination Span<int>

The destination span. Its length must be at least the maximum face count for this cell (2 for hexagons, 5 for pentagons).

Returns

int

The number of distinct faces written to the front of destination.

Exceptions

ArgumentOutOfRangeException

destination is too small.

H3InvalidIndexException

This is not a valid H3 cell.

H3Exception

The native operation failed.

GetIndexDigit(int)

Returns the stored indexing digit (0-7) at the given resolution.

public int GetIndexDigit(int resolution)

Parameters

resolution int

The 1-indexed resolution (1-15) of the digit to read. Resolution 0 is the base cell, not a digit. The resolution may exceed this cell's own resolution, in which case the stored digit (7 for a valid cell) is returned.

Returns

int

The indexing digit (0-7) at resolution.

Exceptions

H3DomainException

resolution is outside the range 1-15.

GetNumCells(int)

Returns the total number of unique H3 cells at the given resolution.

public static long GetNumCells(int resolution)

Parameters

resolution int

The H3 resolution (0-15).

Returns

long

The number of cells at resolution (122 at resolution 0).

Exceptions

H3DomainException

resolution is outside the range 0-15.

GetPentagons(int)

Returns the 12 pentagon cells at the given resolution.

public static H3Index[] GetPentagons(int resolution)

Parameters

resolution int

The H3 resolution (0-15).

Returns

H3Index[]

The 12 pentagons at resolution. Order is not guaranteed.

Exceptions

H3DomainException

resolution is outside the range 0-15.

H3Exception

The native operation failed.

GetPentagonsInto(int, Span<H3Index>)

Fills destination with the 12 pentagon cells at the given resolution.

public static int GetPentagonsInto(int resolution, Span<H3Index> destination)

Parameters

resolution int

The H3 resolution (0-15).

destination Span<H3Index>

The destination span. Its length must be at least 12.

Returns

int

The number of pentagons written (always 12).

Exceptions

ArgumentException

destination is smaller than 12.

H3DomainException

resolution is outside the range 0-15.

H3Exception

The native operation failed.

GetRes0Cells()

Returns all 122 resolution-0 base cells.

public static H3Index[] GetRes0Cells()

Returns

H3Index[]

The 122 resolution-0 cells. Order is not guaranteed.

Exceptions

H3Exception

The native operation failed.

GetRes0CellsInto(Span<H3Index>)

Fills destination with all 122 resolution-0 base cells.

public static int GetRes0CellsInto(Span<H3Index> destination)

Parameters

destination Span<H3Index>

The destination span. Its length must be at least 122.

Returns

int

The number of cells written (always 122).

Exceptions

ArgumentException

destination is smaller than 122.

H3Exception

The native operation failed.

GetVertex(int)

Returns one of the topological vertices of this cell.

public H3Vertex GetVertex(int vertexNumber)

Parameters

vertexNumber int

The vertex number (0-5 for hexagons, 0-4 for pentagons).

Returns

H3Vertex

The requested H3Vertex.

Exceptions

H3DomainException

vertexNumber is out of range for this cell.

H3InvalidIndexException

This is not a valid H3 cell.

GetVertexes()

Returns the topological vertices of this cell.

public H3Vertex[] GetVertexes()

Returns

H3Vertex[]

The vertices (6 for a hexagon, 5 for a pentagon). Order is not guaranteed.

Exceptions

H3InvalidIndexException

This is not a valid H3 cell.

H3Exception

The native operation failed.

GetVertexesInto(Span<H3Vertex>)

Fills destination with the topological vertices of this cell, packing the non-null vertices to the front.

public int GetVertexesInto(Span<H3Vertex> destination)

Parameters

destination Span<H3Vertex>

The destination span. Its length must be at least 6 (the per-cell maximum).

Returns

int

The number of vertices written to the front of destination (6 for a hexagon, 5 for a pentagon).

Exceptions

ArgumentOutOfRangeException

destination is too small.

H3InvalidIndexException

This is not a valid H3 cell.

H3Exception

The native operation failed.

GridDisk(int)

Returns all cells within grid distance k of this cell (the cell itself plus its k-ring neighborhood).

public H3Index[] GridDisk(int k)

Parameters

k int

The grid distance (number of rings); must be non-negative.

Returns

H3Index[]

The cells in the k-ring, with null padding slots removed. Order is not guaranteed.

Exceptions

ArgumentOutOfRangeException

k is negative, or so large that the result would exceed MaxLength.

H3Exception

The native operation failed.

GridDiskDistances(int)

Returns all cells within grid distance k of this cell paired with their grid distance from this cell, as two parallel arrays where index i in Cells corresponds to index i in Distances.

public (H3Index[] Cells, int[] Distances) GridDiskDistances(int k)

Parameters

k int

The grid distance (number of rings); must be non-negative.

Returns

(H3Index[] Cells, int[] Distances)

A tuple of parallel arrays: the cells in the k-ring (this cell at distance 0) and each cell's grid distance in [0, k], with null padding slots removed. Order is not guaranteed.

Exceptions

ArgumentOutOfRangeException

k is negative, or so large that the result would exceed MaxLength.

H3Exception

The native operation failed.

GridDiskDistancesInto(int, Span<H3Index>, Span<int>)

Fills cells and distances with the cells within grid distance k of this cell and their grid distances, packing the non-null entries in lockstep to the front of both spans.

public int GridDiskDistancesInto(int k, Span<H3Index> cells, Span<int> distances)

Parameters

k int

The grid distance (number of rings); must be non-negative.

cells Span<H3Index>

The destination span for the cells. Its length must be at least the maximum grid-disk size for k (see the upstream maxGridDiskSize).

distances Span<int>

The destination span for the per-cell grid distances; index i here corresponds to index i in cells. Its length must be at least the same maximum grid-disk size.

Returns

int

The number of non-null entries written to the front of both spans.

Exceptions

ArgumentOutOfRangeException

k is negative, so large that the result would exceed MaxLength, or either span is too small.

H3Exception

The native operation failed.

GridDiskInto(int, Span<H3Index>)

Fills destination with the cells within grid distance k of this cell, packing non-null cells to the front.

public int GridDiskInto(int k, Span<H3Index> destination)

Parameters

k int

The grid distance (number of rings); must be non-negative.

destination Span<H3Index>

The destination span. Its length must be at least the maximum grid-disk size for k (see the upstream maxGridDiskSize).

Returns

int

The number of non-null cells written to the front of destination.

Exceptions

ArgumentOutOfRangeException

k is negative, so large that the result would exceed MaxLength, or destination is too small.

H3Exception

The native operation failed.

GridDistance(H3Index)

Returns the grid distance (number of steps along the H3 grid) between this cell and other. The metric is symmetric and reflexive (a cell's distance to itself is 0).

public long GridDistance(H3Index other)

Parameters

other H3Index

The other cell; must be the same resolution as this cell.

Returns

long

The grid distance between the two cells.

Exceptions

H3InvalidIndexException

Either cell is not a valid H3 cell.

H3Exception

The cells are different resolutions, are too far apart, or pentagon distortion prevents a finite distance.

GridPathCells(H3Index)

Returns the line of cells forming the minimal-length grid path from this cell (inclusive) to destination (inclusive).

public H3Index[] GridPathCells(H3Index destination)

Parameters

destination H3Index

The end cell of the path; must be the same resolution as this cell.

Returns

H3Index[]

The ordered path of cells, where the first element is this cell and the last is destination. The path is not necessarily unique near pentagons.

Exceptions

ArgumentOutOfRangeException

The path would exceed MaxLength.

H3Exception

The endpoints are too far apart, are different resolutions, or the path crosses a pentagon or the antimeridian.

GridPathCellsInto(H3Index, Span<H3Index>)

Fills result with the line of cells forming the minimal-length grid path from this cell (inclusive) to destination (inclusive).

public int GridPathCellsInto(H3Index destination, Span<H3Index> result)

Parameters

destination H3Index

The end cell of the path; must be the same resolution as this cell.

result Span<H3Index>

The destination span. Its length must be at least the exact path size (see the upstream gridPathCellsSize); the first written element is this cell and the last is destination.

Returns

int

The number of cells written to the front of result (the exact path length).

Exceptions

ArgumentOutOfRangeException

The path would exceed MaxLength, or result is too small.

H3Exception

The endpoints are too far apart, are different resolutions, or the path crosses a pentagon or the antimeridian.

GridRing(int)

Returns the cells forming the hollow grid ring at exactly grid distance k from this cell (the boundary of the k-ring, excluding the interior). For k = 0 the result is this cell itself.

public H3Index[] GridRing(int k)

Parameters

k int

The grid distance (ring radius); must be non-negative.

Returns

H3Index[]

The cells on the ring, with null padding slots removed (pentagon distortion can leave holes). Order is not guaranteed.

Exceptions

ArgumentOutOfRangeException

k is negative, or so large that the result would exceed MaxLength.

H3InvalidIndexException

This is not a valid H3 cell.

H3Exception

The native operation failed.

GridRingInto(int, Span<H3Index>)

Fills destination with the cells forming the hollow grid ring at exactly grid distance k from this cell, packing non-null cells to the front.

public int GridRingInto(int k, Span<H3Index> destination)

Parameters

k int

The grid distance (ring radius); must be non-negative.

destination Span<H3Index>

The destination span. Its length must be at least the maximum grid-ring size for k (see the upstream maxGridRingSize).

Returns

int

The number of non-null cells written to the front of destination.

Exceptions

ArgumentOutOfRangeException

k is negative, so large that the result would exceed MaxLength, or destination is too small.

H3InvalidIndexException

This is not a valid H3 cell.

H3Exception

The native operation failed.

IsNeighbor(H3Index)

Returns a value indicating whether destination is an adjacent neighbor of this cell.

public bool IsNeighbor(H3Index destination)

Parameters

destination H3Index

The candidate neighbor cell; must be the same resolution as this cell.

Returns

bool

true if the two cells are adjacent neighbors; otherwise false.

Exceptions

H3Exception

Either cell is not valid, or the cells are different resolutions.

IsValidCell()

Returns a value indicating whether the native library considers this a valid H3 cell.

public bool IsValidCell()

Returns

bool

true if this is a valid H3 cell; otherwise false.

IsValidIndex()

Returns a value indicating whether the native library considers this a valid H3 index of any kind: a cell, a directed edge, or a vertex. This is broader than IsValidCell(), which is true only for cells; it returns true for valid edge and vertex indexes even though the typed edge and vertex APIs are introduced in later releases.

public bool IsValidIndex()

Returns

bool

true if this is a valid H3 index (cell, directed edge, or vertex); otherwise false.

LocalIJToCell(CoordIJ)

Returns the cell at the given local IJ coordinates relative to this cell as the anchoring origin. Inverse of CellToLocalIJ(H3Index).

public H3Index LocalIJToCell(CoordIJ ij)

Parameters

ij CoordIJ

The local IJ coordinates relative to this origin.

Returns

H3Index

The cell at ij relative to this origin.

Remarks

This is the inverse of CellToLocalIJ(H3Index), but the round trip is not guaranteed invertible near pentagons or the antimeridian.

Exceptions

H3InvalidIndexException

This origin is not a valid H3 cell.

H3Exception

The IJ coordinates do not resolve to a cell near this origin.

Parse(string)

Parses an H3 index from its hexadecimal string representation.

public static H3Index Parse(string value)

Parameters

value string

The hexadecimal index string (with or without a leading "0x").

Returns

H3Index

The parsed H3Index.

Exceptions

ArgumentNullException

value is null.

FormatException

value is not valid hexadecimal.

ToCanonicalString()

Returns the native library's canonical hexadecimal representation of this index. Unlike ToString(), this is not zero-padded, so it is a variable-length lowercase hex string (the two forms differ only by leading zeros).

public string ToCanonicalString()

Returns

string

The canonical (unpadded) lowercase hexadecimal index string.

Exceptions

H3Exception

The native operation failed.

ToLatLng()

Returns the geographic center of this cell.

public LatLng ToLatLng()

Returns

LatLng

The cell center, in degrees.

Exceptions

H3InvalidIndexException

This is not a valid H3 cell.

ToString()

Returns the lowercase, zero-padded 16-digit hexadecimal representation of this index.

public override string ToString()

Returns

string

The 16-character hexadecimal index string.

TryFromString(string?, out H3Index)

Attempts to parse an H3 index from its hexadecimal string representation using the native library.

public static bool TryFromString(string? value, out H3Index result)

Parameters

value string

The hexadecimal index string.

result H3Index

When this method returns true, the parsed index; otherwise Null.

Returns

bool

true if the native library parsed the string; otherwise false.

TryParse(string?, out H3Index)

Attempts to parse an H3 index from its hexadecimal string representation.

public static bool TryParse(string? value, out H3Index result)

Parameters

value string

The hexadecimal index string (with or without a leading "0x").

result H3Index

When this method returns true, the parsed index; otherwise Null.

Returns

bool

true if parsing succeeded; otherwise false.

UncompactCells(ReadOnlySpan<H3Index>, int)

Uncompacts a mixed-resolution set of cells to the equivalent set at the given uniform resolution. Inverse of CompactCells(ReadOnlySpan<H3Index>).

public static H3Index[] UncompactCells(ReadOnlySpan<H3Index> cells, int resolution)

Parameters

cells ReadOnlySpan<H3Index>

The compacted, mixed-resolution cells.

resolution int

The target uniform resolution (0-15); must be greater than or equal to the finest resolution present in cells.

Returns

H3Index[]

The uncompacted set of cells, all at resolution. Order is not guaranteed.

Exceptions

ArgumentOutOfRangeException

resolution implies a result so large that it would exceed MaxLength.

H3DomainException

resolution is outside the range 0-15.

H3Exception

resolution is finer than the input requires, or the native operation failed.

UncompactCellsInto(ReadOnlySpan<H3Index>, int, Span<H3Index>)

Uncompacts a mixed-resolution set of cells into destination at the given uniform resolution, packing non-null cells to the front. Inverse of CompactCellsInto(ReadOnlySpan<H3Index>, Span<H3Index>).

public static int UncompactCellsInto(ReadOnlySpan<H3Index> cells, int resolution, Span<H3Index> destination)

Parameters

cells ReadOnlySpan<H3Index>

The compacted, mixed-resolution cells.

resolution int

The target uniform resolution (0-15); must be greater than or equal to the finest resolution present in cells.

destination Span<H3Index>

The destination span. Its length must be at least the uncompacted size for resolution (see the upstream uncompactCellsSize).

Returns

int

The number of cells written to the front of destination.

Exceptions

ArgumentOutOfRangeException

resolution implies a result that would exceed MaxLength, or destination is too small.

H3DomainException

resolution is outside the range 0-15.

H3Exception

resolution is finer than the input requires, or the native operation failed.