local_options <- options() library(sf) library(dplyr) library(ggplot2) library(h3jsr) # for R < 4, since H3 addresses are handled as strings options(stringsAsFactors = FALSE)
h3-js. The library has extensive potential applications in network analysis, trip routing, and geospatial data aggregation. The wrapper functions provided are intended to interface well with the existing R-spatial ecosystem, particularly
sf::st_transform()and a message is issued.
h3jsr, the default behaviour is to return data in as simple a structure as is practical, but there is always an option to return a more complex-object containing both input and output data, as appropriate for the function in question.
V8to interface with
h3-js. As such, a lot of the overhead for each function call is related to sending data to and from V8 via JSON conversion. Feeding large datasets in often gives faster results than one might expect from the toy examples below. Avoid using these functions in conjunction with e.g.
purrr::mapon individual geometries!
Nine core functions exist - three for translating spatial data into and out of the H3 system, and six information utilities, including an address validity checker.
point_to_h3() takes in
sf-style point data and will return the address each point falls into. You can extract addresses for on