Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

h3 to sf helper #39

Open
JosiahParry opened this issue Jun 21, 2021 · 2 comments
Open

h3 to sf helper #39

JosiahParry opened this issue Jun 21, 2021 · 2 comments

Comments

@JosiahParry
Copy link

I think it would be useful to have a helper function to convert a tibble with many h3 indexes into a single sf object.

Presently, h3_to_geo_bounardy_sf() works well with a vector. However it is less friendly when starting with a tibble. As such I think a helper function such as the below would be useful. See below reprex to get a sense of envisioned flow.

library(h3)
library(tidyverse)

# helper function
add_boundary <- function(data, h3_index) {
  cbind(data, h3_to_geo_boundary_sf(data[[quote(h3_index)]])) %>% 
    sf::st_as_sf()
}


k_ring_distances("842a307ffffffff", 3) %>% 
  add_boundary(h3_index) %>% 
  ggplot(aes(fill = distance)) +
  geom_sf(color = "black", lwd = 0.2) +
  theme_minimal()

image

@crazycapivara
Copy link
Owner

@JosiahParry We can use a S3 method h3_to_geo_boundary_sf.data.frame for this.

@crazycapivara
Copy link
Owner

#31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants