Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

get_local_h3

Get H3 cell from local i, j coordinates


Description

This function returns H3 destination cells for local i, j coordinate pairs anchored by an H3 origin cell.

Usage

get_local_h3(origin = NULL, i = NULL, j = NULL, simple = TRUE)

Arguments

origin

Character; 15-character cell index generated by H3. A vector of indexes can also be supplied.

i

a single i coordinate or vector of same, generated by get_local_ij

j

a single j coordinate or vector of same, generated by get_local_ij

simple

Logical; whether to return a vector of outputs or a data frame containing both inputs and outputs.

Value

If 'simple = TRUE', a character vector of destination H3 cells. If not, a data frame containing columns origin, i, j, destination.

Note

  • 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 cell.

  • Failure may occur if the destination is too far away from the origin or if the destination is on the other side of a pentagon.

  • This function is experimental, and its output is not guaranteed to be compatible across different versions of H3.

Examples

# Get local coordinates for a nearby cell
local <- get_local_ij(origin = '86be8d12fffffff', destination = '86be8d127ffffff')

# Convert back to destination cell
get_local_h3(origin = '86be8d12fffffff', i = local[, 1], j = local[, 2])

h3jsr

Access Uber's H3 Library

v1.2.2
Apache License (>= 2)
Authors
Lauren O'Brien [aut, cre] (<https://orcid.org/0000-0002-7336-2171>)
Initial release
2021-06-16

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.