Libraries
library(sf)
## Linking to GEOS 3.11.2, GDAL 3.7.2, PROJ 9.3.0; sf_use_s2() is TRUE
library(terra)
## terra 1.7.71
library(mapview)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.4.4 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.0
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ tidyr::extract() masks terra::extract()
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(bcmaps)
## Support for Spatial objects (`sp`) was removed in {bcmaps} v2.0.0. Please use `sf` objects with {bcmaps}.
library(units)
## udunits database from C:/Users/TRU/AppData/Local/R/win-library/4.3/units/share/udunits/udunits2.xml
Shape Wells Gray
wg <- st_read("WellsGray_Park.shp")
## Reading layer `WellsGray_Park' from data source
## `C:\Users\TRU\Documents\R\Wells Gray\WellsGray_Park.shp' using driver `ESRI Shapefile'
## Simple feature collection with 1 feature and 16 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: 1368858 ymin: 755755.8 xmax: 1444935 ymax: 890470.9
## Projected CRS: NAD83 / BC Albers
set_units(st_area(wg), "ha")
## 540412.8 [ha]
BEC Wells Gray 2024
wg_bec <- bec() %>%
st_intersection(wg) %>%
mutate(area = set_units(st_area(.), "ha")) %>%
filter(area > set_units(0.1, "ha"))
## bec was updated on 2024-04-04
## Warning: attribute variables are assumed to be spatially constant throughout
## all geometries
plot(wg_bec["ZONE"])

mapview(wg_bec, zcol = "ZONE")
BEC Wells Gray 2011-2040 (ssp245)
BEC_wg_2011_2040 <- st_read("BEC_2011-2040.shp")
## Reading layer `BEC_2011-2040' from data source
## `C:\Users\TRU\Documents\R\Wells Gray\BEC_2011-2040.shp' using driver `ESRI Shapefile'
## Simple feature collection with 7 features and 3 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: 1368858 ymin: 759456.7 xmax: 1444935 ymax: 890470.9
## Projected CRS: NAD83 / BC Albers
set_units(st_area(BEC_wg_2011_2040), "ha")
## Units: [ha]
## [1] 109.3436 109.3436 5139.1507 30944.2480 230605.7209 272921.7066
## [7] 382.7027
plot(BEC_wg_2011_2040["Zone"])

mapview(BEC_wg_2011_2040, zcol = "Zone")
BEC Wells Gray 2071-2100 (ssp245)
BEC_wg_2071_2100 <- st_read("BEC_2071-2100.shp")
## Reading layer `BEC_2071-2100' from data source
## `C:\Users\TRU\Documents\R\Wells Gray\BEC_2071-2100.shp' using driver `ESRI Shapefile'
## Simple feature collection with 8 features and 3 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: 1368858 ymin: 759456.7 xmax: 1444935 ymax: 890470.9
## Projected CRS: NAD83 / BC Albers
set_units(st_area(BEC_wg_2071_2100), "ha")
## Units: [ha]
## [1] 2514.9035 820.0772 85561.3924 273.3591 43901.4684 72768.1874
## [7] 2842.9344 331529.8936
plot(BEC_wg_2071_2100["Zone"])

mapview(BEC_wg_2071_2100, zcol = "Zone")