Prepare Geographic Boundaries

Published

September 25, 2023

Setup

library(tidyverse)
library(sf)
library(rnaturalearth)

Prepare maps

  • All use CRS of 3347 from [Statistics Canada]
  • According to All About Birds, shouldn’t be breeding outside of Canada or US

Therefore use only North America, and, further, only BCRs that overlap breeding range.

Base map

base_map <- ne_states(country = c("United States of America", "Canada"),
                      returnclass = "sf")

# Let's use a smaller range
crop_to <- st_bbox(c(xmin = -135, xmax = -92, ymin = 24.54, ymax = 60))
base_map <- st_crop(base_map, crop_to) |>
  st_make_valid() |>
  summarize() |>
  st_transform(3347)
Warning: attribute variables are assumed to be spatially constant throughout
all geometries
write_rds(base_map, "Data/Datasets/base_map.rds")

BCR maps

Bird Studies Canada and NABCI. 2014. Bird Conservation Regions. Published by Bird Studies Canada on behalf of the North American Bird Conservation Initiative. https://birdscanada.org/bird-science/nabci-bird-conservation-regions Accessed: 2023-09-25

Download and extract the data

download.file("https://birdscanada.org/download/gislab/bcr_terrestrial_shape.zip",
              destfile = "Data/bcr_maps.zip")
unzip("Data/bcr_maps.zip", exdir = "Data/")

Filter to relevant BCRs

bcr <- st_read("Data/BCR_Terrestrial/BCR_Terrestrial_master.shp") |>
  st_transform(3347) |>     # Stats Canada CRS
  rename_with(tolower) |>   # Lower case column names
  filter(bcr %in% c(9, 10, 11, 15, 16, 17, 18, 19)) |> # filter to relevant
  # Fix labels
  mutate(bcr = paste0(bcr,  " - ", str_to_title(bcrname)),
         bcr = factor(bcr, levels = unique(bcr)),
         province = str_to_title(province_s)) |>
  select(bcr, province, country)
Reading layer `BCR_Terrestrial_master' from data source 
  `/home/steffi/Projects/Business/Matt/lb_curlew_distribution/Data/BCR_Terrestrial/BCR_Terrestrial_master.shp' 
  using driver `ESRI Shapefile'
Simple feature collection with 373 features and 11 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: -179.1413 ymin: 14.53287 xmax: 179.7785 ymax: 83.11063
Geodetic CRS:  NAD83
write_rds(bcr, "Data/Datasets/bcr_map.rds")

BCRs

ggplot() +
  theme_bw() +
  geom_sf(data = base_map, colour = "grey80") +
  geom_sf(data = bcr, aes(fill = bcr)) +
  scale_fill_viridis_d(name = "Bird Conservation Region")

British Columbia

ggplot() +
  theme_bw() +
  geom_sf(data = base_map, colour = "grey80") +
  geom_sf(data = filter(bcr, province == "British Columbia"), 
          aes(fill = province)) +
  scale_fill_viridis_d(name = "Province")