Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

h3_to_polygon

Get the boundary of an H3 cell index


Description

This function takes an H3 cell index and returns its bounding shape (usually a hexagon) in WGS84.

Usage

h3_to_polygon(input = NULL, simple = TRUE)

Arguments

input

Character; 15-character index generated by H3, or a vector or list of same, or a data frame where the first column contains H3 addresses.

simple

Logical; whether to return an 'sfc_POLYGON' object or an 'sf' data frame containing both inputs and outputs.

Value

By default, an 'sfc_POLYGON' object of 'length(input)'. If an appropriately formatted data frame is supplied, an 'sf' data frame containing input attributes and geometry.

Examples

# What is the hexagon over the Brisbane Town Hall at resolution 10?
brisbane_hex_10 <- h3_to_polygon(input = '8abe8d12acaffff')

# Give me some of the cells over Brisbane Town Hall as an sf object
bth <- sf::st_sfc(sf::st_point(c(153.023503, -27.468920)), crs = 4326)
bth_addys <- unlist(point_to_h3(bth, res = seq(10, 15)), use.names = FALSE)
bth_hexes <- h3_to_polygon(input = bth_addys)
plot(bth_hexes, axes = TRUE)

h3jsr

Access Uber's H3 Library

v1.2.2
Apache License (>= 2)
Authors
Lauren O'Brien [aut, cre] (<https://orcid.org/0000-0002-7336-2171>)
Initial release
2021-06-16

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.