Skip to contents

Kernel Density Plots for climate-smart spatial plans

Usage

splnr_plot_climKernelDensity(
  soln,
  names = NA,
  type = "Normal",
  colorMap = "C",
  legendTitle = expression(" °C y"^"-1" * ""),
  xAxisLab = expression("Climate warming ( °C y"^"-1" * ")")
)

Arguments

soln

For type "Publication": A list of prioirtizr solutions (e.g. solution_list = list(s1, s2)) containing a "metric" column containing the used climate metric information; For type "App": needs to be a prioritizr solution

names

A list of names of the solutions (names = c("Input 1", "Input 2"))

type

The plotting style of the kernel density plots. Either "Publication" which gives axis information etc., or "App" which condenses the information in the plot to simplify it for stakeholders.

colorMap

A character string indicating the color map to use (see https://ggplot2.tidyverse.org/reference/scale_viridis.html for all options)

legendTitle

A character value for the title of the legend. Can be empty ("").

xAxisLab

A characted value for the x Axis label depending on the climate metric input

Value

A ggplot object of the plot

Examples

target <- dat_species_bin %>%
  dplyr::select(-"cellID") %>%
  sf::st_drop_geometry() %>%
  colnames() %>%
  data.frame() %>%
  setNames(c("feature")) %>%
  dplyr::mutate(target = 0.3)

CPA <- splnr_climate_priorityAreaApproach(
  featuresDF = dat_species_bin,
  metricDF = dat_clim,
  targetsDF = target,
  direction = -1,
  refugiaTarget = 1
)

out_sf <- CPA$Features %>%
  dplyr::mutate(Cost_None = rep(1, 780)) %>%
  dplyr::left_join(dat_clim %>%
    sf::st_drop_geometry(), by = "cellID")

usedFeatures <- out_sf %>%
  sf::st_drop_geometry() %>%
  dplyr::select(-tidyselect::starts_with("Cost_"), -"cellID", -"metric") %>%
  names()

p1 <- prioritizr::problem(out_sf, usedFeatures, "Cost_None") %>%
  prioritizr::add_min_set_objective() %>%
  prioritizr::add_relative_targets(CPA$Targets$target) %>%
  prioritizr::add_binary_decisions() %>%
  prioritizr::add_default_solver(verbose = FALSE)

dat_solnClim <- prioritizr::solve.ConservationProblem(p1)
splnr_plot_climKernelDensity(dat_solnClim, type = "Basic")
splnr_plot_climKernelDensity(soln = list(dat_solnClim), names = c("Input 1"), type = "Normal")