Struct H3Index
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
ValueulongThe raw 64-bit H3 index value.
Properties
BaseCellNumber
Gets the base cell number (0-121) of this cell.
public int BaseCellNumber { get; }
Property Value
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
IsPentagon
Gets a value indicating whether this cell is one of the twelve pentagons at its resolution.
public bool IsPentagon { get; }
Property Value
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
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
Resolution
Gets the resolution (0-15) of this cell.
public int Resolution { get; }
Property Value
Exceptions
- H3InvalidIndexException
This is not a valid H3 cell.
Value
The raw 64-bit H3 index value.
public ulong Value { get; init; }
Property Value
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
childResolutionintThe target child resolution (0-15); must be greater than or equal to this cell's resolution.
Returns
Exceptions
- H3DomainException
childResolutionis outside the range 0-15.- H3Exception
childResolutionis 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
parentResolutionintThe 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
parentResolutionis outside the range 0-15.- H3Exception
parentResolutionis 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
childResolutionintThe 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
childResolutionimplies a result so large that it would exceed MaxLength.- H3DomainException
childResolutionis outside the range 0-15.- H3Exception
childResolutionis 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
childResolutionintThe target child resolution (0-15); must be greater than or equal to this cell's resolution.
destinationSpan<H3Index>The destination span. Its length must be at least the maximum child count for
childResolution(see the upstreamcellToChildrenSize).
Returns
- int
The number of non-null child cells written to the front of
destination.
Exceptions
- ArgumentOutOfRangeException
childResolutionimplies a result that would exceed MaxLength, ordestinationis too small.- H3DomainException
childResolutionis outside the range 0-15.- H3Exception
childResolutionis 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
targetH3IndexThe 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,
targetis 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
parentResolutionintThe target parent resolution (0-15); must be less than or equal to this cell's resolution.
Returns
Exceptions
- H3DomainException
parentResolutionis outside the range 0-15.- H3Exception
parentResolutionis 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
childPositionlongThe zero-based child position, in
[0, cellToChildrenSize).childResolutionintThe child resolution (0-15); must be greater than or equal to this cell's resolution.
Returns
Exceptions
- H3DomainException
childResolutionis outside the range 0-15, orchildPositionis outside the valid range.- H3Exception
childResolutionis 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
cellsReadOnlySpan<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
cellsReadOnlySpan<H3Index>The cells to compact. All must be the same resolution and duplicate-free.
destinationSpan<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
destinationis 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
resolutionintThe target resolution (0-15).
baseCellNumberintThe base cell number (0-121).
digitsReadOnlySpan<int>The indexing digits (each 0-6), one per resolution. Its length must equal
resolution.
Returns
Exceptions
- ArgumentException
The length of
digitsdoes not equalresolution.- 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
destinationH3IndexThe 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
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
valuestringThe hexadecimal index string.
Returns
Exceptions
- ArgumentNullException
valueis null.- H3Exception
valuecould 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
destinationSpan<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
destinationis 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
resolutionintThe H3 resolution (0-15).
Returns
- double
The average hexagon area at
resolution, in square kilometers.
Exceptions
- H3DomainException
resolutionis 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
resolutionintThe H3 resolution (0-15).
Returns
- double
The average hexagon area at
resolution, in square meters.
Exceptions
- H3DomainException
resolutionis 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
resolutionintThe H3 resolution (0-15).
Returns
- double
The average hexagon edge length at
resolution, in kilometers.
Exceptions
- H3DomainException
resolutionis 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
resolutionintThe H3 resolution (0-15).
Returns
- double
The average hexagon edge length at
resolution, in meters.
Exceptions
- H3DomainException
resolutionis 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
destinationSpan<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
destinationis 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
resolutionintThe 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
resolutionis 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
resolutionintThe H3 resolution (0-15).
Returns
- long
The number of cells at
resolution(122 at resolution 0).
Exceptions
- H3DomainException
resolutionis outside the range 0-15.
GetPentagons(int)
Returns the 12 pentagon cells at the given resolution.
public static H3Index[] GetPentagons(int resolution)
Parameters
resolutionintThe H3 resolution (0-15).
Returns
- H3Index[]
The 12 pentagons at
resolution. Order is not guaranteed.
Exceptions
- H3DomainException
resolutionis 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
resolutionintThe H3 resolution (0-15).
destinationSpan<H3Index>The destination span. Its length must be at least 12.
Returns
- int
The number of pentagons written (always 12).
Exceptions
- ArgumentException
destinationis smaller than 12.- H3DomainException
resolutionis 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
Returns
- int
The number of cells written (always 122).
Exceptions
- ArgumentException
destinationis 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
vertexNumberintThe vertex number (0-5 for hexagons, 0-4 for pentagons).
Returns
Exceptions
- H3DomainException
vertexNumberis 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
destinationSpan<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
destinationis 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
kintThe 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
kis 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
kintThe 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
kis 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
kintThe grid distance (number of rings); must be non-negative.
cellsSpan<H3Index>The destination span for the cells. Its length must be at least the maximum grid-disk size for
k(see the upstreammaxGridDiskSize).distancesSpan<int>The destination span for the per-cell grid distances; index
ihere corresponds to indexiincells. 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
kis 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
kintThe grid distance (number of rings); must be non-negative.
destinationSpan<H3Index>The destination span. Its length must be at least the maximum grid-disk size for
k(see the upstreammaxGridDiskSize).
Returns
- int
The number of non-null cells written to the front of
destination.
Exceptions
- ArgumentOutOfRangeException
kis negative, so large that the result would exceed MaxLength, ordestinationis 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
otherH3IndexThe 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
destinationH3IndexThe 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
destinationH3IndexThe end cell of the path; must be the same resolution as this cell.
resultSpan<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 isdestination.
Returns
- int
The number of cells written to the front of
result(the exact path length).
Exceptions
- ArgumentOutOfRangeException
The path would exceed MaxLength, or
resultis 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
kintThe 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
kis 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
kintThe grid distance (ring radius); must be non-negative.
destinationSpan<H3Index>The destination span. Its length must be at least the maximum grid-ring size for
k(see the upstreammaxGridRingSize).
Returns
- int
The number of non-null cells written to the front of
destination.
Exceptions
- ArgumentOutOfRangeException
kis negative, so large that the result would exceed MaxLength, ordestinationis 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
destinationH3IndexThe candidate neighbor cell; must be the same resolution as this cell.
Returns
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
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
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
ijCoordIJThe local IJ coordinates relative to this origin.
Returns
- H3Index
The cell at
ijrelative 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
valuestringThe hexadecimal index string (with or without a leading "0x").
Returns
Exceptions
- ArgumentNullException
valueis null.- FormatException
valueis 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
valuestringThe hexadecimal index string.
resultH3IndexWhen this method returns true, the parsed index; otherwise Null.
Returns
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
valuestringThe hexadecimal index string (with or without a leading "0x").
resultH3IndexWhen this method returns true, the parsed index; otherwise Null.
Returns
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
cellsReadOnlySpan<H3Index>The compacted, mixed-resolution cells.
resolutionintThe 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
resolutionimplies a result so large that it would exceed MaxLength.- H3DomainException
resolutionis outside the range 0-15.- H3Exception
resolutionis 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
cellsReadOnlySpan<H3Index>The compacted, mixed-resolution cells.
resolutionintThe target uniform resolution (0-15); must be greater than or equal to the finest resolution present in
cells.destinationSpan<H3Index>The destination span. Its length must be at least the uncompacted size for
resolution(see the upstreamuncompactCellsSize).
Returns
- int
The number of cells written to the front of
destination.
Exceptions
- ArgumentOutOfRangeException
resolutionimplies a result that would exceed MaxLength, ordestinationis too small.- H3DomainException
resolutionis outside the range 0-15.- H3Exception
resolutionis finer than the input requires, or the native operation failed.