https://github.com/crazycapivara/h3forr
An R Interface to H3 via V8 and h3-js
https://github.com/crazycapivara/h3forr
h3 hexagon hexagonal-hierachical-spatial-index r r-bindings spatial spatial-index
Last synced: 3 months ago
JSON representation
An R Interface to H3 via V8 and h3-js
- Host: GitHub
- URL: https://github.com/crazycapivara/h3forr
- Owner: crazycapivara
- License: other
- Created: 2018-11-17T21:55:38.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-13T23:00:48.000Z (over 2 years ago)
- Last Synced: 2025-05-12T20:54:09.293Z (5 months ago)
- Topics: h3, hexagon, hexagonal-hierachical-spatial-index, r, r-bindings, spatial, spatial-index
- Language: R
- Homepage:
- Size: 1.87 MB
- Stars: 11
- Watchers: 2
- Forks: 3
- Open Issues: 14
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# h3forr[](https://travis-ci.org/crazycapivara/h3forr) [](https://www.repostatus.org/#active)
[](https://github.com/uber/h3/releases/tag/v3.7.0)
[](https://github.com/crazycapivara/h3forr/actions)Provides R bindings for [H3](https://uber.github.io/h3/), a hexagonal hierarchical spatial indexing system, via [V8](https://github.com/jeroen/V8) and [h3-js](https://github.com/uber/h3-js).
See [h3-r](https://github.com/crazycapivara/h3-r) for R bindings to the H3 C library.

## Installation
You can install h3forr from github with:
``` r
# install.packages("remotes")
remotes::install_github("crazycapivara/h3forr")
```## Quickstart
Core functions:
```{r example}
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:
```{r algorithms}
(neighbors <- k_ring(h3_index, ring_size = 1))h3_to_geo_boundary(neighbors) %>%
geo_boundary_to_sf()h3_set_to_multi_polygon(neighbors)
```