bcgov / bcmaps

An R package of map layers for British Columbia
http://bcgov.github.io/bcmaps/
Apache License 2.0
73 stars 17 forks source link

Create `bc_neighbours` from bcdata #59

Closed stephhazlitt closed 4 years ago

stephhazlitt commented 4 years ago
library(bcdata)
library(sf)

coords = list(matrix(c(-142, 59.9,
                       -137.69, 47,
                       -114.31, 47,
                       -110, 59.9,
                       -142, 59.9),
                     ncol = 2,
                     byrow = TRUE))

outside_bc_box <- st_polygon(coords) %>%
  st_sfc(crs = 4326) %>%
  st_transform(3005) %>% 
  st_bbox()

bc_neighbours <- bcdc_query_geodata('b9bd93e1-0226-4351-b943-05c6f80bd5da') %>% 
  filter(BBOX(c(109930.2, 294451.3, 1890069.8, 1758438.9))) %>% 
  collect()

plot(bc_neighbours)