-
Notifications
You must be signed in to change notification settings - Fork 5
/
README.Rmd
90 lines (62 loc) · 2.81 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-",
warning = FALSE
)
```
[![R build status](https://github.com/obrl-soil/h3jsr/workflows/R-CMD-check/badge.svg)](https://github.com/obrl-soil/h3jsr/actions)
[![R build status](https://github.com/obrl-soil/h3jsr/workflows/test-coverage/badge.svg)](https://github.com/obrl-soil/h3jsr/actions)
[![R build status](https://github.com/obrl-soil/h3jsr/workflows/pkgdown/badge.svg)](https://github.com/obrl-soil/h3jsr/actions)
[![Coverage status](https://codecov.io/gh/obrl-soil/h3jsr/branch/master/graph/badge.svg)](https://codecov.io/github/obrl-soil/h3jsr?branch=master)
[![CRAN](https://www.r-pkg.org/badges/version/h3jsr)](https://cran.r-project.org/package=h3jsr)
[![Downloads](https://cranlogs.r-pkg.org/badges/grand-total/h3jsr)](https://www.r-pkg.org/pkg/h3jsr)
# h3jsr
h3jsr provides access to [Uber's H3 library](https://github.com/uber/h3) via its [javascript transpile](https://github.com/uber/h3-js), using the magical power of [`V8`](https://github.com/jeroen/v8).
H3 is a hexagonal hierarchical geospatial indexing system. Details about its structure and use cases [can be found here](https://h3geo.org/docs/).
## Installation
Install from CRAN with
```{r 'installation1', eval = FALSE}
install.packages('h3jsr')
```
Install the development version from GitHub with
```{r 'installation2', eval = FALSE}
remotes::install_github("obrl-soil/h3jsr")
```
> :bulb: Version (v1.3.0) contains an API revision, so some functions have new names. See the NEWS.
## Example
```{r example}
library(h3jsr)
library(sf)
# where is the Brisbane Town Hall at resolution 15?
bth <- st_sfc(st_point(c(153.023503, -27.468920)), crs = 4326)
point_to_cell(bth, res = 15)
# where is it at several resolutions?
point_to_cell(bth, res = seq(10, 15), simple = FALSE)
# Where is the center of the hexagon over the Brisbane Town
# Hall at resolution 10?
brisbane_10 <- cell_to_point(h3_address = '8abe8d12acaffff')
brisbane_10
# Is that a valid H3 address?
is_valid(h3_address = '8abe8d12acaffff')
# is it a pentagon?
is_pentagon(h3_address = '8abe8d12acaffff')
# is it Class III?
is_rc3(h3_address = '8abe8d12acaffff')
# What is Brisbane Town Hall's base cell number?
get_base_cell(h3_address = '8abe8d12acaffff')
# What is the hexagon over the Brisbane Town Hall at resolution 10?
brisbane_hex_10 <- cell_to_polygon(input = '8abe8d12acaffff', simple = FALSE)
# if you're feeling fancy,
# point_to_cell(bth, res = seq(10,15)) %>%
# unlist() %>%
# h3_to_polygon(., simple = FALSE) %>%
# mapview::mapview()
```
Props to Joel Gombin, who's package [`concaveman`](https://github.com/joelgombin/concaveman) provided me with the implementation inspo.
***