knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
Provides R bindings for H3, a hexagonal hierarchical spatial indexing system, via V8 and h3-js.
See h3-r for R bindings to the H3 C library.
You can install h3forr from github with:
# install.packages("remotes") remotes::install_github("crazycapivara/h3forr")
Core functions:
library(h3forr) # Convert a lat/lng point to a hexagon index at resolution 7 coords <- c(37.3615593, -122.0553238) (h3_index <- geo_to_h3(coords, res = 7)) # Get the center of the hexagon h3_to_geo(h3_index) # Get the vertices of the hexagon h3_to_geo_boundary(h3_index, format_as_geojson = FALSE)
Useful algorithms:
(neighbors <- k_ring(h3_index, ring_size = 1)) h3_to_geo_boundary(neighbors) %>% geo_boundary_to_sf() h3_set_to_multi_polygon(neighbors)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.