Tools for Prairie Habitat Joint Venture
The Prairie Habitat Joint Venture (PHJV), in conjunction with Ducks Unlimited Canada (DUC), have developed species distribution models for seven species of ducks that breed in the Prairie Pothole Region. These species distribution models are then used to create PHJV's target landscapes, which help direct conservation efforts on the ground. This R package allows users to access these species distribution models as rasters, the target landscapes as vectors, and additional functions for further calculations on these rasters and vectors.
phjvtools can be installed directly from GitHub:
install.packages("remotes")
remotes::install_github("DUC-IWWR/phjvtools")
Due to data sensitivities, please note that the install of phjvtools does NOT include the installation of the data needed to function. Since this is currently functioning as an internal R package to DUC/IWWR, the data will be provided via IWWR Sharepoint.
To install the data, first download the latest data version .tar file from the Sharepoint link provided to you. Then, after installing phjvtools, run the following command
library(phjvtools)
install_data(data_file = "path/to/data.tar")
In the above, replace the term "path/to/data.tar" with the actual path to the downloaded data. Alternatively, you can use the following command
library(phjvtools)
install_data(data_file = file.choose())
Using the file.choose() option will open up an explorer window for you to navigate to the downloaded data and choose it.
For the most part, this package is meant to provide basic functionality to access target landscapes and DSS rasters, and provide some (opinionated) functionality to run some basic analyses on these files. Any spatial data involved with this package makes use of the SpatVector and SpatRaster data types from the terra R package, and so you can do any other analyses you can think of that you normally could with terra spatial data. See https://rspatial.org/ for details on the terra package.
The function get_target_landscape() will return target landscapes as a SpatVector. There are a few options for which target landscapes you can get.
# Get the 2026 target landscape. No function arguments are required by default
tl_2026 <- get_target_landscape()
# Get the 2011 version instead
tl_2011 <- get_target_landscape(version = 2011)
At version 0.0.4, asking for the 2026 target landscapes will produce a message warning the user that the target landscape is still under review.
The function get_dss() will return either one SpatRaster if you want it for one species, or a list of SpatRasters. The function argument species allows for the 4 letter banding code to be provided. These allowable codes are:
- "MALL" (for Mallard)
- "BWTE" (for Blue-winged Teal)
- "NSHO" (Northern Shoveller)
- "NOPI" (Northern Pintail)
- "GADW" (Gadwall)
- "REDH" (Redhead)
- "CANV" (Canvasback)
An additional option is to supply "ALL", which will return the stacked raster of all of the seven species.
# Get all the species plus the stacked raster
species_list <- c("MALL", "BWTE", "NSHO", "NOPI", "GADW", "REDH", "CANV", "ALL")
species_rasters <- get_dss(species = species_list)
# Get just one species
mallard_dss <- get_dss(species = "MALL")
phjvtools provides some functionality to calculate the area of the target landscapes.
# First load the target landscape. Here we will use the 2026 version.
tl <- get_target_landscape()
# Now get total area.
total_area <- calculate_tl_area(target_landscape = tl)
# Use m^2 instead of km^2
total_area_m2 <- calculate_tl_area(target_landscape = tl,
unit = "m")
# Calculate area in km^2 by province
total_area_prov <- calculate_tl_area(target_landscape = tl, by_province = TRUE)
phjvtools provides some functionality to calculate population by target landscapes.
# First load the target landscape. Here we will use the 2026 version.
tl <- get_target_landscape()
# Get all the species plus the stacked raster
species_list <- c("MALL", "BWTE", "NSHO", "NOPI", "GADW", "REDH", "CANV", "ALL")
species_rasters <- get_dss(species = species_list)
# Calculate the population for each species
pop <- calculate_tl_population(target_landscape = tl_new,
species_rasters = species_rasters,
species_names = species_list)
# Calculate the proportion of populations captured within target landscape boundaries
pop_prop <- calculate_tl_population(target_landscape = tl_new,
species_rasters = species_rasters,
species_names = species_list,
calculate_proportions = TRUE)
# Calculate the population for each species by province
pop <- calculate_tl_population(target_landscape = tl_new,
species_rasters = species_rasters,
species_names = species_list,
by_province = TRUE)
