Learn R Programming

h3jsr (version 1.3.1)

cell_to_line: Convert H3 cell indexes to a line

Description

Return line geometry for a sequence of H3 cell indexes in WGS84 coordinates.

Usage

cell_to_line(input = NULL, simple = TRUE)

# S3 method for data.frame cell_to_line(input = NULL, simple = TRUE)

# S3 method for list cell_to_line(input = NULL, simple = TRUE)

# S3 method for character cell_to_line(input = NULL, simple = TRUE)

Value

An sfc_LINESTRING object containing a line for each vector of H3 cell indexes supplied. If simple = FALSE, an sf object including the input data.

Arguments

input

Character vector of 15-character indexes generated by H3, a list of such, or a data frame where the last column is a list-column of H3 cell indexes (usually the output of h3jsr::grid_path().

simple

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

Examples

Run this code
# What is the cell index over the Brisbane Town Hall at resolution 10?
brisbane_hex_10 <- cell_to_polygon(input = '8abe8d12acaffff')

# Give me a some nearby cells
hex_sample <- get_disk_list('8abe8d12acaffff', 4)[[1]][[4]][seq(1,18,3)]
hex_sample_polys <- cell_to_polygon(hex_sample)

# find connecting paths
paths <- grid_path(rep('8abe8d12acaffff', 6), hex_sample)

# make lines
lines <- cell_to_line(paths)

if (FALSE) {
plot(hex_sample_polys, reset = FALSE)
plot(brisbane_hex_10, add = TRUE)
plot(lines, col = 'red', add = TRUE)
}

Run the code above in your browser using DataLab