| h3_crosswalk | R Documentation |
Maps cell IDs between ISEA (equal-area) and H3 grid systems by looking up each cell's center coordinate in the target grid. This enables workflows where analysis is done in ISEA (exact equal-area) and reporting in H3 (industry-standard).
h3_crosswalk(
cell_id = NULL,
grid,
h3_resolution = NULL,
isea_grid = NULL,
direction = c("isea_to_h3", "h3_to_isea")
)
cell_id |
Cell IDs to translate. Numeric for ISEA, character for H3.
When |
grid |
A HexGridInfo or HexData object. For |
h3_resolution |
Target H3 resolution for |
isea_grid |
A HexGridInfo for the target ISEA grid. Required when
|
direction |
One of |
The crosswalk works by computing the center coordinate of each source cell, then finding which cell in the target grid contains that center. This is a many-to-one mapping: multiple ISEA cells may map to the same H3 cell (or vice versa) depending on the relative resolutions.
When h3_resolution is NULL and direction = "isea_to_h3",
the H3 resolution whose average cell area is closest to the ISEA cell area
is chosen automatically. This gives the best 1:1 correspondence.
A data frame with columns:
ISEA cell ID (numeric)
H3 cell ID (character)
Area of the ISEA cell in km2
Geodesic area of the H3 cell in km2
Ratio of ISEA area to H3 area
cell_area for per-cell area computation,
hex_grid for creating grids
# ISEA -> H3
grid <- hex_grid(area_km2 = 1000)
cells <- lonlat_to_cell(c(0, 10, 20), c(45, 50, 55), grid)
xwalk <- h3_crosswalk(cells, grid)
head(xwalk)
# H3 -> ISEA
h3 <- hex_grid(resolution = 5, type = "h3")
h3_cells <- lonlat_to_cell(c(0, 10), c(45, 50), h3)
xwalk2 <- h3_crosswalk(h3_cells, h3, isea_grid = grid, direction = "h3_to_isea")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.