| h3_from_xy | R Documentation |
Create H3 indices from sfc objects, vectors of x and y coordinates, or H3 string IDs.
h3_from_xy(x, y, resolution)
h3_from_points(x, resolution)
h3_from_strings(x)
h3_to_points(x)
h3_to_vertexes(x)
## S3 method for class 'H3'
as.character(x, ...)
flatten_h3(x)
is_h3(x)
x |
for |
y |
a numeric vector of latitudes. |
resolution |
an integer indicating the H3 cell resolution. Must be between 0 and 15 inclusive. |
... |
unused. |
h3_from_points(): takes an sfc_POINT object and creates a vector of H3 cells
h3_from_strings(): converts a character vector of cell indexes to an H3 vector
h3_from_xy(): converts vectors of x and y coordinates to an H3 vector
h3_to_points(): converts an H3 vector to a either an sfc_POINT object or a list of sfg POINT objects.
h3_to_vertexes(): converts an H3 vector to an sfc_MULTIPOINT object or a list of MULTIPOINT objects.
See details.
h3_from_xy(-90, 120, 5)
h3_from_strings("85f29383fffffff")
if (requireNamespace("sf")) {
# create random points
pnts <- sf::st_cast(
sf::st_sfc(
sf::st_multipoint(matrix(runif(10, max = 90), ncol = 2)),
crs = 4326
),
"POINT"
)
# convert to H3 objects
h3s <- h3_from_points(pnts, 5)
h3_to_vertexes(h3s)
h3_to_points(h3s)
}
h3_ids <- c("831f91fffffffff", "831fb5fffffffff", "831f94fffffffff")
flatten_h3(
list(
NULL,
h3_from_strings(h3_ids),
h3_from_strings(h3_ids[1])
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.