Skip to contents

This function allows to customise plots in a simple and reproducible way, by giving the option for several inputs that can be included in maps produced with the other functions of this package.It can be combined with the spatialplanr spatial plotting functions.

Usage

splnr_gg_add(
  PUs = NULL,
  colorPUs = "grey80",
  Bndry = NULL,
  colorBndry = "black",
  overlay = NULL,
  colorOverlay = "grey20",
  overlay2 = NULL,
  colorOverlay2 = "grey30",
  overlay3 = NULL,
  colorOverlay3 = "grey40",
  contours = NULL,
  colorConts = "black",
  cropOverlay = NULL,
  lockIn = NULL,
  typeLockIn = "Full",
  nameLockIn = NULL,
  alphaLockIn = 0.5,
  colorLockIn = "black",
  legendLockIn = "",
  labelLockIn = "MPAs",
  ggtheme = "Default"
)

Arguments

PUs

Planning Units as an sf object

colorPUs

A color value for the outline of planning units.

Bndry

The planning region boundaries as an sf object

colorBndry

A color value for the outline of the boundary.

overlay

An sf object of overlay polygon.

colorOverlay

A color value for overlay.

overlay2

An sf object of overlay polygon.

colorOverlay2

A color value for overlay.

overlay3

An sf object of overlay polygon.

colorOverlay3

A color value for overlay.

contours

An sf object of contours that are important to visualise (e.g. outline of sea mounts, ridges; can be produced with terra::as.contour()); up to 6 different contours possible.

colorConts

A color value for contours.

cropOverlay

An sf object with the boundary box used for cropping the overlay object.

lockIn

An sf object with binary data of locked in areas in the prioritisation (e.g. MPAs).

typeLockIn

Either "Full" or "Contours"; "Full" maps the locked in areas on top of the planning units; "Contours" draws the outline of the locked in areas.

nameLockIn

column of data frame that contains binary information of the locked in areas to plot

alphaLockIn

A value (0-1) for the opacity of the locked in areas when plotted on top of other plots.

colorLockIn

A color value for the locked in areas.

legendLockIn

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

labelLockIn

The legend label of the locked in area (e.g. MPAs)

ggtheme

The theme applied to the plot. Can either be NA (default ggplot), "Default" (default spatialplanr: theme_bw() and some basic theme settings) or a user-defined list of theme properties.

Value

A ggplot object of the plot

Examples

dat_problem <- prioritizr::problem(dat_species_bin %>% dplyr::mutate(Cost = runif(n = dim(.)[[1]])),
  features = c("Spp1", "Spp2", "Spp3", "Spp4", "Spp5"),
  cost_column = "Cost"
) %>%
  prioritizr::add_min_set_objective() %>%
  prioritizr::add_relative_targets(0.3) %>%
  prioritizr::add_binary_decisions() %>%
  prioritizr::add_default_solver(verbose = FALSE)

dat_soln <- dat_problem %>%
  prioritizr::solve.ConservationProblem()

splnr_plot_solution(dat_soln) +
  splnr_gg_add(PUs = dat_PUs, ggtheme = "Default")
#> Coordinate system already present. Adding new coordinate system, which will
#> replace the existing one.