knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

h3forr

Travis build status Project Status: Active – The project has reached a stable, usable state and is being actively developed. H3 Version R build status

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.

Installation

You can install h3forr from github with:

# install.packages("remotes")
remotes::install_github("crazycapivara/h3forr")

Quickstart

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)


crazycapivara/h3forr documentation built on Dec. 6, 2020, 5:21 a.m.