> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kinetica.com/llms.txt
> Use this file to discover all available pages before exploring further.

# H3 Functions

The functions below support various operations using the H3 geospatial indexing scheme.

<AccordionGroup>
  <Accordion title="H3_CELLTOBOUNDARY(h3_index)" id="h3_celltoboundary-h3_index" defaultOpen>
    Returns a POLYGON boundary box of the H3 index identified by the given `h3_index`.

    See [Geohash-H3](/content/snippets/geohash-h3) for an example.
  </Accordion>

  <Accordion title="H3_CELLTOCENTERCHILD(h3_index, res)" id="h3_celltocenterchild-h3_index-res" defaultOpen>
    Alias for `H3_CELLTOFIRSTCHILD`.
  </Accordion>

  <Accordion title="H3_CELLTOCHILDN(h3_index, res, i)" id="h3_celltochildn-h3_index-res-i" defaultOpen>
    Returns the H3 index corresponding to the 0-based `i` th child at resolution `res` for the given
    `h3_index`.  The value `i` should be less than the number of children returned from calling
    `H3_CELLTOCHILDRENSIZE(h3_index, res)`.
  </Accordion>

  <Accordion title="H3_CELLTOCHILDPOS(h3_index, res)" id="h3_celltochildpos-h3_index-res" defaultOpen>
    Returns the position of the given `h3_index` within an ordered list of the children of the cell's
    parent at resolution `res`. This is the inverse of `H3_CHILDPOSTOCELL` (`H3_CELLTOCHILDN`).
  </Accordion>

  <Accordion title="H3_CELLTOCHILDRENSIZE(h3_index, res)" id="h3_celltochildrensize-h3_index-res" defaultOpen>
    Returns the number of child cells at resolution `res` for the given `h3_index`.
  </Accordion>

  <Accordion title="H3_CELLTOFIRSTCHILD(h3_index, res)" id="h3_celltofirstchild-h3_index-res" defaultOpen>
    Returns the H3 index corresponding to the first child at resolution `res` for the given `h3_index`.

    This is equivalent to `H3_CELLTOCHILDN(h3_index,res,0)`.
  </Accordion>

  <Accordion title="H3_CELLTOLASTCHILD(h3_index, res)" id="h3_celltolastchild-h3_index-res" defaultOpen>
    Returns the H3 index corresponding to the last child at resolution `res` for the given `h3_index`.

    This is equivalent to `H3_CELLTOCHILDN(h3_index,res,H3_CELLTOCHILDRENSIZE(h3_index, res)-1)`.
  </Accordion>

  <Accordion title="H3_CELLTOPARENT(h3_index, res)" id="h3_celltoparent-h3_index-res" defaultOpen>
    Returns the H3 index corresponding to the parent cell of the given `h3_index` at resolution `res`.
  </Accordion>

  <Accordion title="H3_CELLTOXY(h3_index)" id="h3_celltoxy-h3_index" defaultOpen>
    Returns a WKT POINT corresponding to the centroid of the given `h3_index`.
  </Accordion>

  <Accordion title="H3_CHILDPOSTOCELL(i, h3_index, res)" id="h3_childpostocell-i-h3_index-res" defaultOpen>
    Alias for `H3_CELLTOCHILDN(h3_index, res, i)`.
  </Accordion>

  <Accordion title="H3_GEOMTOCELL(geom, res)" id="h3_geomtocell-geom-res" defaultOpen>
    Returns the H3 index, similar to a geohash, for the cell containing the centroid of the geometry
    `geom` with the given resolution `res`.  The higher the resolution, the more precise the index
    is. The resolution `res` must be an integer between `0` and `15`.

    See [Geohash-H3](/content/snippets/geohash-h3) for an example.
  </Accordion>

  <Accordion title="H3_GETRESOLUTION(h3_index)" id="h3_getresolution-h3_index" defaultOpen>
    Returns the resolution of the H3 index `h3_index`.
  </Accordion>

  <Accordion title="H3_GRIDDISK(h3_index, k)" id="h3_griddisk-h3_index-k" defaultOpen>
    Returns an array of H3 indexes within a given distance `k` from the provided H3 index `h3_index`.
  </Accordion>

  <Accordion title="H3_GRIDDISKN(h3_index, k, i)" id="h3_griddiskn-h3_index-k-i" defaultOpen>
    Returns the `i` <sup>th</sup> H3 index within a given distance `k` from the provided H3 index
    `h3_index`.  This function would typically be used in conjunction with `H3_NUMGRIDDISK` via iter-join.
    The value of `i` should be between `0` and the result of `H3_NUMGRIDDISK(h3_index, k)` - `1`.
  </Accordion>

  <Accordion title="H3_GRIDRING(h3_index, k)" id="h3_gridring-h3_index-k" defaultOpen>
    Returns an array of H3 indexes comprising a hollow ring at a distance `k` from the provided
    H3 index `h3_index`.
  </Accordion>

  <Accordion title="H3_H3TOSTRING(h3_index)" id="h3_h3tostring-h3_index" defaultOpen>
    Returns the string representation of the H3 index `h3_index`.

    <Info>
      This function is the inverse of `H3_STRINGTOH3`.
    </Info>
  </Accordion>

  <Accordion title="H3_ISVALID(h3_index)" id="h3_isvalid-h3_index" defaultOpen>
    Returns `1` (true) if the given H3 index `h3_index` is a valid H3 index value; otherwise
    returns `0` (false).
  </Accordion>

  <Accordion title="H3_LATLNGTOCELL (latitude, longitude, res)" id="h3_latlngtocell-latitude-longitude-res" defaultOpen>
    Returns the H3 index, similar to a geohash, for the cell containing the `latitude` and `longitude`
    coordinate, with the given resolution `res`.  The higher the resolution, the more precise the index
    is. The resolution `res` must be an integer between `0` and `15`.

    Equivalent to `H3_XYTOCELL(longitude, latitude, res)`.
  </Accordion>

  <Accordion title="H3_NUMGRIDDISK(h3_index, k)" id="h3_numgriddisk-h3_index-k" defaultOpen>
    Returns the number of cells at a distance of `k` from the provided H3 index `h3_index`. This function
    would typically be used in conjunction with `H3_GRIDDISKN` via iter-join.
  </Accordion>

  <Accordion title="H3_NUMPOLYGONTOCELLS(geom, res)" id="h3_numpolygontocells-geom-res" defaultOpen>
    Returns the number of cells at the given resolution `res` that are within the given geometry `geom`.
    Only polygon geometries are supported. This function would typically be used in conjunction with
    `H3_POLYGONTOCELLSN` via iter-join.
  </Accordion>

  <Accordion title="H3_POLYGONTOCELLS(geom, res)" id="h3_polygontocells-geom-res" defaultOpen>
    Returns an array of H3 indexes at the given resolution `res` that are within the given geometry `geom`.
    Only polygon geometries are supported.
  </Accordion>

  <Accordion title="H3_POLYGONTOCELLSN(geom, res, i)" id="h3_polygontocellsn-geom-res-i" defaultOpen>
    Returns the `i` <sup>th</sup> H3 index at the given resolution `res` that is within the given geometry
    `geom`.  Only polygon geometries are supported. This function would typically be used in conjunction with
    `H3_NUMPOLYGONTOCELLS` via iter-join. The value of `i` should be between `0` and the value returned
    from `H3_NUMPOLYGONTOCELLS(geom, res)` - `1`.
  </Accordion>

  <Accordion title="H3_STRINGTOH3(h3_string)" id="h3_stringtoh3-h3_string" defaultOpen>
    Returns the H3 index corresponding to the string representation `h3_string`.

    <Info>
      This function is the inverse of `H3_H3TOSTRING`.
    </Info>
  </Accordion>

  <Accordion title="H3_XYTOCELL(x, y, res)" id="h3_xytocell-x-y-res" defaultOpen>
    Returns the H3 index, similar to a geohash, for the cell containing the `x` and `y` coordinate,
    with the given resolution `res`.  The higher the resolution, the more precise the index is. The
    resolution `res` must be an integer between `0` and `15`.

    Equivalent to `H3_LATLNGTOCELL(y, x, res)`.

    See [Geohash-H3](/content/snippets/geohash-h3) for an example.
  </Accordion>
</AccordionGroup>
