These functions calculate the area of H3 cells for a given unit.
area_km2()calculates the area in kilometers squaredarea_m2()calculates the area in meters squaredarea_rads2()calculates the area in radians squared
Arguments
- x
for
h3_from_points()an object of classsfc_POINT. Forh3_from_strings()a character vector of H3 index IDs. Forh3_from_xy()a numeric vector of longitudes.
Examples
nc <- sf::st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE)
geo <- sf::st_geometry(nc)
cells <- sfc_to_cells(geo, 5) |>
flatten_h3()
head(area_km2(cells))
#> [1] 230.8037 231.5341 231.3662 230.6341 231.1934 231.7500
head(area_m2(cells))
#> [1] 230803680 231534107 231366169 230634132 231193430 231749967
head(area_rads2(cells))
#> [1] 5.686258e-06 5.704253e-06 5.700116e-06 5.682081e-06 5.695860e-06
#> [6] 5.709571e-06