View source: R/custom_fuctions.R
cell_to_line | R Documentation |
Return line geometry for a sequence of H3 cell indexes in WGS84 coordinates.
cell_to_line(input = NULL, simple = TRUE) ## S3 method for class 'data.frame' cell_to_line(input = NULL, simple = TRUE) ## S3 method for class 'list' cell_to_line(input = NULL, simple = TRUE) ## S3 method for class 'character' cell_to_line(input = NULL, simple = TRUE)
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
|
simple |
Logical; whether to return an |
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.
This function can accept any arbitrary vector of cell indexes (including cells at multiple resolutions) but results may be unexpected. It is assumed that indexes are supplied in a pre-ordered fashion.
# 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) ## Not run: plot(hex_sample_polys, reset = FALSE) plot(brisbane_hex_10, add = TRUE) plot(lines, col = 'red', add = TRUE) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.