par_make_h3: Convert H3 indices to sf object

View source: R/gridding.R

par_make_h3R Documentation

Convert H3 indices to sf object

Description

This function converts an input sf to an sf object with H3 hexagons. It requires the h3r package to be installed.

Usage

par_make_h3(x, res = 5L)

Arguments

x

sf object.

res

integer(1). H3 resolution. Default is 5L.

Details

Non-polygon x will be converted to polygons using sf::st_concave_hull. If the input is not convertible to polygons, the function will throw an error.

Value

An sf object with polygons representing the H3 indices.

Author(s)

Insang Song

See Also

Other Parallelization: par_cut_coords(), par_grid(), par_grid_mirai(), par_hierarchy(), par_hierarchy_mirai(), par_make_dggrid(), par_make_grid(), par_merge_grid(), par_multirasters(), par_multirasters_mirai(), par_pad_balanced(), par_pad_grid(), par_split_list()

Examples

lastpar <- par(mfrow = c(1, 1))
library(sf)
if (rlang::is_installed("h3r")) {
library(h3r)
options(sf_use_s2 = FALSE)
ncpath <- system.file("shape/nc.shp", package = "sf")
nc <- read_sf(ncpath)
nc <- st_transform(nc, "EPSG:4326")
# note that it will throw a warning if
# the input is MULTIPOLYGON.
nc_comp_region_h3 <-
  suppressWarnings(
    par_make_h3(
      nc,
      res = 5L
    )
  )
plot(sf::st_geometry(nc_comp_region_h3))
}
par(lastpar)

chopin documentation built on Sept. 10, 2025, 5:08 p.m.