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

grid_path

Path between H3 cells


Description

This function returns a path of H3 cells between a start and end cell (inclusive).

Usage

grid_path(origin = NULL, destination = NULL, simple = TRUE)

Arguments

origin

Character vector or list of 15-character indices generated by H3.

destination

Character vector or list of 15-character indices generated by H3.

simple

Logical; whether to return a vector of outputs or a list object containing both inputs and outputs.

Value

A vector of h3 cells of form c(origin, c(path), destination).

Note

  • Input H3 cells must be of the same resolution or results cannot be computed. This function may fail to find the distance between two indexes if they are very far apart or on opposite sides of a pentagon.

  • The specific output of this function should not be considered stable across library versions. The only guarantees the library provides are that the line length will be 'h3_distance(start, end) + 1' and that every index in the line will be a neighbor of the preceding index.

  • Lines are drawn in grid space, and may not correspond exactly to either Cartesian lines or great arcs

Examples

## Not run: 
nc <- sf::st_read(system.file("shape/nc.shp", package="sf"), quiet = TRUE)
nc_pts <- sf::st_centroid(nc[c(1, 2), ])
nc_6 <- point_to_h3(nc_pts, res = 6)
# find a path between these two addresses:
grid_path(nc_6[1], nc_6[2], simple = TRUE)


## End(Not run)

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.