Returns the area of each cell in square kilometers. For ISEA grids, all cells have the same area (equal-area property). For H3 grids, each cell has a different geodesic area depending on its location.
Details
For ISEA grids the area is constant across all cells and is read directly from the grid specification.
For H3 grids the area varies by latitude. This function computes geodesic
area via sf::st_area() on H3 cell polygons, with results cached in a
session-scoped environment so repeated calls for the same cells are fast.
See also
hex_grid for grid specifications,
h3_crosswalk for ISEA/H3 interoperability
Examples
# ISEA: constant area
grid <- hex_grid(area_km2 = 1000)
cells <- lonlat_to_cell(c(0, 10, 20), c(45, 50, 55), grid)
cell_area(cells, grid)
# H3: area varies by location
# \donttest{
h3 <- hex_grid(resolution = 5, type = "h3")
h3_cells <- lonlat_to_cell(c(0, 0), c(0, 80), h3)
cell_area(h3_cells, h3) # equator vs polar — different areas
# }