diff --git a/DESCRIPTION b/DESCRIPTION index b09e5a4d..5ffc4548 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: spatialplanr Title: Help files for prioritzr Spatial Planning projects -Version: 0.6.7 +Version: 0.6.8 Authors@R: c( person( given = "Jason D.", @@ -30,7 +30,7 @@ Suggests: ggridges, irr, knitr, - oceandatr (>= 0.1.0), + oceandatr (>= 0.2.0), patchwork, prioritizr, RColorBrewer, @@ -61,7 +61,7 @@ Imports: rnaturalearth, scales, sf, - spatialgridr (>= 0.0.1), + spatialgridr (>= 0.0.2), stringr, terra, tibble, diff --git a/R/data.R b/R/data.R index 8285673a..83b1a7d3 100644 --- a/R/data.R +++ b/R/data.R @@ -5,7 +5,6 @@ #' @format `dat_PUs` #' A data frame with XXXX rows and XXX columns: #' \describe{ -#' \item{cellID}{ID number for each row (or cell) of the dataset} #' \item{geometry}{sf geometry column} #' ... #' } @@ -22,7 +21,6 @@ #' @format `dat_bndry` #' A data frame with XXXX rows and XXX columns: #' \describe{ -#' \item{cellID}{ID number for each row (or cell) of the dataset} #' \item{geometry}{sf geometry column} #' ... #' } @@ -39,7 +37,6 @@ #' @format `dat_region` #' A data frame with XXXX rows and XXX columns: #' \describe{ -#' \item{cellID}{ID number for each row (or cell) of the dataset} #' \item{geometry}{sf geometry column} #' ... #' } @@ -55,7 +52,6 @@ #' @format `dat_species_bin` #' A data frame with XXXX rows and XXX columns: #' \describe{ -#' \item{cellID}{ID number for each row (or cell) of the dataset} #' \item{geometry}{sf geometry column} #' ... #' } @@ -72,7 +68,6 @@ #' @format `dat_species_bin2` #' A data frame with XXXX rows and XXX columns: #' \describe{ -#' \item{cellID}{ID number for each row (or cell) of the dataset} #' \item{geometry}{sf geometry column} #' ... #' } @@ -89,7 +84,6 @@ #' @format `dat_species_prob` #' A data frame with XXXX rows and XXX columns: #' \describe{ -#' \item{cellID}{ID number for each row (or cell) of the dataset} #' \item{geometry}{sf geometry column} #' ... #' } @@ -106,7 +100,6 @@ #' @format `dat_mpas` #' A data frame with XXXX rows and XXX columns: #' \describe{ -#' \item{cellID}{ID number for each row (or cell) of the dataset} #' \item{geometry}{sf geometry column} #' \item{wdpa}{binary MPA information (1: MPA)} #' ... @@ -160,7 +153,6 @@ #' @format `dat_clim` #' A data frame with 780 rows and 3 columns: #' \describe{ -#' \item{cellID}{ID number for each row (or cell) of the dataset} #' \item{geometry}{sf geometry column} #' \item{metric}{climate metric information} #' ... @@ -178,7 +170,6 @@ # A data frame with 397 rows and 17 columns: # \describe{ # \item{Chelonia_mydas}{suitable habitat for Chelonia mydas} -# \item{cellID}{cell ID of planning units} # ... # } # @source Aquamaps.org @@ -196,7 +187,6 @@ #' A data frame with 397 rows and 17 columns: #' \describe{ #' \item{wdpa}{binary vector denoting presence or absence of a current marine protected area} -#' \item{cellID}{cell ID of planning units} #' ... #' } #' @source https://www.protectedplanet.net/en/thematic-areas/wdpa?tab=WDPA @@ -233,7 +223,6 @@ #' @format `CoralSeaVelocity` #' A data frame with 397 rows and 3 columns: #' \describe{ -#' \item{cellID}{cell ID of the planning units} #' \item{vocMagg_transformed}{Climate velocity column} #' \item{geometry}{Geometry column of sf object} #' ... @@ -263,7 +252,6 @@ #' A data frame with bathymetry data #' \describe{ # -#' \item{cellID}{ID number for each row (or cell) of the dataset} #' \item{bathymetry}{Bathymetry data} #' \item{geometry}{sf geometry column} #' ... diff --git a/R/splnr_apply_cutoffs.R b/R/splnr_apply_cutoffs.R index 5005e8fc..910aacaa 100644 --- a/R/splnr_apply_cutoffs.R +++ b/R/splnr_apply_cutoffs.R @@ -23,7 +23,7 @@ splnr_apply_cutoffs <- function(features, Cutoffs, inverse = FALSE) { features <- features %>% dplyr::as_tibble() %>% dplyr::mutate(dplyr::across( - -dplyr::any_of(c("cellID", "geometry")), # Apply to all columns except geometry and cellID + -dplyr::any_of("geometry"), # Apply to all columns except geometry ~ dplyr::case_when( . >= Cutoffs ~ 1, . < Cutoffs ~ 0, @@ -34,11 +34,10 @@ splnr_apply_cutoffs <- function(features, Cutoffs, inverse = FALSE) { if (inverse == TRUE) { # Need to flip the ones/zeros features <- features %>% - dplyr::mutate(dplyr::across(-dplyr::any_of(c("cellID", "geometry")), ~ 1 - .)) + dplyr::mutate(dplyr::across(-dplyr::any_of("geometry"), ~ 1 - .)) } } else if (length(Cutoffs) == length(names(Cutoffs))) { # Named vector with values for each column - nm <- names(Cutoffs) # Testing - We should only be operating on the columns in the Cutoffs vector for (f in 1:length(nm)) { diff --git a/R/splnr_featureRep.R b/R/splnr_featureRep.R index 39f00898..ce0ea455 100644 --- a/R/splnr_featureRep.R +++ b/R/splnr_featureRep.R @@ -2,7 +2,7 @@ #' #' @param soln The `prioritizr` solution #' @param pDat The `prioritizr` problem -#' @param targetsDF `data.frame`with list of features under "feature" column and their corresponding targets under "target" column +#' @param targets `data.frame`with list of features under "feature" column and their corresponding targets under "target" column #' @param climsmart logical denoting whether spatial planning was done climate-smart (and targets have to be calculated differently) #' @param climsmartApproach either 0,1,2 or 3 depending on the climate-smart approach used (0 = None; 1 = Climate Priority Area; 2 = Feature; 3 = Percentile). #' @param solnCol Name of the column with the solution @@ -29,15 +29,17 @@ #' soln = soln, #' pDat = pDat #' ) -splnr_get_featureRep <- function(soln, pDat, targetsDF = NA, - climsmart = FALSE, climsmartApproach = 0, solnCol = "solution_1") { +splnr_get_featureRep <- function(soln, pDat, targets = NA, + climsmart = FALSE, + climsmartApproach = 0, + solnCol = "solution_1") { s_cols <- pDat$data$features[[1]] # Get data for features not chosen not_selected <- soln %>% dplyr::select( -tidyselect::starts_with(c("Cost", "solution_")), - -tidyselect::any_of(c("metric", "cellID")), + -tidyselect::any_of(c("metric")), -tidyselect::any_of(s_cols) ) %>% sf::st_drop_geometry() @@ -102,13 +104,13 @@ splnr_get_featureRep <- function(soln, pDat, targetsDF = NA, dplyr::ungroup() %>% dplyr::mutate(relative_held = .data$absolute_held / .data$total_amount) %>% # Calculate proportion dplyr::select(-"total_amount", -"absolute_held") %>% # Remove extra columns - dplyr::left_join(targetsDF, by = "feature") #%>% # Add targets to df + dplyr::left_join(targets, by = "feature") #%>% # Add targets to df # dplyr::select(-"type") } else if (climsmart == TRUE & climsmartApproach == 3) { s1 <- s1 %>% - dplyr::left_join(targetsDF, by = "feature") + dplyr::left_join(targets, by = "feature") } else { # Add targets to df @@ -179,11 +181,13 @@ splnr_get_featureRep <- function(soln, pDat, targetsDF = NA, #' #' (splnr_plot_featureRep(df, category = dat_category)) #' -splnr_plot_featureRep <- function(df, category = NA, +splnr_plot_featureRep <- function(df, + category = NA, categoryFeatureCol = NA, renameFeatures = FALSE, namesToReplace = NA, - nr = 1, showTarget = NA, + nr = 1, + showTarget = NA, plotTitle = "", ...) { diff --git a/R/splnr_plot.R b/R/splnr_plot.R index 12e85f2d..ea6116cb 100644 --- a/R/splnr_plot.R +++ b/R/splnr_plot.R @@ -2,15 +2,13 @@ #' #' (For now can replace splnr_plot_cost(), splnr_plot_binFeature(), splnr_plot_MPAs(), splnr_plot_featureNo()) #' -#' Written by Kilian Barreiro +#' Written by Kilian Barreiro and Jason Everett #' Written: February 2024 #' -#' Plot Spatial Data, returns a gg object -#' #' @param df The dataframe containing the data to be plotted. It must include a geometry column to be used with geom_sf. -#' @param col_names A list of column names to include in the plot. If specified, only these columns will be used to color the plot. -#' @param paletteName The name of the color palette to use for filling. Default is "YlGnBu". -#' @param colourVals The color values to use if col_names is specified and the data is binary. +#' @param col_names A list of column names to include in the plot. If specified, only these columns will be used to colour the plot. +#' @param paletteName The name of the colour palette to use for filling. Default is "YlGnBu". +#' @param colourVals The colour values to use if col_names is specified and the data is binary. #' @param plot_title The title of the plot. #' @param legend_title The title of the legend. #' @param legend_labels A vector of strings containing the labels to use for legend values. @@ -158,7 +156,7 @@ splnr_plot <- function(df, gg <- gg + ggplot2::geom_sf(data = df, ggplot2::aes(fill = .data[[col_names]]), colour = "grey80", size = 0.1) + - ggplot2::scale_fill_viridis_c() + + ggplot2::scale_fill_viridis_c(name = legend_title) + ggplot2::guides(fill = ggplot2::guide_colourbar(order = 1)) } else if (is.null(col_names)){ # No column to plot by diff --git a/R/splnr_plotting.R b/R/splnr_plotting.R index e3fc219a..b97fecbd 100644 --- a/R/splnr_plotting.R +++ b/R/splnr_plotting.R @@ -206,7 +206,7 @@ splnr_plot_costOverlay <- function(soln, Cost = NA, Cost_name = "Cost", as.numeric(stats::quantile(dplyr::pull(Cost, Cost_name), 0.99)) ), # direction = 1, - # oob = scales::squish, + oob = scales::squish, # guide = ggplot2::guide_colourbar( # title.position = "bottom", # title.hjust = 0.5, diff --git a/R/splnr_plotting_climate.R b/R/splnr_plotting_climate.R index 4653fa42..f245e820 100644 --- a/R/splnr_plotting_climate.R +++ b/R/splnr_plotting_climate.R @@ -208,7 +208,6 @@ splnr_plot_climKernelDensity_Fancy <- function(solution_list, names, #' #' @examples #' target <- dat_species_bin %>% -#' dplyr::select(-"cellID") %>% #' sf::st_drop_geometry() %>% #' colnames() %>% #' data.frame() %>% @@ -216,21 +215,20 @@ splnr_plot_climKernelDensity_Fancy <- function(solution_list, names, #' dplyr::mutate(target = 0.3) #' #' CPA <- splnr_climate_priorityAreaApproach( -#' featuresDF = dat_species_bin, -#' metricDF = dat_clim, -#' targetsDF = target, +#' features = dat_species_bin, +#' metric = dat_clim, +#' targets = 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") +#' sf::st_join(dat_clim, join = sf::st_equals) #' #' usedFeatures <- out_sf %>% #' sf::st_drop_geometry() %>% -#' dplyr::select(-tidyselect::starts_with("Cost_"), -"cellID", -"metric") %>% +#' dplyr::select(-tidyselect::starts_with("Cost_"), -"metric") %>% #' names() #' #' p1 <- prioritizr::problem(out_sf, usedFeatures, "Cost_None") %>% diff --git a/R/splnr_targets.R b/R/splnr_targets.R index 0c140864..b6ac769b 100644 --- a/R/splnr_targets.R +++ b/R/splnr_targets.R @@ -19,8 +19,7 @@ splnr_targets_byInverseArea <- function(df, target_min, target_max) { inherits(df, c("sf", "data.frame")), is.numeric(target_min) && target_min >= 0 && target_min <= 1, is.numeric(target_max) && target_max >= 0 && target_max <= 1, - target_min <= target_max, - "cellID" %in% names(df) + target_min <= target_max ) PU_area_km2 <- as.numeric(sf::st_area(df[1, 1]) / 1e+06) # Area of each planning unit @@ -28,7 +27,6 @@ splnr_targets_byInverseArea <- function(df, target_min, target_max) { total_PU_area <- nrow(df) * PU_area_km2 # Total area of the study region dat <- df %>% - dplyr::select(-"cellID") %>% sf::st_drop_geometry() %>% dplyr::mutate(dplyr::across(dplyr::everything(), ~ tidyr::replace_na(.x, 0))) %>% dplyr::summarise(dplyr::across(dplyr::everything(), ~ sum(., is.na(.), 0))) %>% diff --git a/R/utils-climate.R b/R/utils-climate.R index 881ce0ee..dddb0467 100644 --- a/R/utils-climate.R +++ b/R/utils-climate.R @@ -2,9 +2,9 @@ #' Function to split the feature data into climate-smart (CS) and non-climate-smart (NCS) areas depending on the percentile chosen by the user. #' -#' @param featuresDF feature sf object which should have a column for cellID +#' @param features feature sf object +#' @param metric climate metric `sf` object with 'metric' as the column name of the metric values per planning unit. #' @param percentile cut-off threshold for determining whether an area is a climate priority area or not (e.g., lower 35th percentile of warming or upper 65th percentile of acidification). Note that the percentile here is the lower limit of the threshold. -#' @param metricDF climate metric data.frame with 'metric' as the column name of the metric values per planning unit. This should also have a column for the cellID #' @param direction If direction = 1, metric values are from low (least climate-smart) to high (most climate-smart). If direction = -1, metric values are from high (least climate-smart) to low (most climate-smart). #' #' @return A new sf dataframe that has cutoffs applied. @@ -14,34 +14,26 @@ #' @importFrom rlang .data #' #' @examples -#' metric_df <- dat_clim -#' -#' dat_species_binDF <- dat_species_bin %>% -#' sf::st_drop_geometry() #' #' out_sf <- splnr_climate_priorityArea_preprocess( -#' featuresDF = dat_species_bin, -#' percentile = 5, metricDF = metric_df, direction = 1 +#' features = dat_species_bin, +#' percentile = 5, +#' metric = dat_clim, +#' direction = 1 #' ) -splnr_climate_priorityArea_preprocess <- function(featuresDF, +splnr_climate_priorityArea_preprocess <- function(features, percentile, - metricDF, + metric, direction) { - spp <- featuresDF %>% - dplyr::select(-"geometry", -"cellID") %>% + spp <- features %>% sf::st_drop_geometry() %>% names() - metric <- metricDF %>% - sf::st_drop_geometry() - imptList <- list() # empty list to fill in with the important features for (i in 1:length(spp)) { - df <- featuresDF %>% - tibble::as_tibble() %>% - dplyr::select(!!rlang::sym(spp[i]), "cellID") %>% # Select 1 species at a time - dplyr::left_join(metricDF, by = "cellID") %>% - dplyr::select(-"cellID") + df <- features %>% + dplyr::select(!!rlang::sym(spp[i])) %>% # Select 1 species at a time + sf::st_join(metric, join = sf::st_equals) if (any((apply(df, 2, is.na))[, 2])) { print("There are some NAs in the metric data. Please check.") @@ -75,37 +67,46 @@ splnr_climate_priorityArea_preprocess <- function(featuresDF, } } + if (i > 1){ + df <- df %>% + sf::st_drop_geometry() # Drop here otherwise we get multiple version below + } + imptList[[i]] <- df %>% dplyr::mutate(!!rlang::sym(paste0(spp[i], "_CS")) := .data$V1 * .data$V2) %>% # CS = climate-smart areas dplyr::select(!!rlang::sym(paste0(spp[i], "_CS"))) } - imptList <- do.call(dplyr::bind_cols, imptList) %>% - dplyr::mutate(cellID = dplyr::row_number()) + imptList <- do.call(dplyr::bind_cols, imptList) repList <- list() for (i in 1:length(spp)) { - df1 <- featuresDF %>% - tibble::as_tibble() %>% - dplyr::select(!!rlang::sym(spp[i]), "cellID") %>% # Select 1 species at a time - dplyr::left_join(metricDF, by = "cellID") + + df1 <- features %>% + dplyr::select(!!rlang::sym(spp[i])) %>% # Select 1 species at a time + sf::st_join(metric, join = sf::st_equals) df2 <- imptList %>% - dplyr::select(!!rlang::sym(paste0(spp[i], "_CS")), "cellID") + dplyr::select(!!rlang::sym(paste0(spp[i], "_CS")),) + + df3 <- sf::st_join(df1, df2, join = sf::st_equals) - repList[[i]] <- dplyr::left_join(df1, df2, by = "cellID") %>% + if (i > 1){ + df3 <- df3 %>% + sf::st_drop_geometry() # Drop here otherwise we get multiple version below + } + + repList[[i]] <- df3 %>% dplyr::mutate(!!rlang::sym(paste0(spp[i], "_NCS")) := dplyr::if_else(!!rlang::sym(paste0(spp[i], "_CS")) == 1, - true = 0, - false = .data[[spp[i]]] - )) %>% + true = 0, + false = .data[[spp[i]]] + )) %>% dplyr::select(tidyselect::matches("_NCS|_CS")) } repList <- do.call(dplyr::bind_cols, repList) %>% - dplyr::bind_cols(featuresDF %>% - dplyr::select("cellID", "geometry")) %>% - dplyr::select("cellID", tidyselect::everything()) %>% + dplyr::select(tidyselect::everything()) %>% sf::st_as_sf(sf_column_name = "geometry") return(repList) @@ -114,7 +115,7 @@ splnr_climate_priorityArea_preprocess <- function(featuresDF, #' Function to assign targets for climate-priority-area approach #' -#' @param targetsDF `data.frame`with list of features under "feature" column and their corresponding targets under "target" column +#' @param targets `data.frame`with list of features under "feature" column and their corresponding targets under "target" column #' @param climateSmartDF `sf` object produced using the function splnr_ClimatePriorityArea_CSapproach() #' @param refugiaTarget target assigned to climate-smart areas #' @@ -125,10 +126,9 @@ splnr_climate_priorityArea_preprocess <- function(featuresDF, #' @importFrom rlang .data #' #' @examples -#' Features <- dat_species_bin %>% -#' dplyr::select(-"cellID") +#' Features <- dat_species_bin #' -#' target <- Features %>% +#' targets <- Features %>% #' sf::st_drop_geometry() %>% #' colnames() %>% #' data.frame() %>% @@ -141,32 +141,31 @@ splnr_climate_priorityArea_preprocess <- function(featuresDF, #' sf::st_drop_geometry() #' #' out_sf <- splnr_climate_priorityArea_preprocess( -#' featuresDF = dat_species_bin, -#' percentile = 5, metricDF = metric_df, direction = 1 +#' features = dat_species_bin, +#' percentile = 5, metric = metric_df, direction = 1 #' ) #' #' targets <- splnr_climate_priorityArea_assignTargets( -#' targetsDF = target, +#' targets = targets, #' climateSmartDF = out_sf, #' refugiaTarget = 1 #' ) -splnr_climate_priorityArea_assignTargets <- function(targetsDF, +splnr_climate_priorityArea_assignTargets <- function(targets, climateSmartDF, refugiaTarget = 1) { - spp <- targetsDF %>% + spp <- targets %>% dplyr::select("feature") %>% dplyr::pull() featDF <- climateSmartDF %>% sf::st_drop_geometry() %>% - dplyr::select(-"cellID") %>% dplyr::mutate(dplyr::across(dplyr::everything(), ~ tidyr::replace_na(.x, 0))) %>% dplyr::summarize(dplyr::across(tidyselect::everything(), sum)) %>% tidyr::pivot_longer(tidyselect::everything(), names_to = "feature", values_to = "planunit") finalList <- list() # empty list for (i in 1:length(spp)) { - filteredTarget <- targetsDF %>% # Get the set target per feature + filteredTarget <- targets %>% # Get the set target per feature dplyr::filter(.data$feature == spp[i]) trgt <- filteredTarget$target # Extracting the target set for each feature @@ -215,9 +214,9 @@ splnr_climate_priorityArea_assignTargets <- function(targetsDF, #' Function to run the climate-priority-area approach #' -#' @param featuresDF feature `sf`object which should have a column for cellID -#' @param targetsDF `data.frame`with list of features under "feature" column and their corresponding targets under "target" column -#' @param metricDF climate metric data.frame with 'metric' as the column name of the metric values per planning unit. This should also have a column for the cellID +#' @param features feature `sf`object +#' @param metric climate metric `sf` object with 'metric' as the column name of the metric values per planning unit. +#' @param targets `data.frame`with list of features under "feature" column and their corresponding targets under "target" column #' @param refugiaTarget target assigned to climate-smart areas #' @param direction If direction = 1, metric values are from low (least climate-smart) to high (most climate-smart). If direction = -1, metric values are from high (least climate-smart) to low (most climate-smart). #' @param percentile cut-off threshold for determining whether an area is a climate priority area or not (e.g., lower 35th percentile of warming or upper 65th percentile of acidification). Note that the percentile here is the lower limit of the threshold. @@ -228,39 +227,36 @@ splnr_climate_priorityArea_assignTargets <- function(targetsDF, #' @importFrom rlang .data #' #' @examples -#' Features <- dat_species_bin %>% -#' dplyr::select(-"cellID") #' -#' target <- Features %>% +#' targets <- dat_species_bin %>% #' sf::st_drop_geometry() %>% #' colnames() %>% #' data.frame() %>% #' setNames(c("feature")) %>% #' dplyr::mutate(target = 0.3) #' -#' metric_df <- dat_clim -#' -#' #' CPA_Approach <- splnr_climate_priorityAreaApproach( -#' featuresDF = dat_species_bin, -#' metricDF = metric_df, targetsDF = target, direction = -1 +#' features = dat_species_bin, +#' metric = dat_clim, +#' targets = targets, +#' direction = -1 #' ) #' out_sf <- CPA_Approach$Features #' targets <- CPA_Approach$Targets -splnr_climate_priorityAreaApproach <- function(featuresDF, - metricDF, - targetsDF, +splnr_climate_priorityAreaApproach <- function(features, + metric, + targets, direction, percentile = 5, refugiaTarget = 1) { - assertthat::assert_that(inherits(featuresDF, "sf"), - "cellID" %in% names(featuresDF), - is.data.frame(metricDF), - "cellID" %in% names(metricDF), - is.data.frame(targetsDF), - "feature" %in% names(targetsDF), - "target" %in% names(targetsDF), + #TODO check that geometry of both sf objects are the same. + + assertthat::assert_that(inherits(features, "sf"), + inherits(metric, "sf"), + is.data.frame(targets), + "feature" %in% names(targets), + "target" %in% names(targets), direction %in% c(-1, 1), is.numeric(percentile), percentile >= 0 && percentile <= 100, @@ -268,13 +264,16 @@ splnr_climate_priorityAreaApproach <- function(featuresDF, refugiaTarget >= 0 && refugiaTarget <= 1) CPAFeatures <- splnr_climate_priorityArea_preprocess( - featuresDF = featuresDF, metricDF = metricDF, - direction = direction, percentile = percentile + features = features, + metric = metric, + direction = direction, + percentile = percentile ) CPATargets <- splnr_climate_priorityArea_assignTargets( - targetsDF = targetsDF, - CPAFeatures, refugiaTarget = refugiaTarget + targets = targets, + CPAFeatures, + refugiaTarget = refugiaTarget ) return(list(Features = CPAFeatures, Targets = CPATargets)) } @@ -285,8 +284,8 @@ splnr_climate_priorityAreaApproach <- function(featuresDF, #' #' This function creates a climate layer by selecting the most climate-smart areas in the entire planning region. #' -#' @param featuresDF feature `sf`object which should have a column for cellID -#' @param metricDF climate metric data.frame with 'metric' as the column name of the metric values per planning unit. This should also have a column for the cellID +#' @param features feature `sf`object +#' @param metric climate metric `sf` object with 'metric' as the column name of the metric values per planning unit.#' #' @param direction If direction = 1, metric values are from low (least climate-smart) to high (most climate-smart). If direction = -1, metric values are from high (least climate-smart) to low (most climate-smart). #' @param percentile cut-off threshold for determining whether an area is a climate priority area or not. Note that the percentile here is the lower limit of the threshold. #' @@ -298,28 +297,28 @@ splnr_climate_priorityAreaApproach <- function(featuresDF, #' #' @examples #' -#' metric_df <- dat_clim -#' #' featureTest <- splnr_climate_feature_preprocess( -#' featuresDF = dat_species_bin, -#' percentile = 5, metricDF = metric_df, direction = 1 +#' features = dat_species_bin, +#' percentile = 5, +#' metric = dat_clim, +#' direction = 1 #' ) -splnr_climate_feature_preprocess <- function(featuresDF, +splnr_climate_feature_preprocess <- function(features, percentile, - metricDF, + metric, direction) { - if (any(apply(metricDF, 2, is.na)[, "metric"])) { + if (any(apply(metric, 2, is.na)[, "metric"])) { print("There are some NAs in the metric data. Please check.") } prct <- percentile / 100 - qntl <- stats::quantile(metricDF$metric, prct)[[1]] # Get the percentile + qntl <- stats::quantile(metric$metric, prct)[[1]] # Get the percentile if (direction == 1) { print("Higher values mean more climate-smart areas.") - df <- metricDF %>% + df <- metric %>% dplyr::mutate(climate_layer = ifelse(.data$metric >= qntl, yes = 1, no = 0)) # Create the climate layer } else if (direction == -1) { print("Lower values mean more climate-smart areas.") - df <- metricDF %>% + df <- metric %>% dplyr::mutate(climate_layer = ifelse(.data$metric <= qntl, yes = 1, no = 0)) # Create the climate layer } else { if (direction != 1 & direction != -1) { @@ -328,24 +327,21 @@ splnr_climate_feature_preprocess <- function(featuresDF, } } + # Get the most climate-smart areas climateSmartDF <- df %>% - dplyr::select("cellID", "climate_layer") %>% - tibble::as_tibble() + dplyr::select("climate_layer") # Attach "climate_layer" to the features df and have this as the output - featuresDF <- featuresDF %>% - sf::st_drop_geometry() %>% - tibble::as_tibble() %>% - dplyr::left_join(climateSmartDF, by = "cellID") %>% - sf::st_as_sf(geometry = featuresDF$geometry) + features <- features %>% + sf::st_join(climateSmartDF, join = sf::st_equals) - return(featuresDF) + return(features) } #' Function to assign targets for the feature approach #' -#' @param targetsDF `data.frame`with list of features under "feature" column and their corresponding targets under "target" column +#' @param targets `data.frame`with list of features under "feature" column and their corresponding targets under "target" column #' @param climateSmartDF `sf` object produced using the function splnr_ClimatePriorityArea_CSapproach() #' @param refugiaTarget target assigned to climate-smart areas #' @@ -356,34 +352,34 @@ splnr_climate_feature_preprocess <- function(featuresDF, #' @importFrom rlang .data #' #' @examples -#' Features <- dat_species_bin %>% -#' dplyr::select(-"cellID") +#' Features <- dat_species_bin #' -#' target <- Features %>% +#' targets <- Features %>% #' sf::st_drop_geometry() %>% #' colnames() %>% #' data.frame() %>% #' setNames(c("feature")) %>% #' dplyr::mutate(target = 0.3) #' -#' metric_df <- dat_clim -#' #' dat_species_binDF <- dat_species_bin %>% #' sf::st_drop_geometry() #' #' out_sf <- splnr_climate_feature_preprocess( -#' featuresDF = dat_species_bin, -#' percentile = 5, metricDF = metric_df, direction = 1 +#' features = dat_species_bin, +#' percentile = 5, +#' metric = dat_clim, +#' direction = 1 #' ) #' #' targets <- splnr_climate_feature_assignTargets( -#' targetsDF = target, +#' targets = targets, #' climateSmartDF = out_sf, #' refugiaTarget = 0.3 #' ) splnr_climate_feature_assignTargets <- function(climateSmartDF, refugiaTarget, - targetsDF) { + targets) { + # Calculate the target depending on the # of PUs deemed as "climate-smart" trgt <- refugiaTarget / (sum(climateSmartDF$climate_layer) / nrow(climateSmartDF)) @@ -392,7 +388,7 @@ splnr_climate_feature_assignTargets <- function(climateSmartDF, "climate_layer", trgt ) - finalDF <- targetsDF %>% + finalDF <- targets %>% dplyr::bind_rows(climate_layerDF) # %>% # dplyr::mutate(targets = .data$targets / 100) # Convert target to proportions @@ -401,9 +397,9 @@ splnr_climate_feature_assignTargets <- function(climateSmartDF, #' Function to run the feature approach #' -#' @param featuresDF feature `sf`object which should have a column for cellID -#' @param targetsDF `data.frame`with list of features under "feature" column and their corresponding targets under "target" column -#' @param metricDF climate metric data.frame with 'metric' as the column name of the metric values per planning unit. This should also have a column for the cellID +#' @param features feature `sf`object +#' @param metric climate metric `sf` object with 'metric' as the column name of the metric values per planning unit. +#' @param targets `data.frame`with list of features under "feature" column and their corresponding targets under "target" column #' @param refugiaTarget target assigned to climate-smart areas #' @param direction If direction = 1, metric values are from low (least climate-smart) to high (most climate-smart). If direction = -1, metric values are from high (least climate-smart) to low (most climate-smart). #' @param percentile cut-off threshold for determining whether an area is a climate priority area or not (e.g., lower 35th percentile of warming or upper 65th percentile of acidification). Note that the percentile here is the lower limit of the threshold. @@ -414,39 +410,37 @@ splnr_climate_feature_assignTargets <- function(climateSmartDF, #' @importFrom rlang .data #' #' @examples -#' Features <- dat_species_bin %>% -#' dplyr::select(-"cellID") +#' Features <- dat_species_bin #' -#' target <- Features %>% +#' targets <- Features %>% #' sf::st_drop_geometry() %>% #' colnames() %>% #' data.frame() %>% #' setNames(c("feature")) %>% #' dplyr::mutate(target = 0.3) #' -#' metric_df <- dat_clim -#' -#' #' Feature_Approach <- splnr_climate_featureApproach( -#' featuresDF = dat_species_bin, -#' metricDF = metric_df, targetsDF = target, direction = 1 +#' features = dat_species_bin, +#' metric = dat_clim, +#' targets = targets, +#' direction = 1 #' ) #' out_sf <- Feature_Approach$Features #' targets <- Feature_Approach$Targets -splnr_climate_featureApproach <- function(featuresDF, - metricDF, - targetsDF, +splnr_climate_featureApproach <- function(features, + metric, + targets, direction, percentile = 35, refugiaTarget = 0.3) { - assertthat::assert_that(inherits(featuresDF, "sf"), - "cellID" %in% names(featuresDF), - is.data.frame(metricDF), - "cellID" %in% names(metricDF), - is.data.frame(targetsDF), - "feature" %in% names(targetsDF), - "target" %in% names(targetsDF), + #TODO Check that geometry is the same in all the asserts + + assertthat::assert_that(inherits(features, "sf"), + inherits(metric, "sf"), + is.data.frame(targets), + "feature" %in% names(targets), + "target" %in% names(targets), direction %in% c(-1, 1), is.numeric(percentile), percentile >= 0 && percentile <= 100, @@ -455,12 +449,14 @@ splnr_climate_featureApproach <- function(featuresDF, featureFeatures <- splnr_climate_feature_preprocess( - featuresDF = featuresDF, metricDF = metricDF, - direction = direction, percentile = percentile + features = features, + metric = metric, + direction = direction, + percentile = percentile ) featureTargets <- splnr_climate_feature_assignTargets( - targetsDF = targetsDF, + targets = targets, featureFeatures, refugiaTarget = refugiaTarget ) return(list(Features = featureFeatures, Targets = featureTargets)) @@ -469,9 +465,9 @@ splnr_climate_featureApproach <- function(featuresDF, ##### Percentile Approach #### #' Preprocessing for the percentile climate-smart approach #' This function filters the species' distributions to their climate-smart areas only. -#' @param featuresDF feature sf object which should have a column for cellID +#' @param features feature sf object +#' @param metric climate metric `sf` object with 'metric' as the column name of the metric values per planning unit. #' @param percentile cut-off threshold for determining whether an area is a climate priority area or not (e.g., lower 35th percentile of warming or upper 65th percentile of acidification). Note that the percentile here is the lower limit of the threshold. -#' @param metricDF climate metric data.frame with 'metric' as the column name of the metric values per planning unit. This should also have a column for the cellID #' @param direction If direction = 1, metric values are from low (least climate-smart) to high (most climate-smart). If direction = -1, metric values are from high (least climate-smart) to low (most climate-smart). #' #' @return A new sf dataframe that has cutoffs applied. @@ -481,40 +477,32 @@ splnr_climate_featureApproach <- function(featuresDF, #' @importFrom rlang .data #' #' @examples -#' metric_df <- dat_clim -#' -#' dat_species_binDF <- dat_species_bin %>% -#' sf::st_drop_geometry() #' #' out_sf <- splnr_climate_percentile_preprocess( -#' featuresDF = dat_species_bin, -#' percentile = 5, metricDF = metric_df, direction = 1 +#' features = dat_species_bin, +#' metric = dat_clim, +#' percentile = 5, +#' direction = 1 #' ) -splnr_climate_percentile_preprocess <- function(featuresDF, +splnr_climate_percentile_preprocess <- function(features, + metric, percentile, - metricDF, direction) { - if (any(apply(metricDF, 2, is.na)[, "metric"])) { + if (any(apply(metric, 2, is.na)[, "metric"])) { print("There are some NAs in the metric data. Please check.") } - spp <- featuresDF %>% # Get the list of features - tibble::as_tibble() %>% - dplyr::select(-"geometry", -"cellID") %>% - names() - - metric <- metricDF %>% # Make sure metric df is a data.frame - dplyr::mutate(cellID = dplyr::row_number()) %>% + spp <- features %>% # Get the list of features sf::st_drop_geometry() %>% - tibble::as_tibble() + names() percentileList <- list() for (i in 1:length(spp)) { - df <- featuresDF %>% - tibble::as_tibble() %>% - dplyr::select(!!rlang::sym(spp[i]), "cellID") %>% # Select 1 feature at a time - dplyr::left_join(metric, by = "cellID") %>% # Join with the metric layer - dplyr::select(-"cellID") + + df <- features %>% + dplyr::select(!!rlang::sym(spp[i]),) %>% # Select 1 feature at a time + sf::st_join(metric, join = sf::st_equals) %>% # Join with the metric layer + sf::st_drop_geometry() # Drop here otherwise we get multiple version below filteredDF <- df %>% dplyr::filter(!!rlang::sym(spp[i]) == 1) # Select only areas with presences @@ -550,11 +538,10 @@ splnr_climate_percentile_preprocess <- function(featuresDF, dplyr::select(!!rlang::sym(paste0(spp[i], "_filtered"))) } - resultDF <- do.call(dplyr::bind_cols, percentileList) %>% # Create sf object as output dplyr::rename_all(~ stringr::str_sub(.x, end = -10)) %>% - dplyr::bind_cols(featuresDF %>% dplyr::select("cellID", "geometry")) %>% - dplyr::select("cellID", tidyselect::everything()) %>% + dplyr::bind_cols(features %>% dplyr::select("geometry")) %>% + dplyr::select(tidyselect::everything()) %>% sf::st_as_sf(sf_column_name = "geometry") return(resultDF) @@ -562,8 +549,8 @@ splnr_climate_percentile_preprocess <- function(featuresDF, #' Function to assign targets for the percentile approach #' -#' @param featuresDF feature sf object which should have a column for cellID -#' @param targetsDF `data.frame`with list of features under "feature" column and their corresponding targets under "target" column +#' @param features feature sf object +#' @param targets `data.frame`with list of features under "feature" column and their corresponding targets under "target" column #' @param climateSmartDF `sf` object produced using the function `splnr_climate_percentile_preprocess()` #' #' @return A new sf dataframe that has cutoffs applied. @@ -573,55 +560,51 @@ splnr_climate_percentile_preprocess <- function(featuresDF, #' @importFrom rlang .data #' #' @examples -#' Features <- dat_species_bin %>% -#' dplyr::select(-"cellID") +#' Features <- dat_species_bin #' -#' target <- Features %>% +#' targets <- Features %>% #' sf::st_drop_geometry() %>% #' colnames() %>% #' data.frame() %>% #' setNames(c("feature")) %>% #' dplyr::mutate(target = 0.3) #' -#' metric_df <- dat_clim -#' #' dat_species_binDF <- dat_species_bin %>% #' sf::st_drop_geometry() #' #' out_sf <- splnr_climate_percentile_preprocess( -#' featuresDF = dat_species_bin, -#' percentile = 35, metricDF = metric_df, direction = 1 +#' features = dat_species_bin, +#' metric = dat_clim, +#' percentile = 35, +#' direction = 1 #' ) #' #' targets <- splnr_climate_percentile_assignTargets( -#' featuresDF = dat_species_bin, -#' targetsDF = target, +#' features = dat_species_bin, +#' targets = targets, #' climateSmartDF = out_sf #' ) -splnr_climate_percentile_assignTargets <- function(featuresDF, +splnr_climate_percentile_assignTargets <- function(features, climateSmartDF, - targetsDF) { - spp <- featuresDF %>% # Get the list of features - tibble::as_tibble() %>% - dplyr::select(-"cellID", -"geometry") %>% + targets) { + spp <- features %>% # Get the list of features + sf::st_drop_geometry() %>% names() suppressMessages({ - df <- featuresDF %>% + df <- features %>% sf::st_drop_geometry() %>% dplyr::mutate_all(~ ifelse(is.na(.), 0, .)) %>% tibble::as_tibble() %>% - dplyr::select(-"cellID") %>% dplyr::summarize(dplyr::across(dplyr::everything(), sum)) %>% # Get the # of planning units where feature is present tidyr::pivot_longer(tidyselect::everything(), names_to = "feature", values_to = "original") %>% - dplyr::left_join(targetsDF) # %>% + dplyr::left_join(targets) # %>% # dplyr::mutate(feature = paste0(.data$feature, "_filtered")) # Change names df1 <- climateSmartDF %>% sf::st_drop_geometry() %>% dplyr::mutate_all(~ ifelse(is.na(.), 0, .)) %>% tibble::as_tibble() %>% - dplyr::select(-"cellID") %>% dplyr::summarize(dplyr::across(dplyr::everything(), sum)) %>% # Get the # of planning units selected using the climate-smart approach tidyr::pivot_longer(tidyselect::everything(), names_to = "feature", values_to = "filtered") @@ -639,9 +622,9 @@ splnr_climate_percentile_assignTargets <- function(featuresDF, #' Function to run the percentile approach #' -#' @param featuresDF feature `sf`object which should have a column for cellID -#' @param targetsDF `data.frame`with list of features under "feature" column and their corresponding targets under "target" column -#' @param metricDF climate metric data.frame with 'metric' as the column name of the metric values per planning unit. This should also have a column for the cellID +#' @param features feature `sf`object +#' @param metric climate metric `sf` object with 'metric' as the column name of the metric values per planning unit. +#' @param targets `data.frame`with list of features under "feature" column and their corresponding targets under "target" column #' @param direction If direction = 1, metric values are from low (least climate-smart) to high (most climate-smart). If direction = -1, metric values are from high (least climate-smart) to low (most climate-smart). #' @param percentile cut-off threshold for determining whether an area is a climate priority area or not (e.g., lower 35th percentile of warming or upper 65th percentile of acidification). Note that the percentile here is the lower limit of the threshold. #' @@ -651,53 +634,52 @@ splnr_climate_percentile_assignTargets <- function(featuresDF, #' @importFrom rlang .data #' #' @examples -#' Features <- dat_species_bin %>% -#' dplyr::select(-"cellID") #' -#' target <- Features %>% +#' targets <- dat_species_bin %>% #' sf::st_drop_geometry() %>% #' colnames() %>% #' data.frame() %>% #' setNames(c("feature")) %>% #' dplyr::mutate(target = 0.3) #' -#' metric_df <- dat_clim -#' -#' #' Percentile_Approach <- splnr_climate_percentileApproach( -#' featuresDF = dat_species_bin, -#' metricDF = metric_df, targetsDF = target, direction = 1 +#' features = dat_species_bin, +#' metric = dat_clim, +#' targets = targets, +#' direction = 1 #' ) #' out_sf <- Percentile_Approach$Features #' targets <- Percentile_Approach$Targets -splnr_climate_percentileApproach <- function(featuresDF, - metricDF, - targetsDF, +splnr_climate_percentileApproach <- function(features, + metric, + targets, direction, percentile = 35) { - assertthat::assert_that(inherits(featuresDF, "sf"), - "cellID" %in% names(featuresDF), - is.data.frame(metricDF), - "cellID" %in% names(metricDF), - is.data.frame(targetsDF), - "feature" %in% names(targetsDF), - "target" %in% names(targetsDF), + assertthat::assert_that(inherits(features, "sf"), + inherits(metric, "sf"), + is.data.frame(targets), + "feature" %in% names(targets), + "target" %in% names(targets), direction %in% c(-1, 1), is.numeric(percentile), percentile >= 0 && percentile <= 100) percentileFeatures <- splnr_climate_percentile_preprocess( - featuresDF = featuresDF, metricDF = metricDF, - direction = direction, percentile = percentile + features = features, + metric = metric, + direction = direction, + percentile = percentile ) percentileTargets <- splnr_climate_percentile_assignTargets( - featuresDF = featuresDF, - targetsDF = targetsDF, + features = features, + targets = targets, percentileFeatures ) return(list(Features = percentileFeatures, Targets = percentileTargets)) } + + ##### Penalty Approach ##### diff --git a/R/utils.R b/R/utils.R index 4781cf8e..58b4a0da 100644 --- a/R/utils.R +++ b/R/utils.R @@ -34,8 +34,8 @@ splnr_create_polygon <- function(x, cCRS = "EPSG:4326") { #' Remove NAs from spatial data using nearest neighbour #' -#' `splnr_replace_NAs()` allows you to replace NA values in your data with the value of the nearest neighbor. -#' The nearest neighbor is determined using `st_nearest_feature()` from the `sf` package. +#' `splnr_replace_NAs()` allows you to replace NA values in your data with the value of the nearest neighbour. +#' The nearest neighbour is determined using `st_nearest_feature()` from the `sf` package. #' #' @param df An `sf` dataframe #' @param vari Variable to remove NAs from @@ -59,6 +59,7 @@ splnr_replace_NAs <- function(df, vari) { if (sum(is.na(dplyr::pull(df, !!rlang::sym(vari)))) > 0) { # Check if there are NAs gp <- df %>% + tibble::rowid_to_column("cellID") %>% # Add cellID to reorder df later dplyr::mutate(isna = is.na(!!rlang::sym(vari))) gp <- split(gp, f = as.factor(gp$isna)) @@ -70,7 +71,8 @@ splnr_replace_NAs <- function(df, vari) { df <- rbind(gp$`FALSE`, gp$`TRUE`) %>% dplyr::select(-"isna") %>% - dplyr::arrange(.data$cellID) + dplyr::arrange(.data$cellID) %>% + dplyr::select(-"cellID") # Remove added column } return(df) } @@ -91,7 +93,7 @@ splnr_replace_NAs <- function(df, vari) { #' #' @importFrom rlang := #' @examples -#' dat <- dat_region %>% dplyr::select(-cellID) +#' dat <- dat_region #' nam <- c("Region1" = "SE Aust", "Region2" = "Tas", "Region3" = "NE Aust") #' df <- splnr_match_names(dat, nam) splnr_match_names <- function(dat, nam) { @@ -165,7 +167,7 @@ splnr_scale_01 <- function(dat, col_name) { #' #' @examples #' df <- dat_species_prob %>% -#' splnr_featureNames(exclude = c("cellID")) +#' splnr_featureNames() splnr_featureNames <- function(dat, exclude = NA) { assertthat::assert_that( @@ -174,9 +176,9 @@ splnr_featureNames <- function(dat, exclude = NA) { ) if (is.na(exclude)) { - exclude <- c("Cost_", "cellID") + exclude <- c("Cost_") } else { - exclude <- c("Cost_", "cellID", exclude) + exclude <- c("Cost_", exclude) } dat <- dat %>% @@ -195,7 +197,7 @@ splnr_featureNames <- function(dat, exclude = NA) { #' #' @param df An sf object to sort by Lon and Lat #' -#' @return A sorted sf object with the additionl cellID column +#' @return A sorted sf object #' @export #' #' @examples @@ -211,8 +213,6 @@ splnr_arrangeFeatures <- function(df) { ) df <- df[order(xy[, "X"], xy[, "Y"]), ] - df <- df %>% - dplyr::mutate(cellID = dplyr::row_number()) } diff --git a/data-raw/DATASET.R b/data-raw/DATASET.R index f87ccc26..59914c78 100644 --- a/data-raw/DATASET.R +++ b/data-raw/DATASET.R @@ -24,9 +24,7 @@ dat_bndry <- dplyr::tibble(x = 100, y = seq(-50, 0, by = 1)) %>% # Use boundary to create grid dat_PUs <- sf::st_make_grid(dat_bndry, cellsize = 2) %>% - sf::st_sf() %>% - dplyr::mutate(cellID = dplyr::row_number()) # Add a cell ID reference - + sf::st_sf() # Create some regionalisations dat_region <- dat_PUs %>% @@ -54,16 +52,14 @@ col_name <- dat_species_prob %>% colnames() dat_species_bin <- dat_species_prob %>% - dplyr::as_tibble() %>% dplyr::mutate(dplyr::across( - -dplyr::any_of(c("cellID", "geometry")), # Apply to all columns except geometry and cellID + -dplyr::any_of(c("geometry")), # Apply to all columns except geometry and cellID ~ dplyr::case_when( . >= 0.5 ~ 1, . < 0.5 ~ 0, is.na(.data) ~ 0 ) - )) %>% - sf::st_as_sf() + )) # create second species_bin data set with unused species dat_species_bin2 <- dat_species_bin %>% @@ -73,9 +69,12 @@ dat_species_bin2 <- dat_species_bin %>% # Add a random MPA dat_mpas <- dat_PUs %>% sf::st_sf() %>% + tibble::rowid_to_column("cellID") %>% # Add a cell ID reference dplyr::mutate(wdpa = ifelse((cellID > 33 & cellID < 38) | (cellID > 63 & cellID < 68) | - (cellID > 93 & cellID < 98), 1, 0)) + (cellID > 93 & cellID < 98), 1, 0)) %>% + dplyr::select(-"cellID") + # Add a problem object dat_problem <- problem(dat_species_bin %>% dplyr::mutate(Cost = runif(n = dim(.)[[1]])), @@ -127,6 +126,22 @@ dat_bathy <- oceandatr::get_bathymetry(spatial_grid = dat_PUs, classify_bathymetry = FALSE) + +#TODO Need to sort out the datasets that are not created here + +load("data/spDataFiltered.rda") +spDataFiltered <- spDataFiltered %>% + dplyr::select(-"cellID") + +load("data/MPAsCoralSea.rda") +MPAsCoralSea <- MPAsCoralSea %>% + dplyr::select(-"cellID") + +load("data/CoralSeaVelocity.rda") +CoralSeaVelocity <- CoralSeaVelocity %>% + dplyr::select(-"cellID") + + # Save the data usethis::use_data(dat_bndry, dat_PUs, @@ -142,5 +157,8 @@ usethis::use_data(dat_bndry, dat_category2, dat_clim, dat_bathy, + spDataFiltered, + MPAsCoralSea, + CoralSeaVelocity, overwrite = TRUE ) diff --git a/data-raw/testOptimalityGap.R b/data-raw/testOptimalityGap.R index a05a4282..439e0e00 100644 --- a/data-raw/testOptimalityGap.R +++ b/data-raw/testOptimalityGap.R @@ -63,8 +63,7 @@ Bndry <- dplyr::tibble(x = 60, y = seq(-60, 0, by = 1)) %>% # Use boundary to create grid PUs <- sf::st_make_grid(Bndry, cellsize = 0.125) %>% - sf::st_sf() %>% - dplyr::mutate(cellID = dplyr::row_number()) + sf::st_sf() feature_num <- c(25, 50, 100, 500)#, 1000)#, 5000, 10000)#, 50000, 100000) PU_cellsize <- c(2,1,0.5,0.25,0.125) @@ -75,8 +74,7 @@ counter = 1 for (k in 1:length(PU_cellsize)) { PUs <- sf::st_make_grid(Bndry, cellsize = PU_cellsize[k]) %>% - sf::st_sf() %>% - dplyr::mutate(cellID = dplyr::row_number()) + sf::st_sf() for (j in 1:length(feature_num)) { @@ -129,8 +127,7 @@ counter = 1 for (k in 1:length(PU_cellsize)) { PUs <- sf::st_make_grid(Bndry, cellsize = PU_cellsize[k]) %>% - sf::st_sf() %>% - dplyr::mutate(cellID = dplyr::row_number()) + sf::st_sf() for (j in 1:length(feature_num)) { @@ -192,8 +189,7 @@ counter = 1 for (k in 1:length(PU_cellsize)) { PUs <- sf::st_make_grid(Bndry, cellsize = PU_cellsize[k]) %>% - sf::st_sf() %>% - dplyr::mutate(cellID = dplyr::row_number()) + sf::st_sf() for (j in 1:length(feature_num)) { diff --git a/data/CoralSeaVelocity.rda b/data/CoralSeaVelocity.rda index 12dcdb4b..e4f310ab 100644 Binary files a/data/CoralSeaVelocity.rda and b/data/CoralSeaVelocity.rda differ diff --git a/data/MPAsCoralSea.rda b/data/MPAsCoralSea.rda index 6fa5d6d9..047e959d 100644 Binary files a/data/MPAsCoralSea.rda and b/data/MPAsCoralSea.rda differ diff --git a/data/dat_PUs.rda b/data/dat_PUs.rda index 1bdc4fdd..18822c3b 100644 Binary files a/data/dat_PUs.rda and b/data/dat_PUs.rda differ diff --git a/data/dat_bathy.rda b/data/dat_bathy.rda index 390eff9e..b3ad1b46 100644 Binary files a/data/dat_bathy.rda and b/data/dat_bathy.rda differ diff --git a/data/dat_bndry.rda b/data/dat_bndry.rda index 45c6b444..c9303d3e 100644 Binary files a/data/dat_bndry.rda and b/data/dat_bndry.rda differ diff --git a/data/dat_clim.rda b/data/dat_clim.rda index 6f66dab6..3c56ce0c 100644 Binary files a/data/dat_clim.rda and b/data/dat_clim.rda differ diff --git a/data/dat_mpas.rda b/data/dat_mpas.rda index 17c892b6..05d9a5b4 100644 Binary files a/data/dat_mpas.rda and b/data/dat_mpas.rda differ diff --git a/data/dat_region.rda b/data/dat_region.rda index dca2ff02..cf59a238 100644 Binary files a/data/dat_region.rda and b/data/dat_region.rda differ diff --git a/data/dat_species_bin.rda b/data/dat_species_bin.rda index 3f614418..8ec626ac 100644 Binary files a/data/dat_species_bin.rda and b/data/dat_species_bin.rda differ diff --git a/data/dat_species_bin2.rda b/data/dat_species_bin2.rda index b0c9c8bc..1ab31954 100644 Binary files a/data/dat_species_bin2.rda and b/data/dat_species_bin2.rda differ diff --git a/data/dat_species_prob.rda b/data/dat_species_prob.rda index 3c8d5bd5..3486705d 100644 Binary files a/data/dat_species_prob.rda and b/data/dat_species_prob.rda differ diff --git a/data/spDataFiltered.rda b/data/spDataFiltered.rda index 326e17da..d9172f1d 100644 Binary files a/data/spDataFiltered.rda and b/data/spDataFiltered.rda differ diff --git a/docs/404.html b/docs/404.html index 580b1688..cc8d7112 100644 --- a/docs/404.html +++ b/docs/404.html @@ -75,7 +75,7 @@ diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index c3f4aa48..1add8f31 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -49,7 +49,7 @@ diff --git a/docs/LICENSE.html b/docs/LICENSE.html index d3fd61da..ed33049e 100644 --- a/docs/LICENSE.html +++ b/docs/LICENSE.html @@ -53,7 +53,7 @@ diff --git a/docs/articles/ClimateSmart.html b/docs/articles/ClimateSmart.html index d8d9fcab..70b88183 100644 --- a/docs/articles/ClimateSmart.html +++ b/docs/articles/ClimateSmart.html @@ -117,7 +117,7 @@

Analysis Region
 Bndry <- splnr_get_boundary(Limits = Region, Type = Type, cCRS = cCRS)
 #> Reading layer `ne_10m_geography_marine_polys' from data source 
-#>   `/private/var/folders/_r/mcmw_qtn0m7cd23cbdqfszl40000gp/T/RtmpQilTyY/ne_10m_geography_marine_polys.shp' 
+#>   `/private/var/folders/_r/mcmw_qtn0m7cd23cbdqfszl40000gp/T/RtmpMuMJpx/ne_10m_geography_marine_polys.shp' 
 #>   using driver `ESRI Shapefile'
 #> Simple feature collection with 306 features and 37 fields
 #> Geometry type: MULTIPOLYGON
@@ -179,7 +179,7 @@ 

Convert the probabilities to b datEx_species_bin <- spDataFiltered %>% dplyr::as_tibble() %>% dplyr::mutate(dplyr::across( - -dplyr::any_of(c("cellID", "geometry")), # Don't apply to geometry/cellID + -dplyr::any_of(c("geometry")), # Don't apply to geometry ~ dplyr::case_when( . >= 0.5 ~ 1, . < 0.5 ~ 0, @@ -190,7 +190,6 @@

Convert the probabilities to b col_name <- spDataFiltered %>% sf::st_drop_geometry() %>% - dplyr::select(-"cellID") %>% colnames()

@@ -257,7 +256,6 @@

Climate-smart spatial planning
 target <- datEx_species_bin %>%
   sf::st_drop_geometry() %>%
-  dplyr::select(-"cellID") %>%
   colnames() %>%
   data.frame() %>%
   setNames(c("feature")) %>%
@@ -266,21 +264,19 @@ 

Climate-smart spatial planningCPA_Approach <- splnr_climate_priorityAreaApproach( featuresDF = datEx_species_bin, - metricDF = metric_df, targetsDF = target, direction = -1, refugiaTarget = 1 + metricDF = metric_df, + targetsDF = target, + direction = -1, refugiaTarget = 1 ) out_sf <- CPA_Approach$Features %>% - dplyr::left_join( + sf::st_join( datEx_species_bin %>% - sf::st_drop_geometry() %>% dplyr::select( - "cellID", tidyselect::starts_with("Cost_") ), - by = "cellID" - ) %>% - dplyr::left_join(metric_df %>% - sf::st_drop_geometry(), by = "cellID") + join = sf::st_equals) %>% + sf::st_join(metric_df, join = sf::st_equals) targets <- CPA_Approach$Targets

We now add other information required to perform the spatial @@ -293,7 +289,6 @@

Climate-smart spatial planningsf::st_drop_geometry() %>% dplyr::select( -tidyselect::starts_with("Cost_"), - -"cellID", -tidyselect::starts_with("metric") ) %>% names() @@ -322,7 +317,7 @@

Run the climate-smart spatial pl

However, we are also interested how climate-smart the selected planning units in the solution actually are. For this, we can use a -kernel density plot

+kernel density plot.

 (ggClimDens <- splnr_plot_climKernelDensity(
   soln = list(dat_solnClim),
@@ -342,7 +337,6 @@ 

Percentile Approach
 target <- datEx_species_bin %>%
   sf::st_drop_geometry() %>%
-  dplyr::select(-"cellID") %>%
   colnames() %>%
   data.frame() %>%
   setNames(c("feature")) %>%
@@ -355,17 +349,14 @@ 

Percentile Approach#> [1] "Lower values mean more climate-smart areas." out_sf <- Percentile_Approach$Features %>% - dplyr::left_join( + sf::st_join( datEx_species_bin %>% - sf::st_drop_geometry() %>% dplyr::select( - "cellID", tidyselect::starts_with("Cost_") ), - by = "cellID" + join = sf::st_equals ) %>% - dplyr::left_join(metric_df %>% - sf::st_drop_geometry(), by = "cellID") + sf::st_join(metric_df, join = sf::st_equals) targets <- Percentile_Approach$Targets

We now add other information required to perform the spatial @@ -378,7 +369,6 @@

Percentile Approachsf::st_drop_geometry() %>% dplyr::select( -tidyselect::starts_with("Cost_"), - -"cellID", -tidyselect::starts_with("metric") ) %>% names() @@ -419,7 +409,6 @@

Feature Approach
 target <- datEx_species_bin %>%
   sf::st_drop_geometry() %>%
-  dplyr::select(-"cellID") %>%
   colnames() %>%
   data.frame() %>%
   setNames(c("feature")) %>%
@@ -427,22 +416,20 @@ 

Feature Approach Feature_Approach <- splnr_climate_featureApproach( featuresDF = datEx_species_bin, - metricDF = metric_df, targetsDF = target, direction = 1 + metricDF = metric_df, + targetsDF = target, + direction = 1 ) #> [1] "Higher values mean more climate-smart areas." out_sf <- Feature_Approach$Features %>% - dplyr::left_join( + sf::st_join( datEx_species_bin %>% - sf::st_drop_geometry() %>% dplyr::select( - "cellID", tidyselect::starts_with("Cost_") ), - by = "cellID" - ) %>% - dplyr::left_join(metric_df %>% - sf::st_drop_geometry(), by = "cellID") + join = sf::st_equals) %>% + sf::st_join(metric_df, join = sf::st_equals) targets <- Feature_Approach$Targets

We now add other information required to perform the spatial @@ -455,7 +442,6 @@

Feature Approach sf::st_drop_geometry() %>% dplyr::select( -tidyselect::starts_with("Cost_"), - -"cellID", -tidyselect::starts_with("metric") ) %>% names() @@ -499,7 +485,7 @@

Feature Approach diff --git a/docs/articles/ClimateSmart_files/figure-html/unnamed-chunk-11-1.png b/docs/articles/ClimateSmart_files/figure-html/unnamed-chunk-11-1.png index 5eafe0e5..6f01095a 100644 Binary files a/docs/articles/ClimateSmart_files/figure-html/unnamed-chunk-11-1.png and b/docs/articles/ClimateSmart_files/figure-html/unnamed-chunk-11-1.png differ diff --git a/docs/articles/ClimateSmart_files/figure-html/unnamed-chunk-14-1.png b/docs/articles/ClimateSmart_files/figure-html/unnamed-chunk-14-1.png deleted file mode 100644 index f3e6b790..00000000 Binary files a/docs/articles/ClimateSmart_files/figure-html/unnamed-chunk-14-1.png and /dev/null differ diff --git a/docs/articles/ClimateSmart_files/figure-html/unnamed-chunk-16-1.png b/docs/articles/ClimateSmart_files/figure-html/unnamed-chunk-16-1.png index f60a25f4..5b706493 100644 Binary files a/docs/articles/ClimateSmart_files/figure-html/unnamed-chunk-16-1.png and b/docs/articles/ClimateSmart_files/figure-html/unnamed-chunk-16-1.png differ diff --git a/docs/articles/ClimateSmart_files/figure-html/unnamed-chunk-18-1.png b/docs/articles/ClimateSmart_files/figure-html/unnamed-chunk-18-1.png deleted file mode 100644 index f793907d..00000000 Binary files a/docs/articles/ClimateSmart_files/figure-html/unnamed-chunk-18-1.png and /dev/null differ diff --git a/docs/articles/ClimateSmart_files/figure-html/unnamed-chunk-19-1.png b/docs/articles/ClimateSmart_files/figure-html/unnamed-chunk-19-1.png index 8cc3412b..c85a3bf1 100644 Binary files a/docs/articles/ClimateSmart_files/figure-html/unnamed-chunk-19-1.png and b/docs/articles/ClimateSmart_files/figure-html/unnamed-chunk-19-1.png differ diff --git a/docs/articles/ClimateSmart_files/figure-html/unnamed-chunk-20-1.png b/docs/articles/ClimateSmart_files/figure-html/unnamed-chunk-20-1.png index 5f5bf6ee..3c15f246 100644 Binary files a/docs/articles/ClimateSmart_files/figure-html/unnamed-chunk-20-1.png and b/docs/articles/ClimateSmart_files/figure-html/unnamed-chunk-20-1.png differ diff --git a/docs/articles/ClimateSmart_files/figure-html/unnamed-chunk-22-1.png b/docs/articles/ClimateSmart_files/figure-html/unnamed-chunk-22-1.png deleted file mode 100644 index 54137939..00000000 Binary files a/docs/articles/ClimateSmart_files/figure-html/unnamed-chunk-22-1.png and /dev/null differ diff --git a/docs/articles/ClimateSmart_files/figure-html/unnamed-chunk-24-1.png b/docs/articles/ClimateSmart_files/figure-html/unnamed-chunk-24-1.png index 2394a41f..3593088a 100644 Binary files a/docs/articles/ClimateSmart_files/figure-html/unnamed-chunk-24-1.png and b/docs/articles/ClimateSmart_files/figure-html/unnamed-chunk-24-1.png differ diff --git a/docs/articles/ClimateSmart_files/figure-html/unnamed-chunk-9-1.png b/docs/articles/ClimateSmart_files/figure-html/unnamed-chunk-9-1.png deleted file mode 100644 index 03b6ac8a..00000000 Binary files a/docs/articles/ClimateSmart_files/figure-html/unnamed-chunk-9-1.png and /dev/null differ diff --git a/docs/articles/GlobalFishingWatch.html b/docs/articles/GlobalFishingWatch.html index 88c23a41..2162a592 100644 --- a/docs/articles/GlobalFishingWatch.html +++ b/docs/articles/GlobalFishingWatch.html @@ -282,7 +282,7 @@

Hierarchy of vessels gear types : diff --git a/docs/articles/GlobalFishingWatch_files/figure-html/unnamed-chunk-14-1.png b/docs/articles/GlobalFishingWatch_files/figure-html/unnamed-chunk-14-1.png index f36a0588..db434a66 100644 Binary files a/docs/articles/GlobalFishingWatch_files/figure-html/unnamed-chunk-14-1.png and b/docs/articles/GlobalFishingWatch_files/figure-html/unnamed-chunk-14-1.png differ diff --git a/docs/articles/GlobalFishingWatch_files/figure-html/unnamed-chunk-16-1.png b/docs/articles/GlobalFishingWatch_files/figure-html/unnamed-chunk-16-1.png index 7ba96a03..f67b90cc 100644 Binary files a/docs/articles/GlobalFishingWatch_files/figure-html/unnamed-chunk-16-1.png and b/docs/articles/GlobalFishingWatch_files/figure-html/unnamed-chunk-16-1.png differ diff --git a/docs/articles/GlobalFishingWatch_files/figure-html/unnamed-chunk-8-1.png b/docs/articles/GlobalFishingWatch_files/figure-html/unnamed-chunk-8-1.png index 652dbf68..749e8da8 100644 Binary files a/docs/articles/GlobalFishingWatch_files/figure-html/unnamed-chunk-8-1.png and b/docs/articles/GlobalFishingWatch_files/figure-html/unnamed-chunk-8-1.png differ diff --git a/docs/articles/GlobalFishingWatch_files/figure-html/unnamed-chunk-9-1.png b/docs/articles/GlobalFishingWatch_files/figure-html/unnamed-chunk-9-1.png index 70c06158..6bf932ec 100644 Binary files a/docs/articles/GlobalFishingWatch_files/figure-html/unnamed-chunk-9-1.png and b/docs/articles/GlobalFishingWatch_files/figure-html/unnamed-chunk-9-1.png differ diff --git a/docs/articles/MultipleUse.html b/docs/articles/MultipleUse.html index 744337a8..6763450b 100644 --- a/docs/articles/MultipleUse.html +++ b/docs/articles/MultipleUse.html @@ -107,7 +107,7 @@

Analysis Region
 Bndry <- splnr_get_boundary(Limits = Region, Type = Type, cCRS = cCRS)
 #> Reading layer `ne_10m_geography_marine_polys' from data source 
-#>   `/private/var/folders/_r/mcmw_qtn0m7cd23cbdqfszl40000gp/T/RtmpBoWWk8/ne_10m_geography_marine_polys.shp' 
+#>   `/private/var/folders/_r/mcmw_qtn0m7cd23cbdqfszl40000gp/T/Rtmp0tUE3F/ne_10m_geography_marine_polys.shp' 
 #>   using driver `ESRI Shapefile'
 #> Simple feature collection with 306 features and 37 fields
 #> Geometry type: MULTIPOLYGON
@@ -190,7 +190,6 @@ 

Convert the col_name <- spDataFiltered %>% sf::st_drop_geometry() %>% - dplyr::select(-"cellID") %>% colnames()

@@ -580,10 +579,8 @@

Adding constraints
 mpas <- MPAsCoralSea %>%
   dplyr::mutate(zone = "zone 1") %>%
-  dplyr::rename(
-    pu = cellID,
-    status = wdpa
-  ) %>%
+  dplyr::rename(status = wdpa) %>%
+  tibble::rowid_to_column("pu") %>% 
   sf::st_drop_geometry() %>%
   tibble::tibble() %>%
   dplyr::filter(status == 1)

@@ -755,19 +752,17 @@

Common targets across zones
 datSpecZone1 <- datEx_species_bin %>%
-  sf::st_drop_geometry() %>%
-  dplyr::rename_at(dplyr::vars(-cellID), ~ paste0(.x, "_zone1"))
+  dplyr::rename_at(dplyr::vars(-geometry), ~ paste0(.x, "_zone1"))
 
 featuresZone1 <- datSpecZone1 %>%
-  dplyr::select(-"cellID") %>%
+  sf::st_drop_geometry() %>%
   colnames()
 
 datSpecZone2 <- datEx_species_bin %>%
-  sf::st_drop_geometry() %>%
-  dplyr::rename_at(dplyr::vars(-cellID), ~ paste0(.x, "_zone2"))
+  dplyr::rename_at(dplyr::vars(-geometry), ~ paste0(.x, "_zone2"))
 
 featuresZone2 <- datSpecZone2 %>%
-  dplyr::select(-"cellID") %>%
+  sf::st_drop_geometry() %>%
   colnames()

We also extract the new feature names and then create the zones object, before joining the two newly created data @@ -781,9 +776,7 @@

Common targets across zones) out_sf <- datSpecZone1 %>% - dplyr::left_join(datSpecZone2, by = "cellID") %>% - dplyr::mutate(geometry = datEx_species_bin$geometry) %>% - sf::st_as_sf() %>% + sf::st_join(datSpecZone2, join = sf::st_equals) %>% dplyr::mutate( Cost1 = runif(n = dim(.)[[1]]) * 100, Cost2 = runif(n = dim(.)[[1]]) * 300 @@ -954,27 +947,24 @@

Targets across some (but not all)

We then create a zones object for three different zones:

 datSpecZone1 <- datEx_species_bin %>%
-  sf::st_drop_geometry() %>%
-  dplyr::rename_at(dplyr::vars(-cellID), ~ paste0(.x, "_zone1"))
+  dplyr::rename_at(dplyr::vars(-geometry), ~ paste0(.x, "_zone1"))
 
 featuresZone1 <- datSpecZone1 %>%
-  dplyr::select(-"cellID") %>%
+  sf::st_drop_geometry() %>%
   colnames()
 
 datSpecZone2 <- datEx_species_bin %>%
-  sf::st_drop_geometry() %>%
-  dplyr::rename_at(dplyr::vars(-cellID), ~ paste0(.x, "_zone2"))
+  dplyr::rename_at(dplyr::vars(-geometry), ~ paste0(.x, "_zone2"))
 
 featuresZone2 <- datSpecZone2 %>%
-  dplyr::select(-"cellID") %>%
+  sf::st_drop_geometry() %>%
   colnames()
 
 datSpecZone3 <- datEx_species_bin %>%
-  sf::st_drop_geometry() %>%
-  dplyr::rename_at(dplyr::vars(-cellID), ~ paste0(.x, "_zone3"))
+  dplyr::rename_at(dplyr::vars(-geometry), ~ paste0(.x, "_zone3"))
 
 featuresZone3 <- datSpecZone3 %>%
-  dplyr::select(-"cellID") %>%
+  sf::st_drop_geometry() %>%
   colnames()
 
 z12 <- prioritizr::zones(
@@ -989,8 +979,8 @@ 

Targets across some (but not all)
 # NOTE: When using sf input, we need as many cost columns as we have zones
 out_sf <- datSpecZone1 %>%
-  dplyr::left_join(datSpecZone2, by = "cellID") %>%
-  dplyr::left_join(datSpecZone3, by = "cellID") %>%
+  sf::st_join(datSpecZone2, join = sf::st_equals) %>%
+  sf::st_join(datSpecZone3, join = sf::st_equals) %>%
   dplyr::mutate(geometry = datEx_species_bin$geometry) %>%
   sf::st_as_sf() %>%
   dplyr::mutate(
@@ -1108,7 +1098,7 @@ 
Longer-term -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/articles/index.html b/docs/articles/index.html index 534d8232..fae856d2 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -57,7 +57,7 @@

All vignettes

diff --git a/docs/articles/spatialplanr.html b/docs/articles/spatialplanr.html index bafc5082..c6190243 100644 --- a/docs/articles/spatialplanr.html +++ b/docs/articles/spatialplanr.html @@ -110,7 +110,7 @@

Analysis Region
 Bndry <- splnr_get_boundary(Limits = Region, Type = Type, cCRS = cCRS)
 #> Reading layer `ne_10m_geography_marine_polys' from data source 
-#>   `/private/var/folders/_r/mcmw_qtn0m7cd23cbdqfszl40000gp/T/RtmpFXGTcW/ne_10m_geography_marine_polys.shp' 
+#>   `/private/var/folders/_r/mcmw_qtn0m7cd23cbdqfszl40000gp/T/RtmpYDUd6r/ne_10m_geography_marine_polys.shp' 
 #>   using driver `ESRI Shapefile'
 #> Simple feature collection with 306 features and 37 fields
 #> Geometry type: MULTIPOLYGON
@@ -253,8 +253,7 @@ 

Convert the probabilities to b
 (ggFeatNo <- splnr_plot(df = datEx_species_bin, 
                         col_names =  colnames(datEx_species_bin %>% 
-                                                sf::st_drop_geometry() %>% 
-                                                dplyr::select(-"cellID")),
+                                                sf::st_drop_geometry()),
                         plot_title = "", 
                         legend_title = "Number of features") +
    splnr_gg_add(
@@ -263,9 +262,10 @@ 

Convert the probabilities to b ))

-
-

Prepare Data for prioritisation -

+
+
+

Prepare Data for prioritisation +

For the spatial prioritization we also need to extract the names of our features to pass into prioritizr.

@@ -330,9 +330,10 @@ 
Other features
- +
+

Set Targets +

As shown previously, we assigned the conservation features a class reflecting their importance in the planning region. Conservation targets are then assigned a target based on their class, in our case 30% of @@ -346,10 +347,9 @@

Set Targets -

Set up conservation problem -

+
+

Set up conservation problem +

 datEx_problem <- prioritizr::problem(out_sf, feature_names, "Cost_None") %>%
   prioritizr::add_min_set_objective() %>%
@@ -357,23 +357,23 @@ 

Set up conservation problemprioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(verbose = FALSE)

-
-

Solve the conservation problem -

+
+

Solve the conservation problem +

 datEx_soln <- datEx_problem %>%
   prioritizr::solve.ConservationProblem()
-
-

Visualize Output -

+
+

Visualize Output +

There are different ways to visualize the output of the prioritization that can be loosely grouped into three categories: + Visualization of the solution + Visualization of targets + Visualization of importance scores

-
-
Visualization of the solution -
+
+

Visualization of the solution +

 (ggSoln <- splnr_plot(datEx_soln, 
                       col_names = "solution_1", 
@@ -405,9 +405,9 @@ 
Visualization of the solution -
Visualization of targets -
+
+

Visualization of targets +

To visualize how well the targets are met, we first need to extract how much suitable habitat of each feature are selected in the spatial plan. This also includes potential incidental coverage of feature that @@ -431,21 +431,21 @@

Visualization of targetsFor a circular bar plot, one additional step of data preparation needs to be done.

-# dfTargetCirc <- dfTarget %>%
-# dplyr::select("feature", "value", "group") %>%
-# na.omit()
+dfTargetCirc <- dfTarget %>%
+dplyr::select("feature", "value", "group") %>%
+na.omit()
 
-# colors <- c(
-#   "important" = "darkgreen",
-#   "representative" = "darkred"
-# )
-# legends <- c("Important", "Representative")
+colors <- c(
+  "important" = "darkgreen",
+  "representative" = "darkred"
+)
+legends <- c("Important", "Representative")
 
-# (ggCircTarg <- splnr_plot_circBplot(df = dfTargetCirc, legend_list = legends, legend_color = colors, impTarget = 30, repTarget = 10))
+(ggCircTarg <- splnr_plot_circBplot(df = dfTargetCirc, legend_list = legends, legend_color = colors, impTarget = 30, repTarget = 10))
-
-
Visualization of importance scores -
+
+

Visualization of importance scores +

Importance scores can help to assess the relative importance of an individual selected planning unit in the spatial plan (for more information, see https://prioritizr.net/reference/importance.html)

@@ -484,9 +484,9 @@
Visualization of importance scores
-
-

Comparing Spatial Plans -

+
+

Comparing Spatial Plans +

Sometimes it can be useful to have a direct comparison of two spatial plans. To show how to achieve this with this package, we first need a second conservation problem and resulting solution.

@@ -546,9 +546,9 @@

Comparing Spatial PlansSys.setenv(IUCN_REDLIST_KEY = "[Your Token]"). You can start by running rredlist::rl_use_iucn().

-
-
Set up second conservation problem -
+
+

Set up second conservation problem +

 datEx_problem2 <- prioritizr::problem(out_sf, feature_names, "Cost_None") %>%
   prioritizr::add_min_set_objective() %>%
@@ -593,9 +593,9 @@ 
Set up second conservation problem ))

-
-
Visualize comparison -
+
+

Visualize comparison +

 (ggComp <- splnr_plot_comparison(datEx_soln, datEx_soln2) +
    splnr_gg_add(
@@ -620,12 +620,11 @@ 
Visualize comparison

Plotting selection frequency

Sometimes when multiple spatial plans are generated, we are -interesting in how many times a planning unit is selected across the +interested in how many times a planning unit is selected across the array of solutions. To demonstrate how this can be done using this package, we first create an array (= portfolio) of solutions. One example of this is by using the portfolio

@@ -662,7 +661,7 @@

Plotting selection frequency -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/authors.html b/docs/authors.html index 664edbe1..1a6983d2 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -75,7 +75,7 @@

Citation

diff --git a/docs/index.html b/docs/index.html index 203eb28c..30594fef 100644 --- a/docs/index.html +++ b/docs/index.html @@ -136,7 +136,7 @@

Dev status

diff --git a/docs/pkgdown.js b/docs/pkgdown.js index 9757bf9e..1a99c65f 100644 --- a/docs/pkgdown.js +++ b/docs/pkgdown.js @@ -152,3 +152,11 @@ async function searchFuse(query, callback) { }); }); })(window.jQuery || window.$) + +document.addEventListener('keydown', function(event) { + // Check if the pressed key is '/' + if (event.key === '/') { + event.preventDefault(); // Prevent any default action associated with the '/' key + document.getElementById('search-input').focus(); // Set focus to the search input + } +}); diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 32c1be4c..06fb05a1 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -1,12 +1,12 @@ -pandoc: 3.1.11 -pkgdown: 2.1.0 +pandoc: '3.2' +pkgdown: 2.1.1 pkgdown_sha: ~ articles: ClimateSmart: ClimateSmart.html GlobalFishingWatch: GlobalFishingWatch.html MultipleUse: MultipleUse.html spatialplanr: spatialplanr.html -last_built: 2024-09-10T21:15Z +last_built: 2024-10-31T03:47Z urls: reference: https://mathmarecol.github.io/spatialplanr/reference article: https://mathmarecol.github.io/spatialplanr/articles diff --git a/docs/reference/CoralSeaVelocity.html b/docs/reference/CoralSeaVelocity.html index a7a1756f..65a8832a 100644 --- a/docs/reference/CoralSeaVelocity.html +++ b/docs/reference/CoralSeaVelocity.html @@ -50,10 +50,7 @@

Usage

Format

CoralSeaVelocity -A data frame with 397 rows and 3 columns:

cellID
-

cell ID of the planning units

- -
vocMagg_transformed
+A data frame with 397 rows and 3 columns:

vocMagg_transformed

Climate velocity column

geometry
@@ -76,7 +73,7 @@

Source<

diff --git a/docs/reference/IUCN_IA_Targets.html b/docs/reference/IUCN_IA_Targets.html index 7034c5a0..5e3e4c4a 100644 --- a/docs/reference/IUCN_IA_Targets.html +++ b/docs/reference/IUCN_IA_Targets.html @@ -79,7 +79,7 @@

Source<

diff --git a/docs/reference/MPAsCoralSea.html b/docs/reference/MPAsCoralSea.html index 6c5fdd63..cc8c627c 100644 --- a/docs/reference/MPAsCoralSea.html +++ b/docs/reference/MPAsCoralSea.html @@ -53,9 +53,6 @@

Format< A data frame with 397 rows and 17 columns:

wdpa

binary vector denoting presence or absence of a current marine protected area

-
cellID
-

cell ID of planning units

- ...

@@ -73,7 +70,7 @@

Source<

diff --git a/docs/reference/Rplot001.png b/docs/reference/Rplot001.png deleted file mode 100644 index 17a35806..00000000 Binary files a/docs/reference/Rplot001.png and /dev/null differ diff --git a/docs/reference/Rplot002.png b/docs/reference/Rplot002.png deleted file mode 100644 index c23677dc..00000000 Binary files a/docs/reference/Rplot002.png and /dev/null differ diff --git a/docs/reference/Rplot003.png b/docs/reference/Rplot003.png deleted file mode 100644 index a8e75125..00000000 Binary files a/docs/reference/Rplot003.png and /dev/null differ diff --git a/docs/reference/Rplot004.png b/docs/reference/Rplot004.png deleted file mode 100644 index 59cd958c..00000000 Binary files a/docs/reference/Rplot004.png and /dev/null differ diff --git a/docs/reference/Rplot005.png b/docs/reference/Rplot005.png deleted file mode 100644 index cfa29e01..00000000 Binary files a/docs/reference/Rplot005.png and /dev/null differ diff --git a/docs/reference/dat_PUs.html b/docs/reference/dat_PUs.html index 098398e5..7881a68e 100644 --- a/docs/reference/dat_PUs.html +++ b/docs/reference/dat_PUs.html @@ -50,10 +50,7 @@

Usage

Format

dat_PUs -A data frame with XXXX rows and XXX columns:

cellID
-

ID number for each row (or cell) of the dataset

- -
geometry
+A data frame with XXXX rows and XXX columns:

geometry

sf geometry column

... @@ -73,7 +70,7 @@

Source<

diff --git a/docs/reference/dat_bathy.html b/docs/reference/dat_bathy.html index 3a7fb744..f530c1f5 100644 --- a/docs/reference/dat_bathy.html +++ b/docs/reference/dat_bathy.html @@ -50,10 +50,7 @@

Usage

Format

dat_bathy -A data frame with bathymetry data

cellID
-

ID number for each row (or cell) of the dataset

- -
bathymetry
+A data frame with bathymetry data

bathymetry

Bathymetry data

geometry
@@ -76,7 +73,7 @@

Source<

diff --git a/docs/reference/dat_bndry.html b/docs/reference/dat_bndry.html index 68edcb04..8d7297f9 100644 --- a/docs/reference/dat_bndry.html +++ b/docs/reference/dat_bndry.html @@ -50,10 +50,7 @@

Usage

Format

dat_bndry -A data frame with XXXX rows and XXX columns:

cellID
-

ID number for each row (or cell) of the dataset

- -
geometry
+A data frame with XXXX rows and XXX columns:

geometry

sf geometry column

... @@ -73,7 +70,7 @@

Source<

diff --git a/docs/reference/dat_category.html b/docs/reference/dat_category.html index cb76a841..2d47bdac 100644 --- a/docs/reference/dat_category.html +++ b/docs/reference/dat_category.html @@ -73,7 +73,7 @@

Source< diff --git a/docs/reference/dat_category2.html b/docs/reference/dat_category2.html index 0485e0fe..5a4def95 100644 --- a/docs/reference/dat_category2.html +++ b/docs/reference/dat_category2.html @@ -73,7 +73,7 @@

Source< diff --git a/docs/reference/dat_clim.html b/docs/reference/dat_clim.html index eb3e05ec..3e5d5e50 100644 --- a/docs/reference/dat_clim.html +++ b/docs/reference/dat_clim.html @@ -50,10 +50,7 @@

Usage

Format

dat_clim -A data frame with 780 rows and 3 columns:

cellID
-

ID number for each row (or cell) of the dataset

- -
geometry
+A data frame with 780 rows and 3 columns:

geometry

sf geometry column

metric
@@ -76,7 +73,7 @@

Source<

diff --git a/docs/reference/dat_mpas.html b/docs/reference/dat_mpas.html index 91aa85c6..d0d049f8 100644 --- a/docs/reference/dat_mpas.html +++ b/docs/reference/dat_mpas.html @@ -50,10 +50,7 @@

Usage

Format

dat_mpas -A data frame with XXXX rows and XXX columns:

cellID
-

ID number for each row (or cell) of the dataset

- -
geometry
+A data frame with XXXX rows and XXX columns:

geometry

sf geometry column

wdpa
@@ -76,7 +73,7 @@

Source<

diff --git a/docs/reference/dat_region.html b/docs/reference/dat_region.html index fe3defca..fa7ff803 100644 --- a/docs/reference/dat_region.html +++ b/docs/reference/dat_region.html @@ -50,10 +50,7 @@

Usage

Format

dat_region -A data frame with XXXX rows and XXX columns:

cellID
-

ID number for each row (or cell) of the dataset

- -
geometry
+A data frame with XXXX rows and XXX columns:

geometry

sf geometry column

... @@ -73,7 +70,7 @@

Source<

diff --git a/docs/reference/dat_species_bin.html b/docs/reference/dat_species_bin.html index 4d07d01f..4ad65384 100644 --- a/docs/reference/dat_species_bin.html +++ b/docs/reference/dat_species_bin.html @@ -50,10 +50,7 @@

Usage

Format

dat_species_bin -A data frame with XXXX rows and XXX columns:

cellID
-

ID number for each row (or cell) of the dataset

- -
geometry
+A data frame with XXXX rows and XXX columns:

geometry

sf geometry column

... @@ -73,7 +70,7 @@

Source<

diff --git a/docs/reference/dat_species_bin2.html b/docs/reference/dat_species_bin2.html index fe0d6cad..6244bc26 100644 --- a/docs/reference/dat_species_bin2.html +++ b/docs/reference/dat_species_bin2.html @@ -50,10 +50,7 @@

Usage

Format

dat_species_bin2 -A data frame with XXXX rows and XXX columns:

cellID
-

ID number for each row (or cell) of the dataset

- -
geometry
+A data frame with XXXX rows and XXX columns:

geometry

sf geometry column

... @@ -73,7 +70,7 @@

Source<

diff --git a/docs/reference/dat_species_prob.html b/docs/reference/dat_species_prob.html index 0cbbfda2..e2195ed6 100644 --- a/docs/reference/dat_species_prob.html +++ b/docs/reference/dat_species_prob.html @@ -50,10 +50,7 @@

Usage

Format

dat_species_prob -A data frame with XXXX rows and XXX columns:

cellID
-

ID number for each row (or cell) of the dataset

- -
geometry
+A data frame with XXXX rows and XXX columns:

geometry

sf geometry column

... @@ -73,7 +70,7 @@

Source<

diff --git a/docs/reference/index.html b/docs/reference/index.html index 87a4630a..ef3a71e2 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -436,7 +436,7 @@

Built in datasets -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/pipe.html b/docs/reference/pipe.html index 5f0bf241..d4d6ac27 100644 --- a/docs/reference/pipe.html +++ b/docs/reference/pipe.html @@ -56,7 +56,7 @@

Usage diff --git a/docs/reference/spDataFiltered.html b/docs/reference/spDataFiltered.html index ad84b62f..c4bd52bf 100644 --- a/docs/reference/spDataFiltered.html +++ b/docs/reference/spDataFiltered.html @@ -69,7 +69,7 @@

Source< diff --git a/docs/reference/spatialplanr-package.html b/docs/reference/spatialplanr-package.html index bc3d656e..bf90e9bd 100644 --- a/docs/reference/spatialplanr-package.html +++ b/docs/reference/spatialplanr-package.html @@ -67,7 +67,7 @@

Author< diff --git a/docs/reference/splnr_apply_cutoffs.html b/docs/reference/splnr_apply_cutoffs.html index a42f1e0f..630ce178 100644 --- a/docs/reference/splnr_apply_cutoffs.html +++ b/docs/reference/splnr_apply_cutoffs.html @@ -82,7 +82,7 @@

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/splnr_arrangeFeatures.html b/docs/reference/splnr_arrangeFeatures.html index 74a8fe8e..485218c1 100644 --- a/docs/reference/splnr_arrangeFeatures.html +++ b/docs/reference/splnr_arrangeFeatures.html @@ -57,7 +57,7 @@

Arguments

Value

-

A sorted sf object with the additionl cellID column

+

A sorted sf object

@@ -75,7 +75,7 @@

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/splnr_climate_featureApproach.html b/docs/reference/splnr_climate_featureApproach.html index fd75d951..bc11832b 100644 --- a/docs/reference/splnr_climate_featureApproach.html +++ b/docs/reference/splnr_climate_featureApproach.html @@ -59,11 +59,11 @@

ArgumentsfeaturesDF -

feature sfobject which should have a column for cellID

+

feature sfobject

metricDF
-

climate metric data.frame with 'metric' as the column name of the metric values per planning unit. This should also have a column for the cellID

+

climate metric data.frame with 'metric' as the column name of the metric values per planning unit.

targetsDF
@@ -89,8 +89,7 @@

Value

Examples

-
Features <- dat_species_bin %>%
-  dplyr::select(-"cellID")
+    
Features <- dat_species_bin
 
 target <- Features %>%
   sf::st_drop_geometry() %>%
@@ -120,7 +119,7 @@ 

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/splnr_climate_percentileApproach.html b/docs/reference/splnr_climate_percentileApproach.html index e42a568c..4006d93a 100644 --- a/docs/reference/splnr_climate_percentileApproach.html +++ b/docs/reference/splnr_climate_percentileApproach.html @@ -58,11 +58,11 @@

ArgumentsfeaturesDF -

feature sfobject which should have a column for cellID

+

feature sfobject

metricDF
-

climate metric data.frame with 'metric' as the column name of the metric values per planning unit. This should also have a column for the cellID

+

climate metric data.frame with 'metric' as the column name of the metric values per planning unit.

targetsDF
@@ -84,8 +84,7 @@

Value

Examples

-
Features <- dat_species_bin %>%
-  dplyr::select(-"cellID")
+    
Features <- dat_species_bin
 
 target <- Features %>%
   sf::st_drop_geometry() %>%
@@ -115,7 +114,7 @@ 

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/splnr_climate_priorityAreaApproach.html b/docs/reference/splnr_climate_priorityAreaApproach.html index c9cc4244..07d5e735 100644 --- a/docs/reference/splnr_climate_priorityAreaApproach.html +++ b/docs/reference/splnr_climate_priorityAreaApproach.html @@ -59,11 +59,11 @@

ArgumentsfeaturesDF -

feature sfobject which should have a column for cellID

+

feature sfobject

metricDF
-

climate metric data.frame with 'metric' as the column name of the metric values per planning unit. This should also have a column for the cellID

+

climate metric data.frame with 'metric' as the column name of the metric values per planning unit.

targetsDF
@@ -89,8 +89,7 @@

Value

Examples

- diff --git a/docs/reference/splnr_convert_regionalisation.html b/docs/reference/splnr_convert_regionalisation.html index bcb13e19..6ca24cf2 100644 --- a/docs/reference/splnr_convert_regionalisation.html +++ b/docs/reference/splnr_convert_regionalisation.html @@ -95,7 +95,7 @@

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/splnr_convert_toPUs.html b/docs/reference/splnr_convert_toPUs.html index 7e5c7510..1ceb2ccb 100644 --- a/docs/reference/splnr_convert_toPUs.html +++ b/docs/reference/splnr_convert_toPUs.html @@ -86,7 +86,7 @@

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/splnr_create_polygon.html b/docs/reference/splnr_create_polygon.html index 5a4c5bd6..2477302c 100644 --- a/docs/reference/splnr_create_polygon.html +++ b/docs/reference/splnr_create_polygon.html @@ -81,7 +81,7 @@

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/splnr_featureNames.html b/docs/reference/splnr_featureNames.html index bfe708bb..dd62f04b 100644 --- a/docs/reference/splnr_featureNames.html +++ b/docs/reference/splnr_featureNames.html @@ -70,7 +70,7 @@

Value

Examples

df <- dat_species_prob %>%
-  splnr_featureNames(exclude = c("cellID"))
+  splnr_featureNames()
 

dat <- splnr_get_MPAs(PlanUnits = dat_PUs, Countries = "Australia")
 #> ! importing local data (version Apr 2024); use "force=TRUE" if you need latest version.
-#> Warning: package ‘sf’ was built under R version 4.4.1
-#> Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE
+#> Linking to GEOS 3.13.0, GDAL 3.9.3, PROJ 9.5.0; sf_use_s2() is TRUE
 #> Warning: attribute variables are assumed to be spatially constant throughout all geometries
 #> Warning: attribute variables are assumed to be spatially constant throughout all geometries
 
@@ -115,7 +114,7 @@ 

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/splnr_get_boundary.html b/docs/reference/splnr_get_boundary.html index ba5713bf..eeb44326 100644 --- a/docs/reference/splnr_get_boundary.html +++ b/docs/reference/splnr_get_boundary.html @@ -76,7 +76,7 @@

Value

Examples

Bndry <- splnr_get_boundary(Limits = "North Atlantic Ocean", Type = "Ocean")
 #> Reading layer `ne_10m_geography_marine_polys' from data source 
-#>   `/private/var/folders/_r/mcmw_qtn0m7cd23cbdqfszl40000gp/T/RtmpmU1Uiz/ne_10m_geography_marine_polys.shp' 
+#>   `/private/var/folders/_r/mcmw_qtn0m7cd23cbdqfszl40000gp/T/RtmpUmnXWF/ne_10m_geography_marine_polys.shp' 
 #>   using driver `ESRI Shapefile'
 #> Simple feature collection with 306 features and 37 fields
 #> Geometry type: MULTIPOLYGON
@@ -96,7 +96,7 @@ 

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/splnr_get_distCoast.html b/docs/reference/splnr_get_distCoast.html index a4dfe33c..cd7854c6 100644 --- a/docs/reference/splnr_get_distCoast.html +++ b/docs/reference/splnr_get_distCoast.html @@ -107,7 +107,7 @@

Examples Type = "Oceans", cCRS = cCRS) #> Reading layer `ne_10m_geography_marine_polys' from data source -#> `/private/var/folders/_r/mcmw_qtn0m7cd23cbdqfszl40000gp/T/RtmpmU1Uiz/ne_10m_geography_marine_polys.shp' +#> `/private/var/folders/_r/mcmw_qtn0m7cd23cbdqfszl40000gp/T/RtmpUmnXWF/ne_10m_geography_marine_polys.shp' #> using driver `ESRI Shapefile' #> Simple feature collection with 306 features and 37 fields #> Geometry type: MULTIPOLYGON @@ -132,7 +132,7 @@

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/splnr_get_featureRep.html b/docs/reference/splnr_get_featureRep.html index 8c55613a..e63c1b75 100644 --- a/docs/reference/splnr_get_featureRep.html +++ b/docs/reference/splnr_get_featureRep.html @@ -116,7 +116,7 @@

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/splnr_get_gfw.html b/docs/reference/splnr_get_gfw.html index dad649b7..6d7eeeb6 100644 --- a/docs/reference/splnr_get_gfw.html +++ b/docs/reference/splnr_get_gfw.html @@ -133,7 +133,7 @@

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/splnr_get_kappaCorrData.html b/docs/reference/splnr_get_kappaCorrData.html index da27fcf9..55908207 100644 --- a/docs/reference/splnr_get_kappaCorrData.html +++ b/docs/reference/splnr_get_kappaCorrData.html @@ -127,7 +127,7 @@

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/splnr_get_selFreq-1.png b/docs/reference/splnr_get_selFreq-1.png index f32b37bd..f699bd97 100644 Binary files a/docs/reference/splnr_get_selFreq-1.png and b/docs/reference/splnr_get_selFreq-1.png differ diff --git a/docs/reference/splnr_get_selFreq.html b/docs/reference/splnr_get_selFreq.html index 658cb5cd..fa98198b 100644 --- a/docs/reference/splnr_get_selFreq.html +++ b/docs/reference/splnr_get_selFreq.html @@ -101,7 +101,7 @@

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/splnr_gg_add-1.png b/docs/reference/splnr_gg_add-1.png index ed7aadba..f3ca59ac 100644 Binary files a/docs/reference/splnr_gg_add-1.png and b/docs/reference/splnr_gg_add-1.png differ diff --git a/docs/reference/splnr_gg_add.html b/docs/reference/splnr_gg_add.html index b62afa33..2781003b 100644 --- a/docs/reference/splnr_gg_add.html +++ b/docs/reference/splnr_gg_add.html @@ -212,7 +212,7 @@

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/splnr_match_names.html b/docs/reference/splnr_match_names.html index 235c2ca7..420c66fd 100644 --- a/docs/reference/splnr_match_names.html +++ b/docs/reference/splnr_match_names.html @@ -72,7 +72,7 @@

Value

Examples

-
dat <- dat_region %>% dplyr::select(-cellID)
+    
dat <- dat_region
 nam <- c("Region1" = "SE Aust", "Region2" = "Tas", "Region3" = "NE Aust")
 df <- splnr_match_names(dat, nam)
 
@@ -86,7 +86,7 @@

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/splnr_plot-1.png b/docs/reference/splnr_plot-1.png index e73407aa..75f53edd 100644 Binary files a/docs/reference/splnr_plot-1.png and b/docs/reference/splnr_plot-1.png differ diff --git a/docs/reference/splnr_plot-2.png b/docs/reference/splnr_plot-2.png index e73407aa..75f53edd 100644 Binary files a/docs/reference/splnr_plot-2.png and b/docs/reference/splnr_plot-2.png differ diff --git a/docs/reference/splnr_plot-3.png b/docs/reference/splnr_plot-3.png index 6692863e..27746d71 100644 Binary files a/docs/reference/splnr_plot-3.png and b/docs/reference/splnr_plot-3.png differ diff --git a/docs/reference/splnr_plot-4.png b/docs/reference/splnr_plot-4.png index 939f154b..3033b5ae 100644 Binary files a/docs/reference/splnr_plot-4.png and b/docs/reference/splnr_plot-4.png differ diff --git a/docs/reference/splnr_plot-5.png b/docs/reference/splnr_plot-5.png index 2eaba970..4a145c75 100644 Binary files a/docs/reference/splnr_plot-5.png and b/docs/reference/splnr_plot-5.png differ diff --git a/docs/reference/splnr_plot.html b/docs/reference/splnr_plot.html index d1bb84a0..53fc2c97 100644 --- a/docs/reference/splnr_plot.html +++ b/docs/reference/splnr_plot.html @@ -64,15 +64,15 @@

Argumentscol_names -

A list of column names to include in the plot. If specified, only these columns will be used to color the plot.

+

A list of column names to include in the plot. If specified, only these columns will be used to colour the plot.

paletteName
-

The name of the color palette to use for filling. Default is "YlGnBu".

+

The name of the colour palette to use for filling. Default is "YlGnBu".

colourVals
-

The color values to use if col_names is specified and the data is binary.

+

The colour values to use if col_names is specified and the data is binary.

plot_title
@@ -93,9 +93,8 @@

Value

Details

-

Written by Kilian Barreiro +

Written by Kilian Barreiro and Jason Everett Written: February 2024

-

Plot Spatial Data, returns a gg object

@@ -156,7 +155,7 @@

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/splnr_plot_MPAs.html b/docs/reference/splnr_plot_MPAs.html index 38489b21..8f4ea399 100644 --- a/docs/reference/splnr_plot_MPAs.html +++ b/docs/reference/splnr_plot_MPAs.html @@ -102,7 +102,7 @@

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/splnr_plot_binFeature.html b/docs/reference/splnr_plot_binFeature.html index 06268af3..3efa93e6 100644 --- a/docs/reference/splnr_plot_binFeature.html +++ b/docs/reference/splnr_plot_binFeature.html @@ -107,7 +107,7 @@

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/splnr_plot_circBplot-1.png b/docs/reference/splnr_plot_circBplot-1.png index c0f92c11..5498a388 100644 Binary files a/docs/reference/splnr_plot_circBplot-1.png and b/docs/reference/splnr_plot_circBplot-1.png differ diff --git a/docs/reference/splnr_plot_circBplot.html b/docs/reference/splnr_plot_circBplot.html index eb0f1de0..519e1285 100644 --- a/docs/reference/splnr_plot_circBplot.html +++ b/docs/reference/splnr_plot_circBplot.html @@ -163,7 +163,7 @@

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/splnr_plot_climData-1.png b/docs/reference/splnr_plot_climData-1.png index 3baae4da..beb7e793 100644 Binary files a/docs/reference/splnr_plot_climData-1.png and b/docs/reference/splnr_plot_climData-1.png differ diff --git a/docs/reference/splnr_plot_climData.html b/docs/reference/splnr_plot_climData.html index 81976c26..f1645904 100644 --- a/docs/reference/splnr_plot_climData.html +++ b/docs/reference/splnr_plot_climData.html @@ -97,7 +97,7 @@

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/splnr_plot_climKernelDensity.html b/docs/reference/splnr_plot_climKernelDensity.html index dbc39c62..d9f59eef 100644 --- a/docs/reference/splnr_plot_climKernelDensity.html +++ b/docs/reference/splnr_plot_climKernelDensity.html @@ -90,7 +90,6 @@

Value

Examples

target <- dat_species_bin %>%
-  dplyr::select(-"cellID") %>%
   sf::st_drop_geometry() %>%
   colnames() %>%
   data.frame() %>%
@@ -107,12 +106,11 @@ 

Examples out_sf <- CPA$Features %>% dplyr::mutate(Cost_None = rep(1, 780)) %>% - dplyr::left_join(dat_clim %>% - sf::st_drop_geometry(), by = "cellID") + sf::st_join(dat_clim, join = sf::st_equals) usedFeatures <- out_sf %>% sf::st_drop_geometry() %>% - dplyr::select(-tidyselect::starts_with("Cost_"), -"cellID", -"metric") %>% + dplyr::select(-tidyselect::starts_with("Cost_"), -"metric") %>% names() p1 <- prioritizr::problem(out_sf, usedFeatures, "Cost_None") %>% @@ -135,7 +133,7 @@

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/splnr_plot_comparison-1.png b/docs/reference/splnr_plot_comparison-1.png index 4e656b88..81680003 100644 Binary files a/docs/reference/splnr_plot_comparison-1.png and b/docs/reference/splnr_plot_comparison-1.png differ diff --git a/docs/reference/splnr_plot_comparison.html b/docs/reference/splnr_plot_comparison.html index 2bea83e5..b89a34ae 100644 --- a/docs/reference/splnr_plot_comparison.html +++ b/docs/reference/splnr_plot_comparison.html @@ -118,7 +118,7 @@

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/splnr_plot_corrMat-1.png b/docs/reference/splnr_plot_corrMat-1.png index 01f38009..031e1e05 100644 Binary files a/docs/reference/splnr_plot_corrMat-1.png and b/docs/reference/splnr_plot_corrMat-1.png differ diff --git a/docs/reference/splnr_plot_corrMat.html b/docs/reference/splnr_plot_corrMat.html index 94998399..bd1a2c8b 100644 --- a/docs/reference/splnr_plot_corrMat.html +++ b/docs/reference/splnr_plot_corrMat.html @@ -143,7 +143,7 @@

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/splnr_plot_cost.html b/docs/reference/splnr_plot_cost.html index af071802..3ed0b290 100644 --- a/docs/reference/splnr_plot_cost.html +++ b/docs/reference/splnr_plot_cost.html @@ -117,7 +117,7 @@

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/splnr_plot_costOverlay-1.png b/docs/reference/splnr_plot_costOverlay-1.png index 494903ca..74dc6037 100644 Binary files a/docs/reference/splnr_plot_costOverlay-1.png and b/docs/reference/splnr_plot_costOverlay-1.png differ diff --git a/docs/reference/splnr_plot_costOverlay.html b/docs/reference/splnr_plot_costOverlay.html index f033d718..b6747243 100644 --- a/docs/reference/splnr_plot_costOverlay.html +++ b/docs/reference/splnr_plot_costOverlay.html @@ -109,7 +109,7 @@

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/splnr_plot_featureNo.html b/docs/reference/splnr_plot_featureNo.html index f7a40d25..f6f55bde 100644 --- a/docs/reference/splnr_plot_featureNo.html +++ b/docs/reference/splnr_plot_featureNo.html @@ -103,7 +103,7 @@

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/splnr_plot_featureRep-1.png b/docs/reference/splnr_plot_featureRep-1.png index 3393616f..ecf98be9 100644 Binary files a/docs/reference/splnr_plot_featureRep-1.png and b/docs/reference/splnr_plot_featureRep-1.png differ diff --git a/docs/reference/splnr_plot_featureRep.html b/docs/reference/splnr_plot_featureRep.html index a6c77396..63c9ea31 100644 --- a/docs/reference/splnr_plot_featureRep.html +++ b/docs/reference/splnr_plot_featureRep.html @@ -137,7 +137,7 @@

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/splnr_plot_importanceScore-1.png b/docs/reference/splnr_plot_importanceScore-1.png index 8acad0f7..5df5f2b7 100644 Binary files a/docs/reference/splnr_plot_importanceScore-1.png and b/docs/reference/splnr_plot_importanceScore-1.png differ diff --git a/docs/reference/splnr_plot_importanceScore.html b/docs/reference/splnr_plot_importanceScore.html index 3a9be81b..01f93e2b 100644 --- a/docs/reference/splnr_plot_importanceScore.html +++ b/docs/reference/splnr_plot_importanceScore.html @@ -124,7 +124,7 @@

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/splnr_plot_selectionFreq-1.png b/docs/reference/splnr_plot_selectionFreq-1.png index 89ec93ff..76d5414b 100644 Binary files a/docs/reference/splnr_plot_selectionFreq-1.png and b/docs/reference/splnr_plot_selectionFreq-1.png differ diff --git a/docs/reference/splnr_plot_selectionFreq.html b/docs/reference/splnr_plot_selectionFreq.html index 5c859a22..1d59c1a1 100644 --- a/docs/reference/splnr_plot_selectionFreq.html +++ b/docs/reference/splnr_plot_selectionFreq.html @@ -110,7 +110,7 @@

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/splnr_plot_solution-1.png b/docs/reference/splnr_plot_solution-1.png index c9f4d692..d595515d 100644 Binary files a/docs/reference/splnr_plot_solution-1.png and b/docs/reference/splnr_plot_solution-1.png differ diff --git a/docs/reference/splnr_plot_solution-2.png b/docs/reference/splnr_plot_solution-2.png index 46058249..48d38797 100644 Binary files a/docs/reference/splnr_plot_solution-2.png and b/docs/reference/splnr_plot_solution-2.png differ diff --git a/docs/reference/splnr_plot_solution.html b/docs/reference/splnr_plot_solution.html index 1162b9be..5efd709d 100644 --- a/docs/reference/splnr_plot_solution.html +++ b/docs/reference/splnr_plot_solution.html @@ -149,7 +149,7 @@

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/splnr_replace_NAs.html b/docs/reference/splnr_replace_NAs.html index 78d13d32..d3b0a088 100644 --- a/docs/reference/splnr_replace_NAs.html +++ b/docs/reference/splnr_replace_NAs.html @@ -1,7 +1,7 @@ -Remove NAs from spatial data using nearest neighbour — splnr_replace_NAs • spatialplanr +Remove NAs from spatial data using nearest neighbour — splnr_replace_NAs • spatialplanr Skip to contents @@ -41,8 +41,8 @@
-

splnr_replace_NAs() allows you to replace NA values in your data with the value of the nearest neighbor. -The nearest neighbor is determined using st_nearest_feature() from the sf package.

+

splnr_replace_NAs() allows you to replace NA values in your data with the value of the nearest neighbour. +The nearest neighbour is determined using st_nearest_feature() from the sf package.

@@ -82,7 +82,7 @@

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/splnr_scale_01.html b/docs/reference/splnr_scale_01.html index c24f9bbb..f31ca53e 100644 --- a/docs/reference/splnr_scale_01.html +++ b/docs/reference/splnr_scale_01.html @@ -80,7 +80,7 @@

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/splnr_targets_byCategory.html b/docs/reference/splnr_targets_byCategory.html index 031cc2c8..71c38b1b 100644 --- a/docs/reference/splnr_targets_byCategory.html +++ b/docs/reference/splnr_targets_byCategory.html @@ -86,7 +86,7 @@

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/splnr_targets_byIUCN.html b/docs/reference/splnr_targets_byIUCN.html index dfe11b3a..2ce6772e 100644 --- a/docs/reference/splnr_targets_byIUCN.html +++ b/docs/reference/splnr_targets_byIUCN.html @@ -87,7 +87,7 @@

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/reference/splnr_targets_byInverseArea.html b/docs/reference/splnr_targets_byInverseArea.html index 797ea246..e1e61d89 100644 --- a/docs/reference/splnr_targets_byInverseArea.html +++ b/docs/reference/splnr_targets_byInverseArea.html @@ -83,7 +83,7 @@

Examples -

Site built with pkgdown 2.1.0.

+

Site built with pkgdown 2.1.1.

diff --git a/docs/search.json b/docs/search.json index 6c55cc8b..87022b13 100644 --- a/docs/search.json +++ b/docs/search.json @@ -1 +1 @@ -[{"path":"https://mathmarecol.github.io/spatialplanr/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2023 Jason D. Everett Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/articles/ClimateSmart.html","id":"overview","dir":"Articles","previous_headings":"","what":"Overview","title":"Climate-Smart Spatial Planning","text":"code written simplify process running prioritizr analysis given region. still work progress feel free submit pull requests new features code improvements.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/articles/ClimateSmart.html","id":"set-user-parameters","dir":"Articles","previous_headings":"Overview","what":"Set user parameters","title":"Climate-Smart Spatial Planning","text":"Set diameter planning units. units CRS (usually metres degrees). can also use customised ggplot theme can passed list splnr_gg_add() can used plots. example:","code":"Region <- \"Coral Sea\" # \"Australia\" Type <- \"Oceans\" # \"EEZ\" cCRS <- \"ESRI:54009\" # Mollweide PU_size <- 107460 # m splnr_theme <- list( ggplot2::theme_bw(), ggplot2::theme( legend.position = \"right\", legend.direction = \"vertical\", text = ggplot2::element_text(size = 9, colour = \"black\"), axis.text = ggplot2::element_text(size = 9, colour = \"black\"), plot.title = ggplot2::element_text(size = 9), axis.title = ggplot2::element_blank() ) )"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/ClimateSmart.html","id":"analysis-region","dir":"Articles","previous_headings":"Overview","what":"Analysis Region","title":"Climate-Smart Spatial Planning","text":"Start analysis defining region setting planning units. Get boundary chosen region.","code":"Bndry <- splnr_get_boundary(Limits = Region, Type = Type, cCRS = cCRS) #> Reading layer `ne_10m_geography_marine_polys' from data source #> `/private/var/folders/_r/mcmw_qtn0m7cd23cbdqfszl40000gp/T/RtmpQilTyY/ne_10m_geography_marine_polys.shp' #> using driver `ESRI Shapefile' #> Simple feature collection with 306 features and 37 fields #> Geometry type: MULTIPOLYGON #> Dimension: XY #> Bounding box: xmin: -180 ymin: -85.19206 xmax: 179.9999 ymax: 90 #> Geodetic CRS: WGS 84 landmass <- rnaturalearth::ne_countries(scale = \"medium\", returnclass = \"sf\") %>% sf::st_transform(cCRS)"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/ClimateSmart.html","id":"create-planning-units","dir":"Articles","previous_headings":"Overview","what":"Create Planning Units","title":"Climate-Smart Spatial Planning","text":"","code":"PUs <- spatialgridr::get_grid(boundary = Bndry, crs = cCRS, output = \"sf_hex\", resolution = PU_size)"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/ClimateSmart.html","id":"get-the-features","dir":"Articles","previous_headings":"Overview","what":"Get the features","title":"Climate-Smart Spatial Planning","text":"example, use small subset charismatic megafauna species Coral Sea inform conservation plan. filtered Aquamaps (Aquamaps.org) species distribution models study area following species: species chosen based importance region represent example visualization purposes. Note: structure tribbleabove required downstream plotting. Common denotes common name species, Scientific scientific name format used Aquamaps, Category category species belongs Class represents importance species conservation plan.","code":"Dict <- tibble::tribble( ~nameCommon, ~nameVariable, ~category, \"Green sea turtle\", \"Chelonia_mydas\", \"Reptiles\", \"Loggerhead sea turtle\", \"Caretta_caretta\", \"Reptiles\", \"Hawksbill sea turtle\", \"Eretmochelys_imbricata\", \"Reptiles\", \"Olive ridley sea turtle\", \"Lepidochelys_olivacea\", \"Reptiles\", \"Saltwater crocodile\", \"Crocodylus_porosus\", \"Reptiles\", \"Humpback whale\", \"Megaptera_novaeangliae\", \"Mammals\", \"Common Minke whale\", \"Balaenoptera_acutorostrata\", \"Mammals\", \"Dugong\", \"Dugong_dugon\", \"Mammals\", \"Grey nurse shark\", \"Carcharias_taurus\", \"Sharks and rays\", \"Tiger shark\", \"Galeocerdo_cuvier\", \"Sharks and rays\", \"Great hammerhead shark\", \"Sphyrna_mokarran\", \"Sharks and rays\", \"Giant oceanic manta ray\", \"Mobula_birostris\", \"Sharks and rays\", \"Reef manta ray\", \"Mobula_alfredi\", \"Sharks and rays\", \"Whitetip reef shark\", \"Triaenodon_obesus\", \"Sharks and rays\", \"Red-footed booby\", \"Sula_sula\", \"Birds\" )"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/ClimateSmart.html","id":"convert-the-probabilities-to-binary-data","dir":"Articles","previous_headings":"Overview > Get the features","what":"Convert the probabilities to binary data","title":"Climate-Smart Spatial Planning","text":"","code":"datEx_species_bin <- spDataFiltered %>% dplyr::as_tibble() %>% dplyr::mutate(dplyr::across( -dplyr::any_of(c(\"cellID\", \"geometry\")), # Don't apply to geometry/cellID ~ dplyr::case_when( . >= 0.5 ~ 1, . < 0.5 ~ 0, is.na(.data) ~ 0 ) )) %>% sf::st_as_sf() col_name <- spDataFiltered %>% sf::st_drop_geometry() %>% dplyr::select(-\"cellID\") %>% colnames()"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/ClimateSmart.html","id":"climate-smart-spatial-planning","dir":"Articles","previous_headings":"Overview > Get the features","what":"Climate-smart spatial planning","title":"Climate-Smart Spatial Planning","text":"far, steps exactly spatial plan include climate change. make spatial plan climate smart, need climate metrics. use climate velocity data obtained x, y z models using SSP5-8.5. downstream analysis, rename column interest (: velocity data) metric. climate velocity data can visualized using splnr_plot_climData() function. case, areas low climate velocity, areas define climate refugia example. Usually, combine several metrics (e.g. exposure, velocity etc.) multiple SSP scenarios get robust climate refugia. example, randomly set areas high velocity value 0.85-1 visualize output (CHANGE LATER BETTER DATA). use climate priority area approach splnr_climate_priorityAreaApproach() detailed Buenafe et al (2023) determine climate refugia. Briefly, approach selects percentile (case 5%) suitable habitat feature considered climate-smart. also requires direction input indicating side metric range climate-smart areas can found. case, lower climate velocity denotes climate-smart (direction = -1), cases higher value might represent climate-smart planning units (direction = 1). Using approach also requires adaptation targets, since 5% suitable habitat species already protected climate-smart areas. can decide much 5% climate-smart areas supposed included spatial plan (: refugiaTarget = 1 protect 100% 5% climate-smart areas). now add information required perform spatial planning, cost, extract names used features.","code":"metric_df <- CoralSeaVelocity %>% dplyr::rename(metric = voccMag_transformed) (ggclim <- splnr_plot_climData(metric_df, \"metric\") + splnr_gg_add( Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme )) set.seed(5) metric_df <- CoralSeaVelocity %>% dplyr::rename(metric = voccMag_transformed) %>% dplyr::mutate( metricOG = metric, metric = ifelse(metric > 0.99, runif(., 0.85, 1.0), metric) ) (ggclim <- splnr_plot_climData(metric_df, \"metric\") + splnr_gg_add( Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme )) target <- datEx_species_bin %>% sf::st_drop_geometry() %>% dplyr::select(-\"cellID\") %>% colnames() %>% data.frame() %>% setNames(c(\"feature\")) %>% dplyr::mutate(target = 0.3) CPA_Approach <- splnr_climate_priorityAreaApproach( featuresDF = datEx_species_bin, metricDF = metric_df, targetsDF = target, direction = -1, refugiaTarget = 1 ) out_sf <- CPA_Approach$Features %>% dplyr::left_join( datEx_species_bin %>% sf::st_drop_geometry() %>% dplyr::select( \"cellID\", tidyselect::starts_with(\"Cost_\") ), by = \"cellID\" ) %>% dplyr::left_join(metric_df %>% sf::st_drop_geometry(), by = \"cellID\") targets <- CPA_Approach$Targets out_sf$Cost_None <- rep(1, 397) usedFeatures <- out_sf %>% sf::st_drop_geometry() %>% dplyr::select( -tidyselect::starts_with(\"Cost_\"), -\"cellID\", -tidyselect::starts_with(\"metric\") ) %>% names()"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/ClimateSmart.html","id":"run-the-climate-smart-spatial-planning","dir":"Articles","previous_headings":"Overview > Get the features","what":"Run the climate-smart spatial planning","title":"Climate-Smart Spatial Planning","text":"prioritizrsteps including climate change running non-climate-smart spatial prioritization. can look resulting plan using splnr_plot_solution(). However, also interested climate-smart selected planning units solution actually . , can use kernel density plot","code":"p1 <- prioritizr::problem(out_sf, usedFeatures, \"Cost_None\") %>% prioritizr::add_min_set_objective() %>% prioritizr::add_relative_targets(targets$target) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(verbose = FALSE) dat_solnClim <- prioritizr::solve.ConservationProblem(p1) (ggSoln <- splnr_plot_solution(dat_solnClim) + splnr_gg_add( Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme )) (ggClimDens <- splnr_plot_climKernelDensity( soln = list(dat_solnClim), names = c(\"Input 1\"), type = \"Normal\", legendTitle = \"Climate velocity (add unit)\", xAxisLab = \"Climate velocity\" ))"},{"path":[]},{"path":"https://mathmarecol.github.io/spatialplanr/articles/ClimateSmart.html","id":"percentile-approach","dir":"Articles","previous_headings":"Overview > Alternative Approaches","what":"Percentile Approach","title":"Climate-Smart Spatial Planning","text":"now add information required perform spatial planning, cost, extract names used features run prioritisation. can look resulting plan using splnr_plot_solution(). However, also interested climate-smart selected planning units solution actually . , can use kernel density plot","code":"target <- datEx_species_bin %>% sf::st_drop_geometry() %>% dplyr::select(-\"cellID\") %>% colnames() %>% data.frame() %>% setNames(c(\"feature\")) %>% dplyr::mutate(target = 30) Percentile_Approach <- splnr_climate_percentileApproach( featuresDF = datEx_species_bin, metricDF = metric_df, targetsDF = target, direction = -1, percentile = 35 ) #> [1] \"Lower values mean more climate-smart areas.\" out_sf <- Percentile_Approach$Features %>% dplyr::left_join( datEx_species_bin %>% sf::st_drop_geometry() %>% dplyr::select( \"cellID\", tidyselect::starts_with(\"Cost_\") ), by = \"cellID\" ) %>% dplyr::left_join(metric_df %>% sf::st_drop_geometry(), by = \"cellID\") targets <- Percentile_Approach$Targets out_sf$Cost_None <- rep(1, 397) usedFeatures <- out_sf %>% sf::st_drop_geometry() %>% dplyr::select( -tidyselect::starts_with(\"Cost_\"), -\"cellID\", -tidyselect::starts_with(\"metric\") ) %>% names() p2 <- prioritizr::problem(out_sf, usedFeatures, \"Cost_None\") %>% prioritizr::add_min_set_objective() %>% prioritizr::add_relative_targets(targets$target) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(verbose = FALSE) dat_solnClimPercentile <- prioritizr::solve.ConservationProblem(p2, force = TRUE ) (ggSoln <- splnr_plot_solution(dat_solnClimPercentile) + splnr_gg_add( Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme )) (ggClimDens <- splnr_plot_climKernelDensity( soln = list(dat_solnClimPercentile), names = c(\"Input 1\"), type = \"Normal\", legendTitle = \"Climate velocity (add unit)\", xAxisLab = \"Climate velocity\" ))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/ClimateSmart.html","id":"feature-approach","dir":"Articles","previous_headings":"Overview > Alternative Approaches","what":"Feature Approach","title":"Climate-Smart Spatial Planning","text":"now add information required perform spatial planning, cost, extract names used features run prioritisation. However, also interested climate-smart selected planning units solution actually . , can use kernel density plot","code":"target <- datEx_species_bin %>% sf::st_drop_geometry() %>% dplyr::select(-\"cellID\") %>% colnames() %>% data.frame() %>% setNames(c(\"feature\")) %>% dplyr::mutate(target = 0.3) Feature_Approach <- splnr_climate_featureApproach( featuresDF = datEx_species_bin, metricDF = metric_df, targetsDF = target, direction = 1 ) #> [1] \"Higher values mean more climate-smart areas.\" out_sf <- Feature_Approach$Features %>% dplyr::left_join( datEx_species_bin %>% sf::st_drop_geometry() %>% dplyr::select( \"cellID\", tidyselect::starts_with(\"Cost_\") ), by = \"cellID\" ) %>% dplyr::left_join(metric_df %>% sf::st_drop_geometry(), by = \"cellID\") targets <- Feature_Approach$Targets out_sf$Cost_None <- rep(1, 397) usedFeatures <- out_sf %>% sf::st_drop_geometry() %>% dplyr::select( -tidyselect::starts_with(\"Cost_\"), -\"cellID\", -tidyselect::starts_with(\"metric\") ) %>% names() p3 <- prioritizr::problem(out_sf, usedFeatures, \"Cost_None\") %>% prioritizr::add_min_set_objective() %>% prioritizr::add_relative_targets(targets$target) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(verbose = FALSE) dat_solnClimFeature <- prioritizr::solve.ConservationProblem(p3) (ggSoln <- splnr_plot_solution(dat_solnClimFeature) + splnr_gg_add( Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme )) (ggClimDens <- splnr_plot_climKernelDensity( soln = list(dat_solnClimFeature), names = c(\"Input 1\"), type = \"Normal\", legendTitle = \"Climate velocity (add unit)\", xAxisLab = \"Climate velocity\" ))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/GlobalFishingWatch.html","id":"global-fishing-watch-r-package-gfwr","dir":"Articles","previous_headings":"","what":"Global Fishing Watch R Package (gfwr)","title":"Global Fishing Watch","text":"gfwr package provides convenient functions pull GFW data directly R usable formats. contains three main functions, including : get_vessel_info(), get_event() get_raster(). two first devoted retrieving information features one ore several specific vessels. last particular interest us allows us gather information global fishing watch raster fishing effort (details function appropriate section). mainly use splnr_get_gfw function created enable data retrieved processed variety ways, described . time spent fishing computed using Automatic Identification System (AIS) data, transmitted industrial fishing vessels. AIS data provides information location, speed, direction vessel, can used identify vessel actively fishing.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/articles/GlobalFishingWatch.html","id":"ais-caveats-and-limitations","dir":"Articles","previous_headings":"Global Fishing Watch R Package (gfwr)","what":"AIS Caveats and limitations","title":"Global Fishing Watch","text":"AIS coverage vessels several limitations : 1. number vessels captured (AIS provides approximately 70’000 2.8 million identified fishing vessels). 2. size vessels (52-85% vessels larger 24 meters 1% vessels 12 meters).Good know: IMO mandates AIS vessels larger 36 meters. 3. AIS interference areas high vessel density. 4. terrestrial satellites receive messages near shore.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/articles/GlobalFishingWatch.html","id":"installation","dir":"Articles","previous_headings":"Global Fishing Watch R Package (gfwr)","what":"Installation","title":"Global Fishing Watch","text":"","code":"remotes::install_github(\"GlobalFishingWatch/gfwr\") library(gfwr) library(spatialplanr)"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/GlobalFishingWatch.html","id":"api","dir":"Articles","previous_headings":"Global Fishing Watch R Package (gfwr)","what":"API","title":"Global Fishing Watch","text":"access GFW APIs, need : 1. register GFW account . 2. Request API key . token, add .Renviron file (executing chunk ), writing (GFW_TOKEN = “YOUR_TOKEN”) file. (asked restart R changes take effect.) save key object used gfwr functions.","code":"usethis::edit_r_environ() key <- gfwr::gfw_auth()"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/GlobalFishingWatch.html","id":"fishing-effort-visualization","dir":"Articles","previous_headings":"Global Fishing Watch R Package (gfwr)","what":"Fishing effort visualization","title":"Global Fishing Watch","text":"region_id necessary use get_raster function. get_raster function gets raster fishing effort API converts response data frame contains occurrences vessel grid cell (data binned grid cells different resolution), Vessel IDs, Flag, Geartype Apparent fishing Hours basically amount fishing hours vessel per grid cell (geometry). Data can provided : - DAILY, MONTHLY YEARLY temporal resolutions. - LOW (0.1 deg) HIGH (0.01 deg) spatial resolutions. - VESSEL_ID, FLAG, GEARTYPE, FLAGANDGEARTYPE. (can remove option message = FALSE see columns types.)","code":"region_id <- gfwr::get_region_id(region_name = \"Australia\", region_source = \"EEZ\", key = gfwr::gfw_auth())$id gfwr::get_raster( spatial_resolution = \"LOW\", temporal_resolution = \"MONTHLY\", group_by = \"FLAGANDGEARTYPE\", start_date = \"2022-01-01\", end_date = \"2023-01-01\", region = region_id, region_source = \"EEZ\", key = gfwr::gfw_auth() )"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/GlobalFishingWatch.html","id":"get_raster-caveats-and-limitations-","dir":"Articles","previous_headings":"Global Fishing Watch R Package (gfwr) > Fishing effort visualization","what":"get_raster caveats and limitations.","title":"Global Fishing Watch","text":"Date range limited 1-year. Nevertheless, modifications, can get round problems splnr_get_gfw.","code":"data_sf_combined <- splnr_get_gfw(region = \"Australia\", start_date = \"2019-01-01\", end_date = \"2023-12-31\", temp_res = \"YEARLY\", spat_res = \"LOW\", compress = FALSE)"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/GlobalFishingWatch.html","id":"visualization","dir":"Articles","previous_headings":"Global Fishing Watch R Package (gfwr)","what":"Visualization","title":"Global Fishing Watch","text":"display data, load : - coastline rnaturalearth package modify get sf object, constrain boundaries given data. - EEZ Polygons oceandatr package","code":"# Check and modify if necessary the spatial reference of data_sf_combined data_sf_combined <- sf::st_set_crs(data_sf_combined, sf::st_crs(rnaturalearth::ne_coastline(scale = \"large\"))) coast_clipped <- rnaturalearth::ne_coastline(scale = \"large\") %>% sf::st_as_sf() %>% sf::st_intersection(sf::st_as_sfc(sf::st_bbox(data_sf_combined))) # Load EEZ polygons eezs <- spatialgridr::get_boundary(name = \"Australia\", type = \"eez\", country_type = \"country\") %>% sf::st_transform(crs = sf::st_crs(data_sf_combined)) %>% sf::st_make_valid() %>% sf::st_intersection(sf::st_as_sfc(sf::st_bbox(data_sf_combined)))"},{"path":[]},{"path":[]},{"path":[]},{"path":"https://mathmarecol.github.io/spatialplanr/articles/GlobalFishingWatch.html","id":"year-on-year-comparison","dir":"Articles","previous_headings":"Global Fishing Watch R Package (gfwr) > Here we display the Fishing Effort in Australia from 2019 to 2023.","what":"Year-on-year comparison","title":"Global Fishing Watch","text":"may need compare different timeframes, seasons, see patterns. Note : vessels adopted AIS (mainly economically developed countries) since deployment technologies, rise activities must seen context increase necessarily intense fishing activity.","code":"# We need to change the temporal range according to our need group by it to display the total fishing hours.
data_sf_combined <- splnr_get_gfw(region = \"Australia\", start_date = \"2019-01-01\", end_date = \"2023-12-31\", temp_res = \"MONTHLY\", key = gfwr::gfw_auth()) %>% dplyr::group_by(Year, Month) %>% dplyr::summarize(Total_Fishing_Hours = sum(ApparentFishingHrs))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/GlobalFishingWatch.html","id":"fishing-gear-type","dir":"Articles","previous_headings":"Global Fishing Watch R Package (gfwr) > Here we display the Fishing Effort in Australia from 2019 to 2023.","what":"Fishing gear type","title":"Global Fishing Watch","text":"display Vessel activity ‘Micronesia’ 2020 according fishing gear type.","code":"data_sf_combined <- splnr_get_gfw(region = \"Micronesia\", start_date = \"2019-12-31\", end_date = \"2021-01-01\", temp_res = \"MONTHLY\")"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/GlobalFishingWatch.html","id":"flags","dir":"Articles","previous_headings":"Global Fishing Watch R Package (gfwr) > Here we display the Fishing Effort in Australia from 2019 to 2023.","what":"Flags","title":"Global Fishing Watch","text":"display Vessel activity Papua New Guinea according Vessels flags.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/articles/GlobalFishingWatch.html","id":"supplementary-materials-","dir":"Articles","previous_headings":"Global Fishing Watch R Package (gfwr) > Here we display the Fishing Effort in Australia from 2019 to 2023.","what":"Supplementary materials.","title":"Global Fishing Watch","text":"fishing detection model trained AIS data 503 vessels identified fishing activity 90% accuracy, means can identify fishing non-fishing activity high accuracy. details AIS operation limitations .","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/articles/GlobalFishingWatch.html","id":"hierarchy-of-vessels-gear-types","dir":"Articles","previous_headings":"Global Fishing Watch R Package (gfwr) > Here we display the Fishing Effort in Australia from 2019 to 2023.","what":"Hierarchy of vessels gear types :","title":"Global Fishing Watch","text":"Source : https://globalfishingwatch.org/datasets--code-vessel-identity/","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"overview","dir":"Articles","previous_headings":"","what":"Overview","title":"Spatial Planning With Zones","text":"code written simplify process running prioritizr analysis given region. still work progress feel free submit pull requests new features code improvements. workflow shown based prioritizr introduction zones.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"set-user-parameters","dir":"Articles","previous_headings":"Overview","what":"Set user parameters","title":"Spatial Planning With Zones","text":"Set diameter planning units. units CRS (usually metres degrees). Choose CRS analysis. use Mollweide","code":"Region <- \"Coral Sea\" # \"Australia\" Type <- \"Oceans\" # \"EEZ\" PU_size <- 107460 # m cCRS <- \"ESRI:54009\""},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"analysis-region","dir":"Articles","previous_headings":"Overview","what":"Analysis Region","title":"Spatial Planning With Zones","text":"Start analysis defining region setting planning units. Get boundary chosen region.","code":"Bndry <- splnr_get_boundary(Limits = Region, Type = Type, cCRS = cCRS) #> Reading layer `ne_10m_geography_marine_polys' from data source #> `/private/var/folders/_r/mcmw_qtn0m7cd23cbdqfszl40000gp/T/RtmpBoWWk8/ne_10m_geography_marine_polys.shp' #> using driver `ESRI Shapefile' #> Simple feature collection with 306 features and 37 fields #> Geometry type: MULTIPOLYGON #> Dimension: XY #> Bounding box: xmin: -180 ymin: -85.19206 xmax: 179.9999 ymax: 90 #> Geodetic CRS: WGS 84 landmass <- rnaturalearth::ne_countries( scale = \"medium\", returnclass = \"sf\" ) %>% sf::st_transform(cCRS)"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"create-planning-units","dir":"Articles","previous_headings":"Overview","what":"Create Planning Units","title":"Spatial Planning With Zones","text":"can also use customised ggplot theme can passed list splnr_gg_add() can used plots. example:","code":"PUs <- spatialgridr::get_grid(boundary = Bndry, crs = cCRS, output = \"sf_hex\", resolution = PU_size) splnr_theme <- list( ggplot2::theme_bw(), ggplot2::theme( legend.position = \"right\", legend.direction = \"vertical\", text = ggplot2::element_text(size = 9, colour = \"black\"), axis.text = ggplot2::element_text(size = 9, colour = \"black\"), plot.title = ggplot2::element_text(size = 9), axis.title = ggplot2::element_blank() ) )"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"get-the-features","dir":"Articles","previous_headings":"Overview","what":"Get the features","title":"Spatial Planning With Zones","text":"example, use small subset charismatic megafauna species Coral Sea inform conservation plan. filtered Aquamaps (Aquamaps.org) species distribution models study area following species: species chosen based importance region represent example visualization purposes. Note: structure tribbleabove required downstream plotting. Common denotes common name species, Scientific scientific name format used Aquamaps, Category category species belongs Class represents importance species conservation plan.","code":"Dict <- tibble::tribble( ~nameCommon, ~nameVariable, ~category, \"Green sea turtle\", \"Chelonia_mydas\", \"Reptiles\", \"Loggerhead sea turtle\", \"Caretta_caretta\", \"Reptiles\", \"Hawksbill sea turtle\", \"Eretmochelys_imbricata\", \"Reptiles\", \"Olive ridley sea turtle\", \"Lepidochelys_olivacea\", \"Reptiles\", \"Saltwater crocodile\", \"Crocodylus_porosus\", \"Reptiles\", \"Humpback whale\", \"Megaptera_novaeangliae\", \"Mammals\", \"Common Minke whale\", \"Balaenoptera_acutorostrata\", \"Mammals\", \"Dugong\", \"Dugong_dugon\", \"Mammals\", \"Grey nurse shark\", \"Carcharias_taurus\", \"Sharks and rays\", \"Tiger shark\", \"Galeocerdo_cuvier\", \"Sharks and rays\", \"Great hammerhead shark\", \"Sphyrna_mokarran\", \"Sharks and rays\", \"Giant oceanic manta ray\", \"Mobula_birostris\", \"Sharks and rays\", \"Reef manta ray\", \"Mobula_alfredi\", \"Sharks and rays\", \"Whitetip reef shark\", \"Triaenodon_obesus\", \"Sharks and rays\", \"Red-footed booby\", \"Sula_sula\", \"Birds\" )"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"convert-the-probabilities-to-binary-data-and-feature-names","dir":"Articles","previous_headings":"Overview > Get the features","what":"Convert the probabilities to binary data and feature names","title":"Spatial Planning With Zones","text":"","code":"datEx_species_bin <- spDataFiltered %>% splnr_apply_cutoffs(Cutoffs = 0.5) col_name <- spDataFiltered %>% sf::st_drop_geometry() %>% dplyr::select(-\"cellID\") %>% colnames()"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"spatial-planning-including-zones","dir":"Articles","previous_headings":"Overview > Get the features","what":"Spatial planning including zones","title":"Spatial Planning With Zones","text":"far, steps exactly spatial plan include zones. direct comparison, first run spatial plan include zoning. , define targets features (: 30% features) create conservation problem include area-based cost prioritisation. solve problem plot solution. can also look well set target met. now look spatial plan needs extended include multiple management zones using zones().","code":"target <- rep(0.3, nrow(Dict)) p1 <- prioritizr::problem( datEx_species_bin %>% dplyr::mutate(Cost1 = rep(1, 397)), col_name, \"Cost1\" ) %>% prioritizr::add_min_set_objective() %>% prioritizr::add_relative_targets(target) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(verbose = FALSE) s1 <- p1 %>% prioritizr::solve.ConservationProblem() (ggSoln <- splnr_plot_solution(s1) + splnr_gg_add(PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme)) s1T <- s1 %>% dplyr::select(tidyselect::starts_with(c(\"solution\"))) %>% sf::st_drop_geometry() %>% tibble::as_tibble() r1 <- prioritizr::eval_feature_representation_summary(p1, s1T) print(r1) #> # A tibble: 15 × 5 #> summary feature total_amount absolute_held relative_held #> #> 1 overall Chelonia_mydas 22 10 0.455 #> 2 overall Caretta_caretta 22 10 0.455 #> 3 overall Eretmochelys_imbricata 24 10 0.417 #> 4 overall Lepidochelys_olivacea 22 10 0.455 #> 5 overall Crocodylus_porosus 21 9 0.429 #> 6 overall Megaptera_novaeangliae 388 120 0.309 #> 7 overall Balaenoptera_acutorostrata 238 74 0.311 #> 8 overall Dugong_dugon 13 5 0.385 #> 9 overall Carcharias_taurus 22 10 0.455 #> 10 overall Galeocerdo_cuvier 36 14 0.389 #> 11 overall Sphyrna_mokarran 397 123 0.310 #> 12 overall Mobula_birostris 20 8 0.4 #> 13 overall Mobula_alfredi 20 8 0.4 #> 14 overall Triaenodon_obesus 25 10 0.4 #> 15 overall Sula_sula 13 5 0.385"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"different-cost-layers","dir":"Articles","previous_headings":"Overview > Get the features","what":"Different cost layers","title":"Spatial Planning With Zones","text":"first assume zones interest set features, separate cost layers. , need set targets zones, case 20% features first zone 5% features second zone. create zones object specify number zones features zone. , define two zones features. zones need specified cost targets. use one area-based cost one cost layer uses random numbers, pre-defined targets pass zonesobject problem formulation solving conservation problem. solution can plotted using function splnr_plot_solution() argument zones set TRUE. can see now planning units selected, planning units either selected zone 1 zone 2.","code":"target2 <- matrix(NA, ncol = 2, nrow = nrow(Dict)) target2[, 1] <- 0.2 target2[, 2] <- 0.05 z2 <- prioritizr::zones(\"zone 1\" = col_name, \"zone 2\" = col_name) p2 <- prioritizr::problem( datEx_species_bin %>% dplyr::mutate( Cost1 = rep(1, 397), # when giving sf input, we need as many cost columns as we have zones Cost2 = runif(n = dim(.)[[1]]) ), z2, cost_column = c(\"Cost1\", \"Cost2\") ) %>% prioritizr::add_min_set_objective() %>% prioritizr::add_relative_targets(target2) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(verbose = FALSE) s2 <- p2 %>% prioritizr::solve.ConservationProblem() (gg_s2 <- splnr_plot_solution( s2, zones = TRUE, colorVals = c(\"#c6dbef\", \"#3182bd\", \"black\"), legendLabels = c(\"Not selected\", \"Zone 1\", \"Zone 2\") ) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"different-features","dir":"Articles","previous_headings":"Overview > Get the features","what":"Different features","title":"Spatial Planning With Zones","text":"using sf objects zones(), input feature names zones() need length contain features. means zones features, interest specific zone, target set 0. example, want separate example data zone reptiles another zone containing taxa reptiles, can specify following targets: sets target reptiles first zone 30% rest 0%. second zone, targets non-reptiles 10% reptiles 0% interest zone. Target data given matrix working zones, transform data frame matrix end. define conservation problem way solve . can also look well targets met zone (combined). can see 15 features listed (number) overall summary, summary zone 1 summary zone 2. looking relative_held column tibble, observe summary zone 1 (row 16 onwards), features >30% targets met, whereas others (feature 6 7) low percentage suitable habitat within selected planning units. can extract common names two features: marine mammals thus target 0% zone 1 reptile-specific zone. percentage selected suitable habitat 0% despite target 0 proportion suitable habitat mammals selected incidentally selecting planning units zone meeting targets reptiles. applies zone 2. can also plot final solution :","code":"targets2b <- Dict %>% dplyr::mutate( targetZ1 = dplyr::if_else(category == \"Reptiles\", 30 / 100, 0), targetZ2 = dplyr::if_else(category != \"Reptiles\", 10 / 100, 0) ) %>% dplyr::select(\"targetZ1\", \"targetZ2\") %>% as.matrix() # NOTE: when using sf input, we need as many cost columns as we have zones p2b <- prioritizr::problem( datEx_species_bin %>% dplyr::mutate( Cost1 = rep(1, 397), Cost2 = runif(n = dim(.)[[1]]) ), z2, cost_column = c(\"Cost1\", \"Cost2\") ) %>% prioritizr::add_min_set_objective() %>% prioritizr::add_relative_targets(targets2b) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(verbose = FALSE) s2b <- p2b %>% prioritizr::solve.ConservationProblem() r2b <- s2b %>% dplyr::select(tidyselect::starts_with(c(\"solution\"))) %>% sf::st_drop_geometry() %>% tibble::as_tibble() %>% prioritizr::eval_feature_representation_summary(p2b, .) print(r2b, n = 45) #> # A tibble: 45 × 5 #> summary feature total_amount absolute_held relative_held #> #> 1 overall 1 44 11 0.25 #> 2 overall 2 44 11 0.25 #> 3 overall 3 48 11 0.229 #> 4 overall 4 44 11 0.25 #> 5 overall 5 42 11 0.262 #> 6 overall 6 776 43 0.0554 #> 7 overall 7 476 26 0.0546 #> 8 overall 8 26 7 0.269 #> 9 overall 9 44 11 0.25 #> 10 overall 10 72 13 0.181 #> 11 overall 11 794 48 0.0605 #> 12 overall 12 40 11 0.275 #> 13 overall 13 40 11 0.275 #> 14 overall 14 50 12 0.24 #> 15 overall 15 26 8 0.308 #> 16 zone 1 1 22 8 0.364 #> 17 zone 1 2 22 8 0.364 #> 18 zone 1 3 24 8 0.333 #> 19 zone 1 4 22 8 0.364 #> 20 zone 1 5 21 8 0.381 #> 21 zone 1 6 388 4 0.0103 #> 22 zone 1 7 238 2 0.00840 #> 23 zone 1 8 13 5 0.385 #> 24 zone 1 9 22 8 0.364 #> 25 zone 1 10 36 8 0.222 #> 26 zone 1 11 397 8 0.0202 #> 27 zone 1 12 20 8 0.4 #> 28 zone 1 13 20 8 0.4 #> 29 zone 1 14 25 8 0.32 #> 30 zone 1 15 13 6 0.462 #> 31 zone 2 1 22 3 0.136 #> 32 zone 2 2 22 3 0.136 #> 33 zone 2 3 24 3 0.125 #> 34 zone 2 4 22 3 0.136 #> 35 zone 2 5 21 3 0.143 #> 36 zone 2 6 388 39 0.101 #> 37 zone 2 7 238 24 0.101 #> 38 zone 2 8 13 2 0.154 #> 39 zone 2 9 22 3 0.136 #> 40 zone 2 10 36 5 0.139 #> 41 zone 2 11 397 40 0.101 #> 42 zone 2 12 20 3 0.15 #> 43 zone 2 13 20 3 0.15 #> 44 zone 2 14 25 4 0.16 #> 45 zone 2 15 13 2 0.154 Dict[[1]][6] #> [1] \"Humpback whale\" Dict[[1]][7] #> [1] \"Common Minke whale\" (gg_s2b <- splnr_plot_solution( s2b, zones = TRUE, colorVals = c(\"#c6dbef\", \"#3182bd\", \"black\"), legendLabels = c(\"Not selected\", \"Zone 1\", \"Zone 2\") ) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"boundary-penalty","dir":"Articles","previous_headings":"Overview > Get the features","what":"Boundary penalty","title":"Spatial Planning With Zones","text":"Similar “normal” priritisations, zones also allows including boundary penalty. several options can done within zones zones.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"within-the-same-zone","dir":"Articles","previous_headings":"Overview > Get the features > Boundary penalty","what":"Within the same zone","title":"Spatial Planning With Zones","text":"zeros matrix denote penalty zones, whereas ones introduce boundary penalty define conservation problem. , introduce penalties within zone 1 zone 2 respectively. add_boundary_penalties() set penalty 0.5 zones defined zm1. purpose example, also set 10 second time limit prioritisation. results show less fragmentation previous solution without penalties: boundary penalty can also introduced one zone:","code":"zm1 <- diag(2) print(zm1) #> [,1] [,2] #> [1,] 1 0 #> [2,] 0 1 p3 <- prioritizr::problem( datEx_species_bin %>% dplyr::mutate( Cost1 = rep(1, 397), # when giving sf input, we need as many cost columns as we have zones Cost2 = runif(n = dim(.)[[1]]) ), z2, cost_column = c(\"Cost1\", \"Cost2\") ) %>% prioritizr::add_min_set_objective() %>% prioritizr::add_boundary_penalties(0.5, zone = zm1) %>% prioritizr::add_relative_targets(target2) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(time_limit = 10, verbose = FALSE) s3 <- p3 %>% prioritizr::solve.ConservationProblem() (gg_s3 <- splnr_plot_solution( s3, zones = TRUE, colorVals = c(\"#c6dbef\", \"#3182bd\", \"black\"), legendLabels = c(\"Not selected\", \"Zone 1\", \"Zone 2\") ) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme )) zm2 <- zm1 zm2[2, 2] <- 0 # NOTE: When using sf input, we need as many cost columns as we have zones p4 <- prioritizr::problem( datEx_species_bin %>% dplyr::mutate( Cost1 = rep(1, 397), Cost2 = runif(n = dim(.)[[1]]) ), z2, cost_column = c(\"Cost1\", \"Cost2\") ) %>% prioritizr::add_min_set_objective() %>% prioritizr::add_boundary_penalties(0.5, zone = zm2) %>% prioritizr::add_relative_targets(target2) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(time_limit = 10, verbose = FALSE) s4 <- p4 %>% prioritizr::solve.ConservationProblem() (gg_s4 <- splnr_plot_solution( s4, zones = TRUE, colorVals = c(\"#c6dbef\", \"#3182bd\", \"black\"), legendLabels = c(\"Not selected\", \"Zone 1\", \"Zone 2\") ) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"across-zones","dir":"Articles","previous_headings":"Overview > Get the features > Boundary penalty","what":"Across zones","title":"Spatial Planning With Zones","text":"Similarly, penalties can applied zones specified problem.","code":"zm3 <- matrix(1, ncol = 2, nrow = 2) print(zm3) #> [,1] [,2] #> [1,] 1 1 #> [2,] 1 1 p5 <- prioritizr::problem( datEx_species_bin %>% dplyr::mutate( Cost1 = rep(1, 397), # when giving sf input, we need as many cost columns as we have zones Cost2 = runif(n = dim(.)[[1]]) ), z2, cost_column = c(\"Cost1\", \"Cost2\") ) %>% prioritizr::add_min_set_objective() %>% prioritizr::add_boundary_penalties(0.5, zone = zm3) %>% prioritizr::add_relative_targets(target2) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(time_limit = 10, verbose = FALSE) s5 <- p5 %>% prioritizr::solve.ConservationProblem() (gg_s5 <- splnr_plot_solution( s5, zones = TRUE, colorVals = c(\"#c6dbef\", \"#3182bd\", \"black\"), legendLabels = c(\"Not selected\", \"Zone 1\", \"Zone 2\") ) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"adding-constraints","dir":"Articles","previous_headings":"Overview > Get the features","what":"Adding constraints","title":"Spatial Planning With Zones","text":"Another addition often used conservation planning constraints. often lock lock areas interest various reasons. example, lock already existing MPAs one zones. using zones constraints, use prioritizr function add_manual_locked_constraints() requires input specific format, first prepare MPA data. need specify zone constraint applied , give information planning unit identifier, rename column interest “status” filter planning units locked . results can visualized :","code":"mpas <- MPAsCoralSea %>% dplyr::mutate(zone = \"zone 1\") %>% dplyr::rename( pu = cellID, status = wdpa ) %>% sf::st_drop_geometry() %>% tibble::tibble() %>% dplyr::filter(status == 1) # NOTE: When using sf input, we need as many cost columns as we have zones p6 <- prioritizr::problem( datEx_species_bin %>% dplyr::mutate( Cost1 = rep(1, 397), Cost2 = runif(n = dim(.)[[1]]) ), z2, cost_column = c(\"Cost1\", \"Cost2\") ) %>% prioritizr::add_min_set_objective() %>% prioritizr::add_manual_locked_constraints(mpas) %>% prioritizr::add_relative_targets(target2) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(time_limit = 10, verbose = FALSE) s6 <- p6 %>% prioritizr::solve.ConservationProblem() (gg_s6 <- splnr_plot_solution( s6, zones = TRUE, colorVals = c(\"#c6dbef\", \"#3182bd\", \"black\"), legendLabels = c(\"Not selected\", \"Zone 1\", \"Zone 2\") ) + splnr_gg_add( PUs = PUs, Bndry = Bndry, lockIn = MPAsCoralSea, nameLockIn = \"wdpa\", typeLockIn = \"Full\", colorLockIn = \"lightgrey\", alphaLockIn = 0.2, overlay = landmass, labelLockIn = \"Current MPAs\", cropOverlay = PUs, ggtheme = splnr_theme ))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"objective-functions","dir":"Articles","previous_headings":"Overview > Get the features","what":"Objective functions","title":"Spatial Planning With Zones","text":"far used minimum set objective function meet conservation targets whilst minimizing cost. However, objective function available prioritizr. example maximising mangrove ecosystem services, employed minimum shortfall objective function instead (Dabalà et al 2022). objective function, allocate budget exceeded (example area >30%) whilst still trying minimise cost meeting targets - targets might met (shortfall). Zones also works objective functions minimum set objective function. apply add_min_shortfall_objective() provide separate budgets two zones (8 0.3). can visualize output solving conservation problem.","code":"# NOTE: When using sf input, we need as many cost columns as we have zones p7 <- prioritizr::problem( datEx_species_bin %>% dplyr::mutate( Cost1 = rep(1, 397), Cost2 = runif(n = dim(.)[[1]]) ), z2, cost_column = c(\"Cost1\", \"Cost2\") ) %>% prioritizr::add_min_shortfall_objective(c(8, 0.3)) %>% prioritizr::add_relative_targets(target2) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(time_limit = 10, verbose = FALSE) s7 <- p7 %>% prioritizr::solve.ConservationProblem() (gg_s7 <- splnr_plot_solution( s7, zones = TRUE, colorVals = c(\"#c6dbef\", \"#3182bd\", \"black\"), legendLabels = c(\"Not selected\", \"Zone 1\", \"Zone 2\") ) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"alternative-linear-constraints","dir":"Articles","previous_headings":"Overview > Get the features","what":"Alternative: linear constraints","title":"Spatial Planning With Zones","text":"Sometimes spatial plan might needed requires minimising several costs , binary output (inside protected area/outside protected area) sufficient. case, using linear constraints instead zones might simpler time-efficient way forward. Linear constraints make sure planning units selected area meet criteria given constraint. example, using area-based cost (lowest number planning units meet target), might also simultaneously want minimise cost fisheries keep certain threshold. Inversely, might want minimise cost fisheries also select 30% area. example, fill first define targets random cost layer values ranging 0 1. define solve conservation problem: Based problem definition, want meet targets biodiversity features whilst selecting lowest number planning units possible. However, solution also depends threshold linear constraint specified add_linear_constraints()problem. Specifically, planning units selected solution can exceed 10% total cost planning units costRandom$CostR. can visualise solution : NOTE: can also use multiple linear constraints plan, however, might require normalization input data constraints comparable units, careful tuning thresholds, prioritizr still able solve problem.","code":"target8 <- rep(0.3, nrow(Dict)) set.seed <- 10 # Add seed so the problem below solves each time costRandom <- datEx_species_bin %>% dplyr::mutate(CostR = runif(n = dim(.)[[1]])) %>% dplyr::select(\"CostR\") p8 <- prioritizr::problem( datEx_species_bin %>% dplyr::mutate(Cost1 = rep(1, 397)), col_name, \"Cost1\" ) %>% prioritizr::add_min_set_objective() %>% prioritizr::add_relative_targets(target8) %>% prioritizr::add_linear_constraints(sum(costRandom$CostR) * 0.1, sense = \"<=\", costRandom$CostR ) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(verbose = FALSE) s8 <- p8 %>% prioritizr::solve.ConservationProblem() (gg_s8 <- splnr_plot_solution(s8) + splnr_gg_add(PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"common-targets-across-zones","dir":"Articles","previous_headings":"Overview > Get the features","what":"Common targets across zones","title":"Spatial Planning With Zones","text":"Sometimes might required meet (common) conservation target across multiple zones, several zones contribute reaching target. , need define target across zones (: 30% features across zones): need bring data specific format requires us individual column feature specific zone, spp1 two zones (zone1 zone2), two separate columns input data: spp1_zone1 spp1_zone2. species names zone names exactly specified zones() object separated _. also extract new feature names create zones object, joining two newly created data frames file used prioriztisation. can see defined (random) cost layers cost layer zone2 three times costly zone1. setting solving conservation problem, can look resulting solution well targets met. overall summary shows every feature’s suitable habitat represented least 30% combined target set. However, can see features zone1 lot frequently selected zone2 zone2 three times costly. plot also reflects observation PUs frequently selected zone1. wanted constrain , zone1 less often selected zone2 often?","code":"targetAcross <- dplyr::tibble( feature = col_name, zone = list(c(\"zone1\", \"zone2\"))[rep(1, length(col_name))], target = rep(0.3, length(col_name)), type = rep(\"relative\", length(col_name)) ) datSpecZone1 <- datEx_species_bin %>% sf::st_drop_geometry() %>% dplyr::rename_at(dplyr::vars(-cellID), ~ paste0(.x, \"_zone1\")) featuresZone1 <- datSpecZone1 %>% dplyr::select(-\"cellID\") %>% colnames() datSpecZone2 <- datEx_species_bin %>% sf::st_drop_geometry() %>% dplyr::rename_at(dplyr::vars(-cellID), ~ paste0(.x, \"_zone2\")) featuresZone2 <- datSpecZone2 %>% dplyr::select(-\"cellID\") %>% colnames() z10 <- prioritizr::zones( featuresZone1, featuresZone2, zone_names = c(\"zone1\", \"zone2\"), feature_names = col_name ) out_sf <- datSpecZone1 %>% dplyr::left_join(datSpecZone2, by = \"cellID\") %>% dplyr::mutate(geometry = datEx_species_bin$geometry) %>% sf::st_as_sf() %>% dplyr::mutate( Cost1 = runif(n = dim(.)[[1]]) * 100, Cost2 = runif(n = dim(.)[[1]]) * 300 ) p10 <- prioritizr::problem(out_sf, z10, cost_column = c(\"Cost1\", \"Cost2\") ) %>% prioritizr::add_min_set_objective() %>% prioritizr::add_manual_targets(targetAcross) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(verbose = FALSE) s10 <- p10 %>% prioritizr::solve.ConservationProblem() s10F <- s10 %>% dplyr::select(tidyselect::starts_with(c(\"solution\"))) %>% sf::st_drop_geometry() %>% tibble::as_tibble() r10 <- prioritizr::eval_feature_representation_summary(p10, s10F) print(r10) #> # A tibble: 45 × 5 #> summary feature total_amount absolute_held relative_held #> #> 1 overall Chelonia_mydas 44 14 0.318 #> 2 overall Caretta_caretta 44 14 0.318 #> 3 overall Eretmochelys_imbricata 48 15 0.312 #> 4 overall Lepidochelys_olivacea 44 14 0.318 #> 5 overall Crocodylus_porosus 42 14 0.333 #> 6 overall Megaptera_novaeangliae 776 234 0.302 #> 7 overall Balaenoptera_acutorostrata 476 146 0.307 #> 8 overall Dugong_dugon 26 10 0.385 #> 9 overall Carcharias_taurus 44 14 0.318 #> 10 overall Galeocerdo_cuvier 72 25 0.347 #> # ℹ 35 more rows (gg_s10 <- splnr_plot_solution(s10, zones = TRUE, colorVals = c(\"#c6dbef\", \"#3182bd\", \"black\"), legendLabels = c(\"Not selected\", \"Zone 1\", \"Zone 2\") ) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"targets-across-zones-with-linear-constraints","dir":"Articles","previous_headings":"Overview > Get the features","what":"Targets across zones with linear constraints","title":"Spatial Planning With Zones","text":"can include linear constraints zone1 , area exceed 30% whole area. need create matrix contains data constraint want include. Although want put linear constraint zone1, prioritizr still requires matrix many columns zones. Thus, set area cost 1 zone1 want constraint 0 zone2 want introduce linear constraint. define conservation problem add linear constraint 30% area. selected planning units now equally distributed across zones, also observable plot: However, also expect cost spatial plan higher previous one.","code":"CostArea <- out_sf %>% dplyr::mutate( areaCostZone1 = rep(1, 397), areaCostZone2 = rep(0, 397) ) %>% sf::st_drop_geometry() %>% dplyr::select(\"areaCostZone1\", \"areaCostZone2\") %>% as.matrix() p11 <- prioritizr::problem(out_sf, z10, cost_column = c(\"Cost1\", \"Cost2\") ) %>% prioritizr::add_min_set_objective() %>% prioritizr::add_linear_constraints(sum(CostArea[, 1]) * 0.3, sense = \"<=\", CostArea ) %>% prioritizr::add_manual_targets(targetAcross) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(verbose = FALSE) s11 <- p11 %>% prioritizr::solve.ConservationProblem() s11F <- s11 %>% dplyr::select(tidyselect::starts_with(c(\"solution\"))) %>% sf::st_drop_geometry() %>% tibble::as_tibble() r11 <- prioritizr::eval_feature_representation_summary(p11, s11F) print(r11) #> # A tibble: 45 × 5 #> summary feature total_amount absolute_held relative_held #> #> 1 overall Chelonia_mydas 44 14 0.318 #> 2 overall Caretta_caretta 44 14 0.318 #> 3 overall Eretmochelys_imbricata 48 15 0.312 #> 4 overall Lepidochelys_olivacea 44 14 0.318 #> 5 overall Crocodylus_porosus 42 14 0.333 #> 6 overall Megaptera_novaeangliae 776 234 0.302 #> 7 overall Balaenoptera_acutorostrata 476 144 0.303 #> 8 overall Dugong_dugon 26 9 0.346 #> 9 overall Carcharias_taurus 44 14 0.318 #> 10 overall Galeocerdo_cuvier 72 24 0.333 #> # ℹ 35 more rows (gg_s11 <- splnr_plot_solution( s11, zones = TRUE, colorVals = c(\"#c6dbef\", \"#3182bd\", \"black\"), legendLabels = c(\"Not selected\", \"Zone 1\", \"Zone 2\") ) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"targets-across-some-but-not-all-zones","dir":"Articles","previous_headings":"Overview > Get the features","what":"Targets across some (but not all) zones","title":"Spatial Planning With Zones","text":"example, want target 30% suitable reptile habitat zone 1 zone 2. Additionally, set target 20% zone 2 marine mammals target 5% sharks rays zone 3. create zones object three different zones: create joint sf object zones respective costs.","code":"targetAcrossSome <- Dict %>% dplyr::mutate( target = dplyr::case_when( category == \"Reptiles\" ~ 30 / 100, category == \"Mammals\" ~ 10 / 100, category == \"Sharks and rays\" ~ 5 / 100, TRUE ~ 0 ), zone = dplyr::case_when( category == \"Reptiles\" ~ list(c(\"zone1\", \"zone2\")), category == \"Mammals\" ~ list(\"zone2\"), category == \"Sharks and rays\" ~ list(\"zone3\"), TRUE ~ list(c(\"zone1\", \"zone2\", \"zone3\")) ), type = rep(\"relative\", length(col_name)) ) %>% dplyr::rename(feature = \"nameVariable\") %>% dplyr::select(-\"category\", -\"nameCommon\") datSpecZone1 <- datEx_species_bin %>% sf::st_drop_geometry() %>% dplyr::rename_at(dplyr::vars(-cellID), ~ paste0(.x, \"_zone1\")) featuresZone1 <- datSpecZone1 %>% dplyr::select(-\"cellID\") %>% colnames() datSpecZone2 <- datEx_species_bin %>% sf::st_drop_geometry() %>% dplyr::rename_at(dplyr::vars(-cellID), ~ paste0(.x, \"_zone2\")) featuresZone2 <- datSpecZone2 %>% dplyr::select(-\"cellID\") %>% colnames() datSpecZone3 <- datEx_species_bin %>% sf::st_drop_geometry() %>% dplyr::rename_at(dplyr::vars(-cellID), ~ paste0(.x, \"_zone3\")) featuresZone3 <- datSpecZone3 %>% dplyr::select(-\"cellID\") %>% colnames() z12 <- prioritizr::zones( featuresZone1, featuresZone2, featuresZone3, zone_names = c(\"zone1\", \"zone2\", \"zone3\"), feature_names = col_name ) # NOTE: When using sf input, we need as many cost columns as we have zones out_sf <- datSpecZone1 %>% dplyr::left_join(datSpecZone2, by = \"cellID\") %>% dplyr::left_join(datSpecZone3, by = \"cellID\") %>% dplyr::mutate(geometry = datEx_species_bin$geometry) %>% sf::st_as_sf() %>% dplyr::mutate( Cost1 = runif(n = dim(.)[[1]]) * 100, Cost2 = runif(n = dim(.)[[1]]) * 300, Cost3 = runif(n = dim(.)[[1]]) * 200 ) p12 <- prioritizr::problem(out_sf, z12, cost_column = c(\"Cost1\", \"Cost2\", \"Cost3\") ) %>% prioritizr::add_min_set_objective() %>% prioritizr::add_manual_targets(targetAcrossSome) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(verbose = FALSE) s12 <- p12 %>% prioritizr::solve.ConservationProblem() s12F <- s12 %>% dplyr::select(tidyselect::starts_with(c(\"solution\"))) %>% sf::st_drop_geometry() %>% tibble::as_tibble() r12 <- prioritizr::eval_feature_representation_summary(p12, s12F) print(r12) #> # A tibble: 60 × 5 #> summary feature total_amount absolute_held relative_held #> #> 1 overall Chelonia_mydas 66 16 0.242 #> 2 overall Caretta_caretta 66 16 0.242 #> 3 overall Eretmochelys_imbricata 72 17 0.236 #> 4 overall Lepidochelys_olivacea 66 16 0.242 #> 5 overall Crocodylus_porosus 63 16 0.254 #> 6 overall Megaptera_novaeangliae 1164 64 0.0550 #> 7 overall Balaenoptera_acutorostrata 714 44 0.0616 #> 8 overall Dugong_dugon 39 8 0.205 #> 9 overall Carcharias_taurus 66 16 0.242 #> 10 overall Galeocerdo_cuvier 108 19 0.176 #> # ℹ 50 more rows (gg_s12 <- splnr_plot_solution( s12, zones = TRUE, colorVals = c(\"#c6dbef\", \"#3182bd\", \"navyblue\", \"black\"), legendLabels = c(\"Not selected\", \"Zone 1\", \"Zone 2\", \"Zone3\") ) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ))"},{"path":[]},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"short-term","dir":"Articles","previous_headings":"Overview > Get the features > Next steps","what":"Short-term","title":"Spatial Planning With Zones","text":"Test run time zones compared normal prioritisation Communicate zones outcomes effectively (e.g. targets, cost overlay etc.)","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"longer-term","dir":"Articles","previous_headings":"Overview > Get the features > Next steps","what":"Longer-term","title":"Spatial Planning With Zones","text":"deal overlapping zones (moment prioritizr allocates PU single zone) connect climate-smart workflow zones handle inputs benefit using different objective functions (e.g. ecosystem services vs biodiversity features) Look commonly used data sets multiple use approaches think zone-specific costs, constraints, targets etc. Define (Waitt’s) understanding multiple-use want implement (can differ now future) EU Horizon 2020 MUSES-project: multiple use/multi-use “joint use resources close geographic proximity either single user multiple users. umbrella term covers multitude use combinations marine realm represents radical change concept exclusive resource rights inclusive sharing resources space one users.” Bonnevie et al. 2019: “multi-use specific co-location/coexistence resources shared.” Schupp et al. 2019: distinguishes different types multi-uses (one co-location) Types multiple use MSP according Schupp et al. 2019","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"overview","dir":"Articles","previous_headings":"","what":"Overview","title":"A Basic Spatial Planning Workflow","text":"code written simplify process running prioritizr analysis given region. still work progress feel free submit pull requests new features code improvements.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"set-user-parameters","dir":"Articles","previous_headings":"Overview","what":"Set user parameters","title":"A Basic Spatial Planning Workflow","text":"can set region defined splnr_get_planningUnits. can also define region square boundaries (degrees) need. Choose CRS analysis. case use Mollweide Set diameter planning units. units CRS (usually metres degrees).","code":"Region <- \"Coral Sea\" # \"Australia\" Type <- \"Oceans\" # \"EEZ\" Region <- c(xmin = 150, xmax = 160, ymin = -40, ymax = -30) cCRS <- \"ESRI:54009\" PU_size <- 107460 # m"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"analysis-region","dir":"Articles","previous_headings":"Overview","what":"Analysis Region","title":"A Basic Spatial Planning Workflow","text":"Start analysis defining region setting planning units. Get boundary chosen region. Get land boundaries remove overlap. object “landmass” represents land mass removed (inverse = FALSE)","code":"Bndry <- splnr_get_boundary(Limits = Region, Type = Type, cCRS = cCRS) #> Reading layer `ne_10m_geography_marine_polys' from data source #> `/private/var/folders/_r/mcmw_qtn0m7cd23cbdqfszl40000gp/T/RtmpFXGTcW/ne_10m_geography_marine_polys.shp' #> using driver `ESRI Shapefile' #> Simple feature collection with 306 features and 37 fields #> Geometry type: MULTIPOLYGON #> Dimension: XY #> Bounding box: xmin: -180 ymin: -85.19206 xmax: 179.9999 ymax: 90 #> Geodetic CRS: WGS 84 landmass <- rnaturalearth::ne_countries( scale = \"medium\", returnclass = \"sf\" ) %>% sf::st_transform(cCRS)"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"create-planning-units","dir":"Articles","previous_headings":"Overview","what":"Create Planning Units","title":"A Basic Spatial Planning Workflow","text":"can check PUs look like want add additional properties map, example landmass boundary, can use splnr_gg_add(). can also use customised ggplpot theme can passed list splnr_gg_add() can used plots. example:","code":"PUs <- spatialgridr::get_grid(boundary = Bndry, crs = cCRS, output = \"sf_hex\", resolution = PU_size) (ggPU <- splnr_plot(df = PUs) + ggplot2::theme_bw()) # Plot Planning Units (ggPU <- splnr_plot(df = PUs) + splnr_gg_add( Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = \"Default\" )) splnr_theme <- list( ggplot2::theme_bw(), ggplot2::theme( legend.position = \"right\", legend.direction = \"vertical\", text = ggplot2::element_text(size = 9, colour = \"black\"), axis.text = ggplot2::element_text(size = 9, colour = \"black\"), plot.title = ggplot2::element_text(size = 9), axis.title = ggplot2::element_blank() ) ) (ggPU <- splnr_plot(PUs) + splnr_gg_add( Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"get-the-features","dir":"Articles","previous_headings":"Overview","what":"Get the features","title":"A Basic Spatial Planning Workflow","text":"example, use small subset charismatic megafauna species Coral Sea inform conservation plan. filtered Aquamaps (Aquamaps.org) species distribution models study area following species: species chosen based importance region represent example visualization purposes. Note: structure tribbleabove required downstream plotting. Common denotes common name species, nameVariable scientific name format used Aquamaps, TaxGroup taxonomic grouping species belongs Category represents importance species conservation plan.","code":"Dict <- tibble::tribble( ~nameCommon, ~nameVariable, ~category, \"Green sea turtle\", \"Chelonia_mydas\", \"Reptiles\", \"Loggerhead sea turtle\", \"Caretta_caretta\", \"Reptiles\", \"Hawksbill sea turtle\", \"Eretmochelys_imbricata\", \"Reptiles\", \"Olive ridley sea turtle\", \"Lepidochelys_olivacea\", \"Reptiles\", \"Saltwater crocodile\", \"Crocodylus_porosus\", \"Reptiles\", \"Humpback whale\", \"Megaptera_novaeangliae\", \"Mammals\", \"Common Minke whale\", \"Balaenoptera_acutorostrata\", \"Mammals\", \"Dugong\", \"Dugong_dugon\", \"Mammals\", \"Grey nurse shark\", \"Carcharias_taurus\", \"Sharks and rays\", \"Tiger shark\", \"Galeocerdo_cuvier\", \"Sharks and rays\", \"Great hammerhead shark\", \"Sphyrna_mokarran\", \"Sharks and rays\", \"Giant oceanic manta ray\", \"Mobula_birostris\", \"Sharks and rays\", \"Reef manta ray\", \"Mobula_alfredi\", \"Sharks and rays\", \"Whitetip reef shark\", \"Triaenodon_obesus\", \"Sharks and rays\", \"Red-footed booby\", \"Sula_sula\", \"Birds\" )"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"convert-the-probabilities-to-binary-data","dir":"Articles","previous_headings":"Overview > Get the features","what":"Convert the probabilities to binary data","title":"A Basic Spatial Planning Workflow","text":"can now look feature data used spatial plan individually calling splnr_plot_binFeature(), example see binary habitat suitability map Green sea turtles: suitable habitat Green sea turtles predicted Aquamaps restricted cells close coast. now compare predicted suitable habitat Humpback whales, can see fairly ubiquitous across whole Coral Sea. example, reason classified species either representative suitable habitat wide-ranging within study region important restricted number cells. get better idea overall distribution used features, can also plot number features suitable habitat within planning unit study region.","code":"datEx_species_bin <- spDataFiltered %>% splnr_apply_cutoffs(Cutoffs = 0.5) (ggFeature1 <- splnr_plot( df = datEx_species_bin, col_names = \"Chelonia_mydas\", plot_title = \"Chelonia mydas\", legend_labels = c(\"Absence\", \"Presence\") ) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ) ) (ggFeature <- splnr_plot( datEx_species_bin, \"Megaptera_novaeangliae\", plot_title = \"Megaptera novaeangliae\" ) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme )) (ggFeatNo <- splnr_plot(df = datEx_species_bin, col_names = colnames(datEx_species_bin %>% sf::st_drop_geometry() %>% dplyr::select(-\"cellID\")), plot_title = \"\", legend_title = \"Number of features\") + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"prepare-data-for-prioritisation","dir":"Articles","previous_headings":"Overview > Get the features","what":"Prepare Data for prioritisation","title":"A Basic Spatial Planning Workflow","text":"spatial prioritization also need extract names features pass prioritizr. also create sf object contains information needed prioritization.","code":"feature_names <- splnr_featureNames(datEx_species_bin) out_sf <- datEx_species_bin"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"add-cost","dir":"Articles","previous_headings":"Overview > Get the features > Prepare Data for prioritisation","what":"Add Cost","title":"A Basic Spatial Planning Workflow","text":"example, use minimum set objective function, aims minimize cost whilst meeting conservation targets. add area-based cost include little area possible spatial plan whilst meeting conservation targets. , planning units assigned equal cost 1.","code":"out_sf$Cost_None <- 1 (ggCost <- splnr_plot(out_sf, col_names = \"Cost_None\", legend_title = \"Cost\", legend_labels = \"1\") + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ))"},{"path":[]},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"fishing-effort","dir":"Articles","previous_headings":"","what":"A Basic Spatial Planning Workflow","title":"A Basic Spatial Planning Workflow","text":"gfwr package allows us recover data fisheries across world, set parameter compress TRUE recover Apparent fishing hours per coordinates.","code":"gfw_data <- splnr_get_gfw(region = 'Australia', start_date = \"2022-01-01\", end_date = \"2022-12-31\", temp_res = \"yearly\", cCRS = cCRS, compress = TRUE) %>% sf::st_interpolate_aw(PUs, extensive = TRUE) out_sf$Apparent.Fishing.Hours <- 0 # Add column to PUs out_sf$Apparent.Fishing.Hours[as.numeric(rownames(PUs))] <- gfw_data$Apparent.Fishing.Hours # Put corresponding data in PUs (ggCost <- splnr_plot(out_sf, col_names = \"Apparent.Fishing.Hours\") + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"other-features-1","dir":"Articles","previous_headings":"","what":"A Basic Spatial Planning Workflow","title":"A Basic Spatial Planning Workflow","text":"Many features can taken account cost layers prioritization, provide different features oceandatrpackage.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"set-targets","dir":"Articles","previous_headings":"Overview > Get the features > Prepare Data for prioritisation","what":"Set Targets","title":"A Basic Spatial Planning Workflow","text":"shown previously, assigned conservation features class reflecting importance planning region. Conservation targets assigned target based class, case 30% suitable habitat important 10% representative features. Note: assigned classes targets based ecological information chosen visualization purposes.","code":"catTarg <- c(\"Reptiles\" = 0.3, \"Mammals\" = 0.1, \"Sharks and rays\" = 0.1, \"Birds\" = 0.1) target <- Dict %>% splnr_targets_byCategory(catTarg, catName = \"category\")"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"set-up-conservation-problem","dir":"Articles","previous_headings":"Overview > Get the features","what":"Set up conservation problem","title":"A Basic Spatial Planning Workflow","text":"","code":"datEx_problem <- prioritizr::problem(out_sf, feature_names, \"Cost_None\") %>% prioritizr::add_min_set_objective() %>% prioritizr::add_relative_targets(target$target) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(verbose = FALSE)"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"solve-the-conservation-problem","dir":"Articles","previous_headings":"Overview > Get the features","what":"Solve the conservation problem","title":"A Basic Spatial Planning Workflow","text":"","code":"datEx_soln <- datEx_problem %>% prioritizr::solve.ConservationProblem()"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"visualize-output","dir":"Articles","previous_headings":"Overview > Get the features","what":"Visualize Output","title":"A Basic Spatial Planning Workflow","text":"different ways visualize output prioritization can loosely grouped three categories: + Visualization solution + Visualization targets + Visualization importance scores","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"visualization-of-the-solution","dir":"Articles","previous_headings":"Overview > Get the features > Visualize Output","what":"Visualization of the solution","title":"A Basic Spatial Planning Workflow","text":"plot shows optimal solution planning region meets selected targets chosen features smallest area possible. categorical map displays, planning units selected important meeting conservation targets (dark blue) selected (light blue). can also done overlay cost show solution avoids highly costly areas: Note: example, cost equal planning units.","code":"(ggSoln <- splnr_plot(datEx_soln, col_names = \"solution_1\", legend_title = \"Solution\", legend_labels = c(\"0\",\"1\")) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme )) (ggCostOverlay <- splnr_plot_costOverlay( soln = datEx_soln, Cost = NA, Cost_name = \"Cost_None\" ) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"visualization-of-targets","dir":"Articles","previous_headings":"Overview > Get the features > Visualize Output","what":"Visualization of targets","title":"A Basic Spatial Planning Workflow","text":"visualize well targets met, first need extract much suitable habitat feature selected spatial plan. also includes potential incidental coverage feature included spatial plan can still found planning region. circular bar plot, one additional step data preparation needs done.","code":"dfTarget <- splnr_get_featureRep(datEx_soln, datEx_problem, climsmart = FALSE, solnCol = \"solution_1\" ) (ggTarget <- splnr_plot_featureRep(dfTarget, category = Dict, renameFeatures = TRUE, namesToReplace = Dict, categoryFeatureCol = \"nameCommon\", nr = 1, showTarget = TRUE, )) # dfTargetCirc <- dfTarget %>% # dplyr::select(\"feature\", \"value\", \"group\") %>% # na.omit() # colors <- c( # \"important\" = \"darkgreen\", # \"representative\" = \"darkred\" # ) # legends <- c(\"Important\", \"Representative\") # (ggCircTarg <- splnr_plot_circBplot(df = dfTargetCirc, legend_list = legends, legend_color = colors, impTarget = 30, repTarget = 10))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"visualization-of-importance-scores","dir":"Articles","previous_headings":"Overview > Get the features > Visualize Output","what":"Visualization of importance scores","title":"A Basic Spatial Planning Workflow","text":"Importance scores can help assess relative importance individual selected planning unit spatial plan (information, see https://prioritizr.net/reference/importance.html) , use two different importance scores, Ferrier Score Rarity Weighted Richness. example, scores label similar -coastal- planning units important spatial plan.","code":"ggFerrier <- splnr_plot_importanceScore( soln = datEx_soln, pDat = datEx_problem, method = \"Ferrier\", decimals = 4, legendTitle = \"Importance Score \\n(Ferrier Score)\" ) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ) #> Ferrier Score. ggRWR <- splnr_plot_importanceScore( soln = datEx_soln, pDat = datEx_problem, method = \"RWR\", decimals = 2, legendTitle = \"Importance Score \\n(Rarity Weighted Richness)\" ) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ) #> Rarity Wighted Richness. (ggScores <- patchwork::wrap_plots(ggFerrier + ggRWR))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"comparing-spatial-plans","dir":"Articles","previous_headings":"Overview > Get the features","what":"Comparing Spatial Plans","title":"A Basic Spatial Planning Workflow","text":"Sometimes can useful direct comparison two spatial plans. show achieve package, first need second conservation problem resulting solution. , second spatial plan include already existing marine protected areas area (https://www.protectedplanet.net/en/thematic-areas/wdpa?tab=WDPA) following characteristics: * Status = c(“Designated”, “Established”, “Inscribed”) * Designation Type = c(“National”, “Regional”, “International”, “Applicable”) * IUCN Category = c(“Ia”, “Ib”, “II”, “III”, “IV”) also include targets based IUCN categories prioritise species IUCN status : Vulnerable Endangered Critically Endangered Extinct Wild Extinct assign 30% target species within categories. species fall categories receive inverse area target, species greater area suitable habitat assigned lower target. can also adjust targets based IUCN Category. apply increased target 0.3 species increased thread level IUCN Red List(“EX”, “EW”, “CR”, “EN”, “VU”). Note: Accessing IUCN database requires login token rl_use_iucn() needs added environment using Sys.setenv(IUCN_REDLIST_KEY = \"[Token]\"). can start running rredlist::rl_use_iucn().","code":"# The user can download their own MPAs using this code, # but below we use data already within the package. LockedIn <- splnr_get_MPAs(PUs, \"Australia\") %>% splnr_apply_cutoffs(0.5) %>% dplyr::mutate(wdpa = as.logical(wdpa)) (ggMPA <- splnr_plot(MPAsCoralSea, \"wdpa\") + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme )) minTarget <- 0.1 maxTarget <- 0.2 # Create inverse area target IA_Targets <- splnr_targets_byInverseArea( datEx_species_bin, minTarget, maxTarget ) IUCN_IA_Targets <- IA_Targets %>% splnr_get_IUCNRedList(species_col = \"Species\") %>% # Add RL data to the df splnr_targets_byIUCN(IUCN_target = 0.3)"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"set-up-second-conservation-problem","dir":"Articles","previous_headings":"Overview > Get the features > Comparing Spatial Plans","what":"Set up second conservation problem","title":"A Basic Spatial Planning Workflow","text":"locked areas already existing MPAs. want show overlap selected planning units current MPAs, can can add splnr_gg_add()function. instead want see contours locked areas can set typeLockIn = \"Contours\"splnr_gg_add().","code":"datEx_problem2 <- prioritizr::problem(out_sf, feature_names, \"Cost_None\") %>% prioritizr::add_min_set_objective() %>% prioritizr::add_relative_targets(IA_Targets$target) %>% prioritizr::add_locked_in_constraints(as.logical(MPAsCoralSea$wdpa)) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(verbose = FALSE) # Add a solution object datEx_soln2 <- datEx_problem2 %>% prioritizr::solve.ConservationProblem() (ggSoln2 <- splnr_plot_solution(datEx_soln2) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme )) (splnr_plot_solution(datEx_soln2) + splnr_gg_add( PUs = PUs, Bndry = Bndry, lockIn = MPAsCoralSea, nameLockIn = \"wdpa\", typeLockIn = \"Full\", colorLockIn = \"lightgrey\", alphaLockIn = 0.2, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme )) (splnr_plot_solution(datEx_soln2) + splnr_gg_add( lockIn = MPAsCoralSea, nameLockIn = \"wdpa\", typeLockIn = \"Contours\", colorLockIn = \"lightgrey\", alphaLockIn = 0.2, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"visualize-comparison","dir":"Articles","previous_headings":"Overview > Get the features > Comparing Spatial Plans","what":"Visualize comparison","title":"A Basic Spatial Planning Workflow","text":"plot shows first solution (without current MPAs) differs second solution (including current MPAs. categorical map displays, planning units selected solution 2 solution 1 (red), solution 1 solution 2 (blue), selected solutions (grey). correlation matrix shows similarity Cohen’s Kappa correlation solution 1 solution 2.","code":"(ggComp <- splnr_plot_comparison(datEx_soln, datEx_soln2) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme )) CorrMat <- splnr_get_kappaCorrData(list(datEx_soln, datEx_soln2), name_sol = c(\"soln1\", \"soln2\") ) (ggCorr <- splnr_plot_corrMat(CorrMat, AxisLabels = c(\"Solution 1\", \"Solution 2\") ))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"plotting-selection-frequency","dir":"Articles","previous_headings":"Overview > Get the features","what":"Plotting selection frequency","title":"A Basic Spatial Planning Workflow","text":"Sometimes multiple spatial plans generated, interesting many times planning unit selected across array solutions. demonstrate can done using package, first create array (= portfolio) solutions. One example using portfolio","code":"datEx_soln_portfolio <- datEx_problem %>% prioritizr::add_cuts_portfolio(5) %>% # create a portfolio of solutions prioritizr::solve.ConservationProblem() selFreq <- datEx_soln_portfolio %>% # calculate selection frequency sf::st_drop_geometry() %>% dplyr::mutate(selFreq = as.factor(rowSums( dplyr::select(., dplyr::starts_with(\"solution_\")) ))) %>% sf::st_as_sf(geometry = datEx_soln_portfolio$geometry) %>% dplyr::select(selFreq) (ggselFreq <- splnr_plot_selectionFreq(selFreq) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ))"},{"path":"https://mathmarecol.github.io/spatialplanr/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Jason D. Everett. Author, maintainer. Sandra Neubert. Author.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Everett J, Neubert S (2024). spatialplanr: Help files prioritzr Spatial Planning projects. R package version 0.6.7, https://github.com/MathMarEcol/spatialplanr.","code":"@Manual{, title = {spatialplanr: Help files for prioritzr Spatial Planning projects}, author = {Jason D. Everett and Sandra Neubert}, year = {2024}, note = {R package version 0.6.7}, url = {https://github.com/MathMarEcol/spatialplanr}, }"},{"path":[]},{"path":"https://mathmarecol.github.io/spatialplanr/index.html","id":"overview","dir":"","previous_headings":"","what":"Overview","title":"Help files for prioritzr Spatial Planning projects","text":"package designed assist students staff Mathematical Marine Ecology Lab University Queensland. may useful others well. code written simplify process running prioritizr analysis given region use workflows data MME Lab. still work progress feel free submit pull requests new features code improvements.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Help files for prioritzr Spatial Planning projects","text":"aware package early stages development. Functions documentation complete installing moment risk. still interested, can install development version GitHub :","code":"# install.packages(\"devtools\") devtools::install_github(\"https://github.com/MathMarEcol/spatialplanr\")"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/CoralSeaVelocity.html","id":null,"dir":"Reference","previous_headings":"","what":"Example climate velocity for the example region of the coral sea — CoralSeaVelocity","title":"Example climate velocity for the example region of the coral sea — CoralSeaVelocity","text":"tsf file containing climate velocity (SSP5-8.5) coral sea","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/CoralSeaVelocity.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Example climate velocity for the example region of the coral sea — CoralSeaVelocity","text":"","code":"CoralSeaVelocity"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/CoralSeaVelocity.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Example climate velocity for the example region of the coral sea — CoralSeaVelocity","text":"CoralSeaVelocity data frame 397 rows 3 columns: cellID cell ID planning units vocMagg_transformed Climate velocity column geometry Geometry column sf object","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/CoralSeaVelocity.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Example climate velocity for the example region of the coral sea — CoralSeaVelocity","text":"https://www.iucnredlist.org/","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/IUCN_IA_Targets.html","id":null,"dir":"Reference","previous_headings":"","what":"IUCN and Inverse Area based Targets for Aquamaps example species — IUCN_IA_Targets","title":"IUCN and Inverse Area based Targets for Aquamaps example species — IUCN_IA_Targets","text":"tbl_df file containing IUCN IA targets selected species coral sea","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/IUCN_IA_Targets.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"IUCN and Inverse Area based Targets for Aquamaps example species — IUCN_IA_Targets","text":"","code":"IUCN_IA_Targets"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/IUCN_IA_Targets.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"IUCN and Inverse Area based Targets for Aquamaps example species — IUCN_IA_Targets","text":"IUCN_IA_Targets data frame 15 rows 4 columns: Species Species names found IUCN database Area km2 total suitable habitat species Target Individual species-specific target IUCN_Category IUCN category species","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/IUCN_IA_Targets.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"IUCN and Inverse Area based Targets for Aquamaps example species — IUCN_IA_Targets","text":"https://www.iucnredlist.org/","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/MPAsCoralSea.html","id":null,"dir":"Reference","previous_headings":"","what":"Current MPAs of the Coral Sea — MPAsCoralSea","title":"Current MPAs of the Coral Sea — MPAsCoralSea","text":"sf file containing current marine protected areas coral sea","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/MPAsCoralSea.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Current MPAs of the Coral Sea — MPAsCoralSea","text":"","code":"MPAsCoralSea"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/MPAsCoralSea.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Current MPAs of the Coral Sea — MPAsCoralSea","text":"MPAsCoralSea data frame 397 rows 17 columns: wdpa binary vector denoting presence absence current marine protected area cellID cell ID planning units","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/MPAsCoralSea.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Current MPAs of the Coral Sea — MPAsCoralSea","text":"https://www.protectedplanet.net/en/thematic-areas/wdpa?tab=WDPA","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_PUs.html","id":null,"dir":"Reference","previous_headings":"","what":"Planning Units — dat_PUs","title":"Planning Units — dat_PUs","text":"sf dataframe planning units spatial prioritisation","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_PUs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Planning Units — dat_PUs","text":"","code":"dat_PUs"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_PUs.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Planning Units — dat_PUs","text":"dat_PUs data frame XXXX rows XXX columns: cellID ID number row (cell) dataset geometry sf geometry column","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_PUs.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Planning Units — dat_PUs","text":"\"Made data\"","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_bathy.html","id":null,"dir":"Reference","previous_headings":"","what":"Bathymetry Data — dat_bathy","title":"Bathymetry Data — dat_bathy","text":"Bathymetry data downloaded via oceandatr package","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_bathy.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Bathymetry Data — dat_bathy","text":"","code":"dat_bathy"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_bathy.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Bathymetry Data — dat_bathy","text":"dat_bathy data frame bathymetry data cellID ID number row (cell) dataset bathymetry Bathymetry data geometry sf geometry column","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_bathy.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Bathymetry Data — dat_bathy","text":"\"oceandatr package\"","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_bndry.html","id":null,"dir":"Reference","previous_headings":"","what":"Boundary of planning units — dat_bndry","title":"Boundary of planning units — dat_bndry","text":"sf dataframe planning units spatial prioritisation","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_bndry.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Boundary of planning units — dat_bndry","text":"","code":"dat_bndry"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_bndry.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Boundary of planning units — dat_bndry","text":"dat_bndry data frame XXXX rows XXX columns: cellID ID number row (cell) dataset geometry sf geometry column","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_bndry.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Boundary of planning units — dat_bndry","text":"\"Made data\"","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_category.html","id":null,"dir":"Reference","previous_headings":"","what":"Category vector — dat_category","title":"Category vector — dat_category","text":"tibble containing specific grouping features","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_category.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Category vector — dat_category","text":"","code":"dat_category"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_category.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Category vector — dat_category","text":"dat_category data frame XXXX rows XXX columns: feature features available spatial prioritisation category categories features","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_category.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Category vector — dat_category","text":"\"Made data\"","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_category2.html","id":null,"dir":"Reference","previous_headings":"","what":"Category vector — dat_category2","title":"Category vector — dat_category2","text":"tibble containing specific grouping features","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_category2.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Category vector — dat_category2","text":"","code":"dat_category2"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_category2.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Category vector — dat_category2","text":"dat_category2 data frame XXXX rows XXX columns: feature features available spatial prioritisation category categories features","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_category2.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Category vector — dat_category2","text":"\"Made data\"","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_clim.html","id":null,"dir":"Reference","previous_headings":"","what":"Climate metric data — dat_clim","title":"Climate metric data — dat_clim","text":"sf dataframe planning units spatial prioritisation","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_clim.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Climate metric data — dat_clim","text":"","code":"dat_clim"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_clim.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Climate metric data — dat_clim","text":"dat_clim data frame 780 rows 3 columns: cellID ID number row (cell) dataset geometry sf geometry column metric climate metric information","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_clim.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Climate metric data — dat_clim","text":"\"Made data\"","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_mpas.html","id":null,"dir":"Reference","previous_headings":"","what":"MPA Data — dat_mpas","title":"MPA Data — dat_mpas","text":"sf dataframe planning units spatial prioritisation","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_mpas.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"MPA Data — dat_mpas","text":"","code":"dat_mpas"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_mpas.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"MPA Data — dat_mpas","text":"dat_mpas data frame XXXX rows XXX columns: cellID ID number row (cell) dataset geometry sf geometry column wdpa binary MPA information (1: MPA)","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_mpas.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"MPA Data — dat_mpas","text":"\"Made data\"","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_region.html","id":null,"dir":"Reference","previous_headings":"","what":"Regionalisation — dat_region","title":"Regionalisation — dat_region","text":"sf dataframe planning units spatial prioritisation","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_region.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Regionalisation — dat_region","text":"","code":"dat_region"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_region.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Regionalisation — dat_region","text":"dat_region data frame XXXX rows XXX columns: cellID ID number row (cell) dataset geometry sf geometry column","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_region.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Regionalisation — dat_region","text":"\"Made data\"","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_species_bin.html","id":null,"dir":"Reference","previous_headings":"","what":"Binary Species Data — dat_species_bin","title":"Binary Species Data — dat_species_bin","text":"sf dataframe planning units spatial prioritisation","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_species_bin.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Binary Species Data — dat_species_bin","text":"","code":"dat_species_bin"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_species_bin.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Binary Species Data — dat_species_bin","text":"dat_species_bin data frame XXXX rows XXX columns: cellID ID number row (cell) dataset geometry sf geometry column","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_species_bin.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Binary Species Data — dat_species_bin","text":"\"Made data\"","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_species_bin2.html","id":null,"dir":"Reference","previous_headings":"","what":"Binary Species Data 2 — dat_species_bin2","title":"Binary Species Data 2 — dat_species_bin2","text":"sf dataframe planning units spatial prioritisation","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_species_bin2.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Binary Species Data 2 — dat_species_bin2","text":"","code":"dat_species_bin2"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_species_bin2.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Binary Species Data 2 — dat_species_bin2","text":"dat_species_bin2 data frame XXXX rows XXX columns: cellID ID number row (cell) dataset geometry sf geometry column","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_species_bin2.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Binary Species Data 2 — dat_species_bin2","text":"\"Made data\"","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_species_prob.html","id":null,"dir":"Reference","previous_headings":"","what":"Probability Species Data — dat_species_prob","title":"Probability Species Data — dat_species_prob","text":"sf dataframe planning units spatial prioritisation","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_species_prob.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Probability Species Data — dat_species_prob","text":"","code":"dat_species_prob"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_species_prob.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Probability Species Data — dat_species_prob","text":"dat_species_prob data frame XXXX rows XXX columns: cellID ID number row (cell) dataset geometry sf geometry column","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_species_prob.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Probability Species Data — dat_species_prob","text":"\"Made data\"","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/pipe.html","id":null,"dir":"Reference","previous_headings":"","what":"Pipe operator — %>%","title":"Pipe operator — %>%","text":"See magrittr::%>% details.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/pipe.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Pipe operator — %>%","text":"","code":"lhs %>% rhs"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/spDataFiltered.html","id":null,"dir":"Reference","previous_headings":"","what":"Example data — spDataFiltered","title":"Example data — spDataFiltered","text":"Example data","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/spDataFiltered.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Example data — spDataFiltered","text":"","code":"spDataFiltered"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/spDataFiltered.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Example data — spDataFiltered","text":"spDataFiltered data frame sample species data Species Species names","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/spDataFiltered.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Example data — spDataFiltered","text":"\"Made data\"","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/spatialplanr-package.html","id":null,"dir":"Reference","previous_headings":"","what":"spatialplanr: Help files for prioritzr Spatial Planning projects — spatialplanr-package","title":"spatialplanr: Help files for prioritzr Spatial Planning projects — spatialplanr-package","text":"package provides range tools setting , running plotting spatial plan using prioritizr. intended use Mathematical Marine Ecology Lab UQ, sets projects using approach data sets.","code":""},{"path":[]},{"path":"https://mathmarecol.github.io/spatialplanr/reference/spatialplanr-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"spatialplanr: Help files for prioritzr Spatial Planning projects — spatialplanr-package","text":"Maintainer: Jason D. Everett JaseEverett@gmail.com (ORCID) Authors: Sandra Neubert sandra.neubert97@gmail.com (ORCID)","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_apply_cutoffs.html","id":null,"dir":"Reference","previous_headings":"","what":"Function to apply cutoffs to feature data — splnr_apply_cutoffs","title":"Function to apply cutoffs to feature data — splnr_apply_cutoffs","text":"Function apply cutoffs feature data","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_apply_cutoffs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Function to apply cutoffs to feature data — splnr_apply_cutoffs","text":"","code":"splnr_apply_cutoffs(features, Cutoffs, inverse = FALSE)"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_apply_cutoffs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Function to apply cutoffs to feature data — splnr_apply_cutoffs","text":"features sf dataframe feature information Cutoffs single value named vector cutoffs. inverse TRUE, values Cutoffs used. FALSE (default), values kept.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_apply_cutoffs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Function to apply cutoffs to feature data — splnr_apply_cutoffs","text":"new sf dataframe cutoffs applied.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_apply_cutoffs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Function to apply cutoffs to feature data — splnr_apply_cutoffs","text":"","code":"df <- splnr_apply_cutoffs(dat_species_prob, Cutoffs = 0.5)"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_arrangeFeatures.html","id":null,"dir":"Reference","previous_headings":"","what":"Ensure all features are in the same order. — splnr_arrangeFeatures","title":"Ensure all features are in the same order. — splnr_arrangeFeatures","text":"splnr_arrangeFeatures() sorts data based longitude latitude values.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_arrangeFeatures.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Ensure all features are in the same order. — splnr_arrangeFeatures","text":"","code":"splnr_arrangeFeatures(df)"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_arrangeFeatures.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Ensure all features are in the same order. — splnr_arrangeFeatures","text":"df sf object sort Lon Lat","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_arrangeFeatures.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Ensure all features are in the same order. — splnr_arrangeFeatures","text":"sorted sf object additionl cellID column","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_arrangeFeatures.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Ensure all features are in the same order. — splnr_arrangeFeatures","text":"","code":"df <- dat_species_prob %>% splnr_arrangeFeatures()"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_climate_featureApproach.html","id":null,"dir":"Reference","previous_headings":"","what":"Function to run the feature approach — splnr_climate_featureApproach","title":"Function to run the feature approach — splnr_climate_featureApproach","text":"Function run feature approach","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_climate_featureApproach.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Function to run the feature approach — splnr_climate_featureApproach","text":"","code":"splnr_climate_featureApproach( featuresDF, metricDF, targetsDF, direction, percentile = 35, refugiaTarget = 0.3 )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_climate_featureApproach.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Function to run the feature approach — splnr_climate_featureApproach","text":"featuresDF feature sfobject column cellID metricDF climate metric data.frame 'metric' column name metric values per planning unit. also column cellID targetsDF data.framewith list features \"feature\" column corresponding targets \"target\" column direction direction = 1, metric values low (least climate-smart) high (climate-smart). direction = -1, metric values high (least climate-smart) low (climate-smart). percentile cut-threshold determining whether area climate priority area (e.g., lower 35th percentile warming upper 65th percentile acidification). Note percentile lower limit threshold. refugiaTarget target assigned climate-smart areas","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_climate_featureApproach.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Function to run the feature approach — splnr_climate_featureApproach","text":"list two components: 1. data frame passed prioritizr creating conservation problem containing binary information per planning unit per feature. 2. targets features conservation problem CPA approach used.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_climate_featureApproach.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Function to run the feature approach — splnr_climate_featureApproach","text":"","code":"Features <- dat_species_bin %>% dplyr::select(-\"cellID\") target <- Features %>% sf::st_drop_geometry() %>% colnames() %>% data.frame() %>% setNames(c(\"feature\")) %>% dplyr::mutate(target = 0.3) metric_df <- dat_clim Feature_Approach <- splnr_climate_featureApproach( featuresDF = dat_species_bin, metricDF = metric_df, targetsDF = target, direction = 1 ) #> [1] \"Higher values mean more climate-smart areas.\" out_sf <- Feature_Approach$Features targets <- Feature_Approach$Targets"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_climate_percentileApproach.html","id":null,"dir":"Reference","previous_headings":"","what":"Function to run the percentile approach — splnr_climate_percentileApproach","title":"Function to run the percentile approach — splnr_climate_percentileApproach","text":"Function run percentile approach","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_climate_percentileApproach.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Function to run the percentile approach — splnr_climate_percentileApproach","text":"","code":"splnr_climate_percentileApproach( featuresDF, metricDF, targetsDF, direction, percentile = 35 )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_climate_percentileApproach.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Function to run the percentile approach — splnr_climate_percentileApproach","text":"featuresDF feature sfobject column cellID metricDF climate metric data.frame 'metric' column name metric values per planning unit. also column cellID targetsDF data.framewith list features \"feature\" column corresponding targets \"target\" column direction direction = 1, metric values low (least climate-smart) high (climate-smart). direction = -1, metric values high (least climate-smart) low (climate-smart). percentile cut-threshold determining whether area climate priority area (e.g., lower 35th percentile warming upper 65th percentile acidification). Note percentile lower limit threshold.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_climate_percentileApproach.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Function to run the percentile approach — splnr_climate_percentileApproach","text":"list two components: 1. data frame passed prioritizr creating conservation problem containing binary information per planning unit per feature. 2. targets features conservation problem CPA approach used.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_climate_percentileApproach.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Function to run the percentile approach — splnr_climate_percentileApproach","text":"","code":"Features <- dat_species_bin %>% dplyr::select(-\"cellID\") target <- Features %>% sf::st_drop_geometry() %>% colnames() %>% data.frame() %>% setNames(c(\"feature\")) %>% dplyr::mutate(target = 0.3) metric_df <- dat_clim Percentile_Approach <- splnr_climate_percentileApproach( featuresDF = dat_species_bin, metricDF = metric_df, targetsDF = target, direction = 1 ) #> [1] \"Higher values mean more climate-smart areas.\" out_sf <- Percentile_Approach$Features targets <- Percentile_Approach$Targets"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_climate_priorityAreaApproach.html","id":null,"dir":"Reference","previous_headings":"","what":"Function to run the climate-priority-area approach — splnr_climate_priorityAreaApproach","title":"Function to run the climate-priority-area approach — splnr_climate_priorityAreaApproach","text":"Function run climate-priority-area approach","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_climate_priorityAreaApproach.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Function to run the climate-priority-area approach — splnr_climate_priorityAreaApproach","text":"","code":"splnr_climate_priorityAreaApproach( featuresDF, metricDF, targetsDF, direction, percentile = 5, refugiaTarget = 1 )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_climate_priorityAreaApproach.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Function to run the climate-priority-area approach — splnr_climate_priorityAreaApproach","text":"featuresDF feature sfobject column cellID metricDF climate metric data.frame 'metric' column name metric values per planning unit. also column cellID targetsDF data.framewith list features \"feature\" column corresponding targets \"target\" column direction direction = 1, metric values low (least climate-smart) high (climate-smart). direction = -1, metric values high (least climate-smart) low (climate-smart). percentile cut-threshold determining whether area climate priority area (e.g., lower 35th percentile warming upper 65th percentile acidification). Note percentile lower limit threshold. refugiaTarget target assigned climate-smart areas","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_climate_priorityAreaApproach.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Function to run the climate-priority-area approach — splnr_climate_priorityAreaApproach","text":"list two components: 1. data frame passed prioritizr creating conservation problem containing binary information per planning unit per feature. 2. targets features conservation problem CPA approach used.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_climate_priorityAreaApproach.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Function to run the climate-priority-area approach — splnr_climate_priorityAreaApproach","text":"","code":"Features <- dat_species_bin %>% dplyr::select(-\"cellID\") target <- Features %>% sf::st_drop_geometry() %>% colnames() %>% data.frame() %>% setNames(c(\"feature\")) %>% dplyr::mutate(target = 0.3) metric_df <- dat_clim CPA_Approach <- splnr_climate_priorityAreaApproach( featuresDF = dat_species_bin, metricDF = metric_df, targetsDF = target, direction = -1 ) out_sf <- CPA_Approach$Features targets <- CPA_Approach$Targets"},{"path":[]},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_convert_regionalisation.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Function to interpolate regionalisation data onto Planning Units — splnr_convert_regionalisation","text":"","code":"splnr_convert_regionalisation(dat, PUs, cat_name = NA, col_name = NA)"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_convert_regionalisation.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Function to interpolate regionalisation data onto Planning Units — splnr_convert_regionalisation","text":"dat Dataset raster sf format. PUs sf object Planning Units cat_name character string categories regionalisation col_name name layer","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_convert_regionalisation.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Function to interpolate regionalisation data onto Planning Units — splnr_convert_regionalisation","text":"sf object containing Planning Units feature.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_convert_regionalisation.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Function to interpolate regionalisation data onto Planning Units — splnr_convert_regionalisation","text":"wrapper splnr_Convert2PUs() deals need processes layer seperately dataset needs raster vector format. input contains continuous data, output area-averaged mean planning unit. input binary, output proportion planning unit covered.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_convert_regionalisation.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Function to interpolate regionalisation data onto Planning Units — splnr_convert_regionalisation","text":"","code":"if (FALSE) { # \\dontrun{ df <- splnr_convert_regionalisation(dat, PUs) } # }"},{"path":[]},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_convert_toPUs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Function to interpolate data onto Planning Units — splnr_convert_toPUs","text":"","code":"splnr_convert_toPUs(dat, PlanUnits)"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_convert_toPUs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Function to interpolate data onto Planning Units — splnr_convert_toPUs","text":"dat Dataset filename dataset PlanUnits sf object Planning Units","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_convert_toPUs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Function to interpolate data onto Planning Units — splnr_convert_toPUs","text":"sf object containing Planning Units feature.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_convert_toPUs.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Function to interpolate data onto Planning Units — splnr_convert_toPUs","text":"dataset needs raster vector format. input contains continuous data, output area-averaged mean planning unit. input binary, output proportion planning unit covered.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_convert_toPUs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Function to interpolate data onto Planning Units — splnr_convert_toPUs","text":"","code":"if (FALSE) { # \\dontrun{ df <- splnr_convert_toPUs(dat, PlanUnits) } # }"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_create_polygon.html","id":null,"dir":"Reference","previous_headings":"","what":"Function for creating polygon — splnr_create_polygon","title":"Function for creating polygon — splnr_create_polygon","text":"splnr_create_polygon() allows create polygon based longitude latitude coordinates input data.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_create_polygon.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Function for creating polygon — splnr_create_polygon","text":"","code":"splnr_create_polygon(x, cCRS = \"EPSG:4326\")"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_create_polygon.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Function for creating polygon — splnr_create_polygon","text":"x named vector lon/lat coordinates make sf polygon cCRS CRS use polygon","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_create_polygon.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Function for creating polygon — splnr_create_polygon","text":"sf object polygon","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_create_polygon.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Function for creating polygon — splnr_create_polygon","text":"","code":"splnr_create_polygon(x = dplyr::tibble(x = seq(-50, 50, by = 1), y = 120) %>% dplyr::bind_rows(dplyr::tibble(x = 50, y = seq(120, 180, by = 1))) %>% dplyr::bind_rows(dplyr::tibble(x = seq(50, -50, by = -1), y = 180)) %>% dplyr::bind_rows(dplyr::tibble(x = -50, y = seq(150, 120, by = -1))))"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_featureNames.html","id":null,"dir":"Reference","previous_headings":"","what":"Returns the feature names — splnr_featureNames","title":"Returns the feature names — splnr_featureNames","text":"splnr_featureNames() allows extract names features want pass prioritizr prioritization. requires sf object input returns column names object excluding columns specify exclude argument.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_featureNames.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Returns the feature names — splnr_featureNames","text":"","code":"splnr_featureNames(dat, exclude = NA)"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_featureNames.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Returns the feature names — splnr_featureNames","text":"dat sf dataframe features exclude Character vector columns exclude","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_featureNames.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Returns the feature names — splnr_featureNames","text":"character vector names","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_featureNames.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Returns the feature names — splnr_featureNames","text":"","code":"df <- dat_species_prob %>% splnr_featureNames(exclude = c(\"cellID\"))"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_IUCNRedList.html","id":null,"dir":"Reference","previous_headings":"","what":"Match Species to IUCN RedList — splnr_get_IUCNRedList","title":"Match Species to IUCN RedList — splnr_get_IUCNRedList","text":"First need API key, alphanumeric string provided IUCN need send every request; following function takes website, need fill form (might take 1-2 days receive key) rl_use_iucn() receive email API key, set environmental variable (MUST named IUCN_REDLIST_KEY) need re-step everytime restart R Sys.setenv(IUCN_REDLIST_KEY = \"\") add IUCN_REDLIST_KEY = \"\" .Renviron file permanently set Sys.getenv(\"IUCN_REDLIST_KEY\") #' check Evaluated DD: Data Deficient LC: Least Concern NT: Near Threatened VU: Vulnerable EN: Endangered CR: Critically Endangered EW: Extinct Wild EX: Extinct LRlc: Low risk – least concern LRnt: Low risk – near threatened LRcd: Low risk - conservation dependent Categories care cate <- c(\"EX\",\"EW\",\"CR\",\"EN\",\"VU\")","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_IUCNRedList.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Match Species to IUCN RedList — splnr_get_IUCNRedList","text":"","code":"splnr_get_IUCNRedList(df, species_col = \"Species\")"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_IUCNRedList.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Match Species to IUCN RedList — splnr_get_IUCNRedList","text":"df dataframe containing species matched IUCN redlist species_col string name column containting species name","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_IUCNRedList.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Match Species to IUCN RedList — splnr_get_IUCNRedList","text":"dataframe additional column IUCN_Category","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_IUCNRedList.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Match Species to IUCN RedList — splnr_get_IUCNRedList","text":"","code":"if (FALSE) { # \\dontrun{ df <- data.frame(Species = c(\"Diomedea exulans\", \"Hippocampus kuda\", \"Squatina squatina\")) %>% splnr_get_IUCNRedList() } # }"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_MPAs.html","id":null,"dir":"Reference","previous_headings":"","what":"Get marine parks from the WDPA. — splnr_get_MPAs","title":"Get marine parks from the WDPA. — splnr_get_MPAs","text":"code wrapper wonderful wdpar package written Jeffrey O. Hanson. data interfaced planning units. sf object returned PU area covered selected marine protected areas.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_MPAs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get marine parks from the WDPA. — splnr_get_MPAs","text":"","code":"splnr_get_MPAs( PlanUnits, Countries, Status = c(\"Designated\", \"Established\", \"Inscribed\"), Desig = c(\"National\", \"Regional\", \"International\", \"Not Applicable\"), Category = c(\"Ia\", \"Ib\", \"II\", \"III\", \"IV\"), ... )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_MPAs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get marine parks from the WDPA. — splnr_get_MPAs","text":"PlanUnits Planning Units sf object Countries character vector countries extract MPAs. get MPAs, use \"global\" . Status status field WDPA provides information whether protected area established, designated, proposed time data submitted. Desig designation type category type protected area legally/officially designated proposed. Category Stores IUCN Protected Area Management Categories (recorded field IUCN_CAT) protected areas categories reported ... arguments passed wdpa_fetch()","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_MPAs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get marine parks from the WDPA. — splnr_get_MPAs","text":"sf object MPAs intersected planning units","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_MPAs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get marine parks from the WDPA. — splnr_get_MPAs","text":"","code":"dat <- splnr_get_MPAs(PlanUnits = dat_PUs, Countries = \"Australia\") #> ! importing local data (version Apr 2024); use \"force=TRUE\" if you need latest version. #> Warning: package ‘sf’ was built under R version 4.4.1 #> Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE #> Warning: attribute variables are assumed to be spatially constant throughout all geometries #> Warning: attribute variables are assumed to be spatially constant throughout all geometries aust <- rnaturalearth::ne_countries(country = \"Australia\", returnclass = \"sf\") gg <- ggplot2::ggplot() + ggplot2::geom_sf(data = dat, ggplot2::aes(fill = wdpa)) + ggplot2::geom_sf(data = aust, fill = \"grey50\")"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_boundary.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the boundary of the planning region. — splnr_get_boundary","title":"Get the boundary of the planning region. — splnr_get_boundary","text":"splnr_get_boundary() allows create sf object planning region either based specific coordinate information, rnaturalearth inputs ocean data. Creating boundary often first step conservation planning requirement downstream function sin spatialplanr.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_boundary.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the boundary of the planning region. — splnr_get_boundary","text":"","code":"splnr_get_boundary(Limits, Type = NULL, res = 1, cCRS = \"ESRI:54009\")"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_boundary.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the boundary of the planning region. — splnr_get_boundary","text":"Limits limits boundary. can either 4 element numeric named vector (c(xmin = 150, xmax = 160, ymin = -40, ymax = -30)), vector ocean/sea names, vector EEZs., Type type Limits provided. Options \"Ocean\" \"EEZ\". (required numeric \"Global\" limits provided) res resolution (degrees) create boundary polygon numeric limits provided. cCRS CRS boundary returned ","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_boundary.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the boundary of the planning region. — splnr_get_boundary","text":"boundary planning region","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_boundary.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the boundary of the planning region. — splnr_get_boundary","text":"","code":"Bndry <- splnr_get_boundary(Limits = \"North Atlantic Ocean\", Type = \"Ocean\") #> Reading layer `ne_10m_geography_marine_polys' from data source #> `/private/var/folders/_r/mcmw_qtn0m7cd23cbdqfszl40000gp/T/RtmpmU1Uiz/ne_10m_geography_marine_polys.shp' #> using driver `ESRI Shapefile' #> Simple feature collection with 306 features and 37 fields #> Geometry type: MULTIPOLYGON #> Dimension: XY #> Bounding box: xmin: -180 ymin: -85.19206 xmax: 179.9999 ymax: 90 #> Geodetic CRS: WGS 84 Bndry <- splnr_get_boundary(Limits = \"Global\") Bndry <- splnr_get_boundary(Limits = c(\"xmin\" = 150, \"xmax\" = 170, \"ymin\" = -40, \"ymax\" = -20))"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_distCoast.html","id":null,"dir":"Reference","previous_headings":"","what":"Function to compute distances to nearest coastline for each centroid of each planning unit in the 'sf' object provided. — splnr_get_distCoast","title":"Function to compute distances to nearest coastline for each centroid of each planning unit in the 'sf' object provided. — splnr_get_distCoast","text":"code takes sf object return updated new coastDistance column. output inherits crs sf object ensure correct projection needs","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_distCoast.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Function to compute distances to nearest coastline for each centroid of each planning unit in the 'sf' object provided. — splnr_get_distCoast","text":"","code":"splnr_get_distCoast(dat_sf, custom_coast = NULL, res = NULL)"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_distCoast.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Function to compute distances to nearest coastline for each centroid of each planning unit in the 'sf' object provided. — splnr_get_distCoast","text":"dat_sf sf object. custom_coast sf coastline object (optional) res Allow user choose resolution (small, medium, large) rnaturalearth data used coastline.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_distCoast.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Function to compute distances to nearest coastline for each centroid of each planning unit in the 'sf' object provided. — splnr_get_distCoast","text":"sf object distances nearest coast","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_distCoast.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Function to compute distances to nearest coastline for each centroid of each planning unit in the 'sf' object provided. — splnr_get_distCoast","text":"Written Kristine Buenafe Written: March/April 2023 Modified Kilian Barreiro Updated: December 2023","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_distCoast.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Function to compute distances to nearest coastline for each centroid of each planning unit in the 'sf' object provided. — splnr_get_distCoast","text":"","code":"bbox <- sf::st_bbox(c(xmin = 0, ymin = 0, xmax = 3, ymax = 3)) grid <- sf::st_make_grid(bbox, n = c(3, 3), what = \"polygons\") grid <- sf::st_sf(geometry = grid) %>% sf::st_set_crs(\"EPSG:4326\") splnr_get_distCoast(grid) #> Simple feature collection with 9 features and 1 field #> Geometry type: POLYGON #> Dimension: XY #> Bounding box: xmin: 0 ymin: 0 xmax: 3 ymax: 3 #> Geodetic CRS: WGS 84 #> geometry coastDistance_km #> 1 POLYGON ((0 0, 1 0, 1 1, 0 ... 544.9762 #> 2 POLYGON ((1 0, 2 0, 2 1, 1 ... 553.2552 #> 3 POLYGON ((2 0, 3 0, 3 1, 2 ... 442.2715 #> 4 POLYGON ((0 1, 1 1, 1 2, 0 ... 438.7047 #> 5 POLYGON ((1 1, 2 1, 2 2, 1 ... 480.9762 #> 6 POLYGON ((2 1, 3 1, 3 2, 2 ... 462.5574 #> 7 POLYGON ((0 2, 1 2, 1 3, 0 ... 335.6332 #> 8 POLYGON ((1 2, 2 2, 2 3, 1 ... 371.9517 #> 9 POLYGON ((2 2, 3 2, 3 3, 2 ... 406.2456 cCRS <- \"ESRI:54009\" Bndry <- splnr_get_boundary(Limits = \"Coral Sea\", Type = \"Oceans\", cCRS = cCRS) #> Reading layer `ne_10m_geography_marine_polys' from data source #> `/private/var/folders/_r/mcmw_qtn0m7cd23cbdqfszl40000gp/T/RtmpmU1Uiz/ne_10m_geography_marine_polys.shp' #> using driver `ESRI Shapefile' #> Simple feature collection with 306 features and 37 fields #> Geometry type: MULTIPOLYGON #> Dimension: XY #> Bounding box: xmin: -180 ymin: -85.19206 xmax: 179.9999 ymax: 90 #> Geodetic CRS: WGS 84 landmass <- rnaturalearth::ne_countries( scale = \"medium\", returnclass = \"sf\" ) %>% sf::st_transform(cCRS)"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_featureRep.html","id":null,"dir":"Reference","previous_headings":"","what":"Prepare data to plot how well targets are met — splnr_get_featureRep","title":"Prepare data to plot how well targets are met — splnr_get_featureRep","text":"Prepare data plot well targets met","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_featureRep.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Prepare data to plot how well targets are met — splnr_get_featureRep","text":"","code":"splnr_get_featureRep( soln, pDat, targetsDF = NA, climsmart = FALSE, climsmartApproach = 0, solnCol = \"solution_1\" )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_featureRep.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Prepare data to plot how well targets are met — splnr_get_featureRep","text":"soln prioritizr solution pDat prioritizr problem targetsDF data.framewith list features \"feature\" column corresponding targets \"target\" column climsmart logical denoting whether spatial planning done climate-smart (targets calculated differently) climsmartApproach either 0,1,2 3 depending climate-smart approach used (0 = None; 1 = Climate Priority Area; 2 = Feature; 3 = Percentile). solnCol Name column solution","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_featureRep.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Prepare data to plot how well targets are met — splnr_get_featureRep","text":"tbl_df dataframe","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_featureRep.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Prepare data to plot how well targets are met — splnr_get_featureRep","text":"","code":"pDat <- prioritizr::problem(dat_species_bin %>% dplyr::mutate(Cost = runif(n = dim(.)[[1]])), features = c(\"Spp1\", \"Spp2\", \"Spp3\"), cost_column = \"Cost\" ) %>% prioritizr::add_min_set_objective() %>% prioritizr::add_relative_targets(0.3) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(verbose = FALSE) soln <- pDat %>% prioritizr::solve.ConservationProblem() df <- splnr_get_featureRep( soln = soln, pDat = pDat )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_gfw.html","id":null,"dir":"Reference","previous_headings":"","what":"The get_gfwData function recover the data of Global Fishing Watch and returns it as a sf object. — splnr_get_gfw","title":"The get_gfwData function recover the data of Global Fishing Watch and returns it as a sf object. — splnr_get_gfw","text":"possibilities offered function explained vignette(\"GlobalFishingWatch\")","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_gfw.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"The get_gfwData function recover the data of Global Fishing Watch and returns it as a sf object. — splnr_get_gfw","text":"","code":"splnr_get_gfw( region, start_date, end_date, temp_res, spat_res = \"LOW\", region_source = \"EEZ\", key = gfwr::gfw_auth(), cCRS = \"EPSG:4326\", compress = FALSE )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_gfw.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"The get_gfwData function recover the data of Global Fishing Watch and returns it as a sf object. — splnr_get_gfw","text":"region Region studied (character) geojson shape filter raster start_date Start date (waited format : \"%Y-%m-%d\"). end_date End date (waited format : \"%Y-%m-%d\"). temp_res Temporal resolution (\"daily\",\"monthly\",\"yearly\"). spat_res Spatial resolution (\"low\" 0.1 degree, \"high\" 0.01 degree). region_source source region ('eez','mpa', 'rfmo' 'user_json') key Token GFW API (see details GlobalFishingWatch vignette). cCRS crs sf returned (default = \"EPSG:4326\"). compress Binary operator compress (aggregate) data per coordinates (default = FALSE).","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_gfw.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"The get_gfwData function recover the data of Global Fishing Watch and returns it as a sf object. — splnr_get_gfw","text":"sf object gfw data.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_gfw.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"The get_gfwData function recover the data of Global Fishing Watch and returns it as a sf object. — splnr_get_gfw","text":"parameters get_raster function, plus cCRS crs sf_modification Different possible values can combined : Time Range, Flag, Geartype. (combination can : c('Time Range','Geartype'), want get sum fishing hours per date geartype, example want display drifting longline fishing specific year) Notes : moment limited EEZs region, can potentially restrict working area specific MPAs. Days indicated the__ start_date end_date __variables included data recovery. code takes several parameters described return sf object gfw data aggregated (param compress)","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_gfw.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"The get_gfwData function recover the data of Global Fishing Watch and returns it as a sf object. — splnr_get_gfw","text":"","code":"if (FALSE) { # \\dontrun{ gfw_data <- splnr_get_gfw('Australia', \"2021-01-01\", \"2022-12-31\", \"YEARLY\", cCRS = \"ESRI:54009\", compress = TRUE) } # }"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_kappaCorrData.html","id":null,"dir":"Reference","previous_headings":"","what":"Prepare data to plot Cohen's Kappa correlation matrix — splnr_get_kappaCorrData","title":"Prepare data to plot Cohen's Kappa correlation matrix — splnr_get_kappaCorrData","text":"Conservation planning often requires comparison outputs solutions different conservation problems. One way compare solutions correlating solutions using Cohen's Kappa. splnr_get_kappaCorrData() takes list prioritizr solutions perform Cohen's Kappa correlation solution. resulting correlation matrix symmetrical along main diagonal contains Cohen's Kappa pairwise correlation solutions. main diagonal always 1. correlation matrix obtained function can passed onto splnr_plot_corrMat().","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_kappaCorrData.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Prepare data to plot Cohen's Kappa correlation matrix — splnr_get_kappaCorrData","text":"","code":"splnr_get_kappaCorrData(sol, name_sol)"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_kappaCorrData.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Prepare data to plot Cohen's Kappa correlation matrix — splnr_get_kappaCorrData","text":"sol List prioritizr solutions (sf objects) solutions column name solution_1 name_sol Name tags different solutions","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_kappaCorrData.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Prepare data to plot Cohen's Kappa correlation matrix — splnr_get_kappaCorrData","text":"matrixOut matrix","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_kappaCorrData.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Prepare data to plot Cohen's Kappa correlation matrix — splnr_get_kappaCorrData","text":"","code":"# 30 % target for problem/solution 1 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() # 50 % target for problem/solution 2 dat_problem2 <- 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.5) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(verbose = FALSE) dat_soln2 <- dat_problem2 %>% prioritizr::solve.ConservationProblem() corrMat <- splnr_get_kappaCorrData(list(dat_soln, dat_soln2), name_sol = c(\"soln1\", \"soln2\")) #> New names: #> • `soln1` -> `soln1...1` #> • `soln1` -> `soln1...2` #> New names: #> • `soln2` -> `soln2...1` #> • `soln2` -> `soln2...2` #> New names: #> • `` -> `...1` #> • `` -> `...2`"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_selFreq.html","id":null,"dir":"Reference","previous_headings":"","what":"Prepare data to plot Selection Frequency of planning units — splnr_get_selFreq","title":"Prepare data to plot Selection Frequency of planning units — splnr_get_selFreq","text":"multiple spatial plans generated, often interested many times planning unit selected across array solutions. array can either list solutions different conservation problems generated portfolio approach prioritizr. splnr_get_selFreq() allows calculate selection frequency planning unit either list portfolio solutions. resulting sf object can passed visualization spatialplanr function splnr_plot_selectionFreq().","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_selFreq.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Prepare data to plot Selection Frequency of planning units — splnr_get_selFreq","text":"","code":"splnr_get_selFreq(solnMany, type = \"portfolio\")"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_selFreq.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Prepare data to plot Selection Frequency of planning units — splnr_get_selFreq","text":"solnMany List portfolio prioritizr solutions type Either \"portfolio\" (sf object) portfolio produced using prioritizr \"list\" list solutions","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_selFreq.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Prepare data to plot Selection Frequency of planning units — splnr_get_selFreq","text":"selFreq sf object containing column selection frequency (sum solutions).","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_selFreq.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Prepare data to plot Selection Frequency of planning units — splnr_get_selFreq","text":"","code":"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() # create conservation problem that contains a portfolio of solutions dat_soln_portfolio <- dat_problem %>% prioritizr::add_cuts_portfolio(number_solutions = 5) %>% prioritizr::solve.ConservationProblem() selFreq <- splnr_get_selFreq(solnMany = dat_soln_portfolio, type = \"portfolio\") (splnr_plot_selectionFreq(selFreq))"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_gg_add.html","id":null,"dir":"Reference","previous_headings":"","what":"Add-ons for plotting — splnr_gg_add","title":"Add-ons for plotting — splnr_gg_add","text":"function allows customise plots simple reproducible way, giving option several inputs can included maps produced functions package.can combined spatialplanr spatial plotting functions.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_gg_add.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add-ons for plotting — splnr_gg_add","text":"","code":"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\" )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_gg_add.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add-ons for plotting — splnr_gg_add","text":"PUs Planning Units sf object colorPUs color value outline planning units. Bndry planning region boundaries sf object colorBndry color value outline boundary. overlay sf object overlay polygon. colorOverlay color value overlay. overlay2 sf object overlay polygon. colorOverlay2 color value overlay. overlay3 sf object overlay polygon. colorOverlay3 color value overlay. contours sf object contours important visualise (e.g. outline sea mounts, ridges; can produced terra::.contour()); 6 different contours possible. colorConts color value contours. cropOverlay sf object boundary box used cropping overlay object. lockIn sf object binary data locked areas prioritisation (e.g. MPAs). typeLockIn Either \"Full\" \"Contours\"; \"Full\" maps locked areas top planning units; \"Contours\" draws outline locked areas. nameLockIn column data frame contains binary information locked areas plot alphaLockIn value (0-1) opacity locked areas plotted top plots. colorLockIn color value locked areas. legendLockIn character value title legend locked areas. Can empty (\"\"). labelLockIn legend label locked area (e.g. MPAs) ggtheme theme applied plot. Can either NA (default ggplot), \"Default\" (default spatialplanr: theme_bw() basic theme settings) user-defined list theme properties.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_gg_add.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add-ons for plotting — splnr_gg_add","text":"ggplot object plot","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_gg_add.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add-ons for plotting — splnr_gg_add","text":"","code":"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."},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_match_names.html","id":null,"dir":"Reference","previous_headings":"","what":"Substitute numbers for all_names in regionalisations — splnr_match_names","title":"Substitute numbers for all_names in regionalisations — splnr_match_names","text":"Many regionalisations numeric values shape files correspond vector names. provide function quickly replace numbers names.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_match_names.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Substitute numbers for all_names in regionalisations — splnr_match_names","text":"","code":"splnr_match_names(dat, nam)"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_match_names.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Substitute numbers for all_names in regionalisations — splnr_match_names","text":"dat sf data frame one column numeric/integer corresponding nam nam Named character vector names corresponding column dat recode","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_match_names.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Substitute numbers for all_names in regionalisations — splnr_match_names","text":"sf dataframe numeric regionalisations substituted category names","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_match_names.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Substitute numbers for all_names in regionalisations — splnr_match_names","text":"","code":"dat <- dat_region %>% dplyr::select(-cellID) nam <- c(\"Region1\" = \"SE Aust\", \"Region2\" = \"Tas\", \"Region3\" = \"NE Aust\") df <- splnr_match_names(dat, nam)"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot.html","id":null,"dir":"Reference","previous_headings":"","what":"Function to plot data. — splnr_plot","title":"Function to plot data. — splnr_plot","text":"(now can replace splnr_plot_cost(), splnr_plot_binFeature(), splnr_plot_MPAs(), splnr_plot_featureNo())","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Function to plot data. — splnr_plot","text":"","code":"splnr_plot( df, col_names = NULL, paletteName = \"YlGnBu\", colourVals = c(\"#c6dbef\", \"#3182bd\"), plot_title = \"\", legend_title = NULL, legend_labels = NULL )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Function to plot data. — splnr_plot","text":"df dataframe containing data plotted. must include geometry column used geom_sf. col_names list column names include plot. specified, columns used color plot. paletteName name color palette use filling. Default \"YlGnBu\". colourVals color values use col_names specified data binary. plot_title title plot. legend_title title legend. legend_labels vector strings containing labels use legend values.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Function to plot data. — splnr_plot","text":"ggplot object.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Function to plot data. — splnr_plot","text":"Written Kilian Barreiro Written: February 2024 Plot Spatial Data, returns gg object","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Function to plot data. — splnr_plot","text":"","code":"# Binary plot of species distribution splnr_plot(df = dat_species_bin, col_names = \"Spp1\", legend_title = \"Legend\", legend_labels = c(\"Absent\", \"Present\")) #> Coordinate system already present. Adding new coordinate system, which will #> replace the existing one. # Logical plot of species distribution splnr_plot(df = dat_species_bin %>% dplyr::mutate(dplyr::across( tidyselect::starts_with(\"Spp\"), as.logical)), col_names = \"Spp1\", legend_title = \"Legend\", legend_labels = c(\"Absent\", \"Present\")) #> Coordinate system already present. Adding new coordinate system, which will #> replace the existing one. # Continuous plot of bathymetry# splnr_plot(df = dat_bathy, col_names = \"bathymetry\", plot_title = \"Bathymetry\", legend_title = \"Bathymetry (m)\") #> Coordinate system already present. Adding new coordinate system, which will #> replace the existing one. # Plot Planning Units splnr_plot(df = dat_PUs) #> Coordinate system already present. Adding new coordinate system, which will #> replace the existing one. # Multi binary features splnr_plot(df = dat_species_bin, col_names = colnames(dat_species_bin %>% sf::st_drop_geometry() %>% dplyr::select( tidyselect::starts_with(\"Spp\"))), legend_title = \"Number of features\") #> Coordinate system already present. Adding new coordinate system, which will #> replace the existing one."},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_MPAs.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot MPAs — splnr_plot_MPAs","title":"Plot MPAs — splnr_plot_MPAs","text":"splnr_plot_MPAs() allows plot either outline area MPAs existing planning region (example extracted spatialplanrfunction splnr_get_MPAs()) customisable way using ggplot2. function requires sf object containing information whether planning unit planning region lies within MPA column called wdpa outputs ggobject. can combined spatialplanr function splnr_gg_add().","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_MPAs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot MPAs — splnr_plot_MPAs","text":"","code":"splnr_plot_MPAs( df, colorVals = c(`TRUE` = \"blue\", `FALSE` = \"white\"), showLegend = TRUE, plotTitle = \"Locked In Areas\", legendTitle = \"\" )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_MPAs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot MPAs — splnr_plot_MPAs","text":"df sf object marine protected areas colorVals list object named vectors match color value according name. \"TRUE\" stands selected planning units. showLegend logical command whether show legend solution (Default: TRUE). plotTitle character value title plot. Can empty (\"\"). legendTitle character value title legend. Can empty (\"\").","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_MPAs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot MPAs — splnr_plot_MPAs","text":"ggplot object plot","code":""},{"path":[]},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_MPAs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot MPAs — splnr_plot_MPAs","text":"","code":"if (FALSE) { # \\dontrun{ splnr_plot_MPAs(dat_mpas) } # }"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_binFeature.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot binary feature — splnr_plot_binFeature","title":"Plot binary feature — splnr_plot_binFeature","text":"splnr_plot_binFeature() allows plot presences absences feature planning region customisable way using ggplot2. function requires sf object binary information feature(0 absences 1 presences, example created continuous data spatialplanr function splnr_apply_cutoffs()). outputs ggobject can combined spatialplanr function splnr_gg_add().","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_binFeature.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot binary feature — splnr_plot_binFeature","text":"","code":"splnr_plot_binFeature( df, colInterest, colorVals = c(Suitable = \"#3182bd\", `Not Suitable` = \"#c6dbef\"), showLegend = TRUE, plotTitle = \" \", legendTitle = \"Habitat\" )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_binFeature.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot binary feature — splnr_plot_binFeature","text":"df data frame binary feature information colInterest column data frame contains binary information feature plot colorVals list object named vectors match color value according name. \"TRUE\" stands selected planning units. showLegend logical command whether show legend solution (Default: TRUE). plotTitle character value title plot. Can empty (\"\"). legendTitle character value title legend. Can empty (\"\").","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_binFeature.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot binary feature — splnr_plot_binFeature","text":"ggplot object plot","code":""},{"path":[]},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_binFeature.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot binary feature — splnr_plot_binFeature","text":"","code":"if (FALSE) { # \\dontrun{ splnr_plot_binFeature(dat_species_bin, dat_species_bin$Spp1) } # }"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_circBplot.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot circular barplot — splnr_plot_circBplot","title":"Plot circular barplot — splnr_plot_circBplot","text":"Plot circular barplot","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_circBplot.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot circular barplot — splnr_plot_circBplot","text":"","code":"splnr_plot_circBplot( df, legend_color, legend_list, indicateTargets = TRUE, impTarget = NA, repTarget = NA, colTarget = \"red\" )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_circBplot.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot circular barplot — splnr_plot_circBplot","text":"df data frame following column names: feature, value, group legend_color vector list colors; group names corresponding colors legend_list list groups/legends groups indicateTargets logical whether show targets set impTarget target important features (%) repTarget target representative features (%) colTarget string colour value indicator line","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_circBplot.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot circular barplot — splnr_plot_circBplot","text":"ggplot object plot","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_circBplot.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot circular barplot — splnr_plot_circBplot","text":"","code":"# DISCLAIMER: THIS SOLUTION IS NOT ACTUALLY RUN WITH THESE TARGETS YET 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() s1 <- dat_soln %>% tibble::as_tibble() p1 <- dat_problem df_rep_imp <- prioritizr::eval_feature_representation_summary( p1, s1[, \"solution_1\"] ) %>% dplyr::select(feature, relative_held) %>% dplyr::mutate(relative_held = relative_held * 100) imp_layers <- c(\"Spp1\", \"Spp3\") target <- data.frame(feature = c(\"Spp1\", \"Spp2\", \"Spp3\", \"Spp4\", \"Spp5\")) %>% dplyr::mutate(class = dplyr::if_else(.data$feature %in% imp_layers, \"important\", \"representative\" )) %>% dplyr::mutate(target = dplyr::if_else(class == \"important\", 50 / 100, 30 / 100 )) df <- merge(df_rep_imp, target) %>% dplyr::select(-target) %>% na.omit() %>% dplyr::rename(value = relative_held) %>% dplyr::rename(group = class) colors <- c( \"important\" = \"darkgreen\", \"representative\" = \"darkred\" ) legends <- c(\"Important\", \"Representative\") (splnr_plot_circBplot(df, legend_list = legends, legend_color = colors, impTarget = 50, repTarget = 30 )) #> Warning: Removed 4 rows containing missing values or values outside the scale range #> (`geom_bar()`). #> Warning: Removed 6 rows containing missing values or values outside the scale range #> (`geom_text()`)."},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_climData.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot climate data — splnr_plot_climData","title":"Plot climate data — splnr_plot_climData","text":"Plot climate data","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_climData.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot climate data — splnr_plot_climData","text":"","code":"splnr_plot_climData( df, colInterest, colorMap = \"C\", plotTitle = \" \", legendTitle = \"Climate metric\" )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_climData.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot climate data — splnr_plot_climData","text":"df sf object climate metric information colInterest column data frame contains metric informatin colorMap character string indicating color map use (see https://ggplot2.tidyverse.org/reference/scale_viridis.html options) plotTitle character value title plot. Can empty (\"\"). legendTitle character value title legend. Can empty (\"\").","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_climData.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot climate data — splnr_plot_climData","text":"ggplot object plot","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_climData.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot climate data — splnr_plot_climData","text":"","code":"splnr_plot_climData(df = dat_clim, colInterest = \"metric\")"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_climKernelDensity.html","id":null,"dir":"Reference","previous_headings":"","what":"Kernel Density Plots for climate-smart spatial plans — splnr_plot_climKernelDensity","title":"Kernel Density Plots for climate-smart spatial plans — splnr_plot_climKernelDensity","text":"Kernel Density Plots climate-smart spatial plans","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_climKernelDensity.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Kernel Density Plots for climate-smart spatial plans — splnr_plot_climKernelDensity","text":"","code":"splnr_plot_climKernelDensity( soln, names = NA, type = \"Normal\", colorMap = \"C\", legendTitle = expression(\" °C y\"^\"-1\" * \"\"), xAxisLab = expression(\"Climate warming ( °C y\"^\"-1\" * \")\") )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_climKernelDensity.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Kernel Density Plots for climate-smart spatial plans — splnr_plot_climKernelDensity","text":"soln type \"Publication\": list prioirtizr solutions (e.g. solution_list = list(s1, s2)) containing \"metric\" column containing used climate metric information; type \"App\": needs prioritizr solution names list names solutions (names = c(\"Input 1\", \"Input 2\")) type plotting style kernel density plots. Either \"Publication\" gives axis information etc., \"App\" condenses information plot simplify stakeholders. colorMap character string indicating color map use (see https://ggplot2.tidyverse.org/reference/scale_viridis.html options) legendTitle character value title legend. Can empty (\"\"). xAxisLab characted value x Axis label depending climate metric input","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_climKernelDensity.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Kernel Density Plots for climate-smart spatial plans — splnr_plot_climKernelDensity","text":"ggplot object plot","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_climKernelDensity.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Kernel Density Plots for climate-smart spatial plans — splnr_plot_climKernelDensity","text":"","code":"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\")"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_comparison.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot solution comparison — splnr_plot_comparison","title":"Plot solution comparison — splnr_plot_comparison","text":"Conservation planning often requires comparison outputs solutions different conservation problems. One way compare solutions spatially visualising different planning units selected two separate solutions conservation problems. splnr_plot_comparison() allows map differences two solutions customisable way using ggplot2. function requires two separate sf objects containing solution_1 column indicating binary solution (selected vs selected) prioritizr conservation problem. outputs ggobject can combined spatialplanr function splnr_gg_add().","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_comparison.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot solution comparison — splnr_plot_comparison","text":"","code":"splnr_plot_comparison( soln1, soln2, legendTitle = \"Scenario 2 compared to Scenario 1:\" )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_comparison.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot solution comparison — splnr_plot_comparison","text":"soln1 first prioritizr solution soln2 second prioritizr solution legendTitle character value title legend. Can empty (\"\").","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_comparison.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot solution comparison — splnr_plot_comparison","text":"ggplot object plot","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_comparison.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot solution comparison — splnr_plot_comparison","text":"","code":"# 30 % target for problem/solution 1 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() # 50 % target for problem/solution 2 dat_problem2 <- 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.5) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(verbose = FALSE) dat_soln2 <- dat_problem2 %>% prioritizr::solve.ConservationProblem() (splnr_plot_comparison(dat_soln, dat_soln2))"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_corrMat.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot correlation matrices — splnr_plot_corrMat","title":"Plot correlation matrices — splnr_plot_corrMat","text":"Conservation planning often requires comparison outputs solutions different conservation problems. One way compare solutions correlating solutions using Cohen's Kappa. splnr_plot_corrMat() allows visualize correlation matrix different solutions (example produced spatialplanr function splnr_get_kappaCorrData()).","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_corrMat.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot correlation matrices — splnr_plot_corrMat","text":"","code":"splnr_plot_corrMat( x, colourGradient = c(\"#BB4444\", \"#FFFFFF\", \"#4477AA\"), legendTitle = \"Correlation \\ncoefficient\", AxisLabels = NULL, plotTitle = \"\" )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_corrMat.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot correlation matrices — splnr_plot_corrMat","text":"x correlation matrix prioritizr solutions colourGradient list three colour values high positive, high negative correlation legendTitle character value title legend. Can empty (\"\"). AxisLabels list labels solutions correlated (Default: NULL). Length needs match number correlated solutions. plotTitle character value title plot. Can empty (\"\").","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_corrMat.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot correlation matrices — splnr_plot_corrMat","text":"ggplot object plot","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_corrMat.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot correlation matrices — splnr_plot_corrMat","text":"","code":"# 30 % target for problem/solution 1 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() # 50 % target for problem/solution 2 dat_problem2 <- 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.5) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(verbose = FALSE) dat_soln2 <- dat_problem2 %>% prioritizr::solve.ConservationProblem() CorrMat <- splnr_get_kappaCorrData(list(dat_soln, dat_soln2), name_sol = c(\"soln1\", \"soln2\")) #> New names: #> • `soln1` -> `soln1...1` #> • `soln1` -> `soln1...2` #> New names: #> • `soln2` -> `soln2...1` #> • `soln2` -> `soln2...2` #> New names: #> • `` -> `...1` #> • `` -> `...2` (splnr_plot_corrMat(CorrMat, AxisLabels = c(\"Solution 1\", \"Solution 2\"))) #> Scale for fill is already present. #> Adding another scale for fill, which will replace the existing scale. #> Scale for x is already present. #> Adding another scale for x, which will replace the existing scale."},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_cost.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot cost — splnr_plot_cost","title":"Plot cost — splnr_plot_cost","text":"splnr_plot_cost() allows plot cost within planning units planning region customisable way using ggplot2. function requires sf object cost column outputs ggobject. can combined spatialplanr function splnr_gg_add().","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_cost.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot cost — splnr_plot_cost","text":"","code":"splnr_plot_cost( Cost, Cost_name = \"Cost\", legendTitle = \"Cost\", paletteName = \"YlGnBu\", plotTitle = \"\" )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_cost.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot cost — splnr_plot_cost","text":"Cost sf object cost prioritizr Cost_name Name cost column legendTitle character value title legend. Can empty (\"\"). paletteName string (number) color palette use. Available palettes can found https://ggplot2.tidyverse.org/reference/scale_brewer.html. plotTitle character value title plot. Can empty (\"\").","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_cost.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot cost — splnr_plot_cost","text":"ggplot object plot","code":""},{"path":[]},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_cost.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot cost — splnr_plot_cost","text":"","code":"if (FALSE) { # \\dontrun{ 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() dat_cost <- dat_soln %>% dplyr::mutate(Cost = runif(n = dim(.)[[1]])) (splnr_plot_cost(dat_cost)) } # }"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_costOverlay.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot cost overlay — splnr_plot_costOverlay","title":"Plot cost overlay — splnr_plot_costOverlay","text":"splnr_plot_costOverlay() allows plot cost planning units planning region top solution conservation problem created prioritizr customisable way using ggplot2. function requires solution sf object column called solution_1 well cost column outputs ggobject. can combined spatialplanr function splnr_gg_add().","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_costOverlay.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot cost overlay — splnr_plot_costOverlay","text":"","code":"splnr_plot_costOverlay( soln, Cost = NA, Cost_name = \"Cost\", legendTitle = \"Cost\", plotTitle = \"Solution overlaid with cost\" )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_costOverlay.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot cost overlay — splnr_plot_costOverlay","text":"soln prioritizr solution Cost sf object cost prioritizr.case prioritizrsolution contain cost, alternative cost object provided used generate solution (default: NA). Cost_name Name cost column legendTitle character value title legend. Can empty (\"\"). plotTitle character value title plot. Can empty (\"\").","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_costOverlay.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot cost overlay — splnr_plot_costOverlay","text":"ggplot object plot","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_costOverlay.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot cost overlay — splnr_plot_costOverlay","text":"","code":"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_costOverlay(soln = dat_soln)"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_featureNo.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot number of features — splnr_plot_featureNo","title":"Plot number of features — splnr_plot_featureNo","text":"splnr_plot_featureNo() allows use ggplot2 visually inspect number features per planning unit used inputs conservation problem. features species, map can seen visualisation species richness planning region.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_featureNo.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot number of features — splnr_plot_featureNo","text":"","code":"splnr_plot_featureNo( df, showLegend = TRUE, paletteName = \"YlGnBu\", plotTitle = \"Number of Features\", legendTitle = \"Features\" )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_featureNo.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot number of features — splnr_plot_featureNo","text":"df sf object features showLegend logical command whether show legend solution (Default: TRUE). paletteName string (number) color palette use. Available palettes can found https://ggplot2.tidyverse.org/reference/scale_brewer.html. plotTitle character value title plot. Can empty (\"\"). legendTitle character value title legend. Can empty (\"\").","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_featureNo.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot number of features — splnr_plot_featureNo","text":"ggplot object plot","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_featureNo.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Plot number of features — splnr_plot_featureNo","text":"function requires sf object binary information features want include richness plot (0 absences 1 presences, example created continuous data spatialplanr function splnr_apply_cutoffs()). outputs ggobject can combined spatialplanr function splnr_gg_add().","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_featureNo.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot number of features — splnr_plot_featureNo","text":"","code":"if (FALSE) { # \\dontrun{ (splnr_plot_featureNo(dat_species_bin)) } # }"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_featureRep.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot how well targets are met — splnr_plot_featureRep","title":"Plot how well targets are met — splnr_plot_featureRep","text":"Plot well targets met","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_featureRep.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot how well targets are met — splnr_plot_featureRep","text":"","code":"splnr_plot_featureRep( df, category = NA, categoryFeatureCol = NA, renameFeatures = FALSE, namesToReplace = NA, nr = 1, showTarget = NA, plotTitle = \"\", ... )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_featureRep.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot how well targets are met — splnr_plot_featureRep","text":"df df containing target information (resulting splnr_get_featureRep() function) category named data frame feature category grouping plot output categoryFeatureCol character column containing feature infromation plotted category data frame contain column named 'feature' can matched 'df' infromation. renameFeatures logical whether variable names used replaced common names namesToReplace data frame containing variable name ('nameVariable') common name ('nameCommon'). nr Number rows legend showTarget logical targets shown bar plot plotTitle character value title plot. Can empty (\"\"). ... arguments passed ggplot2::theme()","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_featureRep.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot how well targets are met — splnr_plot_featureRep","text":"ggplot object plot","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_featureRep.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot how well targets are met — splnr_plot_featureRep","text":"","code":"pDat <- 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) soln <- pDat %>% prioritizr::solve.ConservationProblem() # including incidental species coverage df <- splnr_get_featureRep( soln = soln, pDat = pDat ) (splnr_plot_featureRep(df, category = dat_category))"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_importanceScore.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot importance score — splnr_plot_importanceScore","title":"Plot importance score — splnr_plot_importanceScore","text":"Importance scores mean reflect irreplaceability planning unit solution prioirtizr conservation problem. Based prioritizr package, splnr_plot_importanceScore() allows visualize three different types importance scores ggplot2 used based conservation problem hand. prioritizr development team generally recommend using replacement cost score, however might feasible conservation problems many planning units features.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_importanceScore.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot importance score — splnr_plot_importanceScore","text":"","code":"splnr_plot_importanceScore( soln, pDat, method = \"Ferrier\", plotTitle = \"\", colorMap = \"A\", decimals = 4, legendTitle = \"Importance Score\" )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_importanceScore.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot importance score — splnr_plot_importanceScore","text":"soln prioritizr solution pDat prioritizr problem method method calcualting importance scores. Can either \"Ferrier\" Ferrier Score, can used minimum set objective function, \"RWR\" Rarity Weighted Richness Score, \"RC\" Replacement Cost takes longer approaches due iterative process. plotTitle character value title plot. Can empty (\"\"). colorMap character string indicating color map use (see https://ggplot2.tidyverse.org/reference/scale_viridis.html options) decimals number decimals shown plot. Ferrier Score often requires higher number decimals (>4) two approaches (2) analysis work. legendTitle character value title legend. Can empty (\"\").","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_importanceScore.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot importance score — splnr_plot_importanceScore","text":"ggplot object plot","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_importanceScore.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Plot importance score — splnr_plot_importanceScore","text":"function outputs ggobject can combined spatialplanr function splnr_gg_add().","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_importanceScore.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot importance score — splnr_plot_importanceScore","text":"","code":"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_importanceScore(soln = dat_soln, pDat = dat_problem, method = \"Ferrier\", decimals = 4)) #> Ferrier Score."},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_selectionFreq.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot selection frequency of a planning unit in an array of prioritisations — splnr_plot_selectionFreq","title":"Plot selection frequency of a planning unit in an array of prioritisations — splnr_plot_selectionFreq","text":"multiple spatial plans generated, often interested many times planning unit selected across array solutions. array can either made solutions different conservation problems generated portfolio approach prioritizr. Either way, function requires sf object input contains column (selFreq) selection frequency planning unit can generated spatialplanrfunction splnr_get_selFreq(). splnr_plot_selectionFreq() allows visualize selection frequency using ggplot2. outputs ggobject can combined spatialplanr function splnr_gg_add().","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_selectionFreq.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot selection frequency of a planning unit in an array of prioritisations — splnr_plot_selectionFreq","text":"","code":"splnr_plot_selectionFreq( selFreq, plotTitle = \"\", paletteName = \"Greens\", legendTitle = \"Selection \\nFrequency\" )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_selectionFreq.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot selection frequency of a planning unit in an array of prioritisations — splnr_plot_selectionFreq","text":"selFreq sf object containing selection frequency planning unit array solutions plotTitle character value title plot. Can empty (\"\"). paletteName string (number) color palette use. Available palettes can found https://ggplot2.tidyverse.org/reference/scale_brewer.html. legendTitle character value title legend. Can empty (\"\").","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_selectionFreq.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot selection frequency of a planning unit in an array of prioritisations — splnr_plot_selectionFreq","text":"ggplot object plot","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_selectionFreq.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot selection frequency of a planning unit in an array of prioritisations — splnr_plot_selectionFreq","text":"","code":"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) # create conservation problem that contains a portfolio of solutions dat_soln_portfolio <- dat_problem %>% prioritizr::add_cuts_portfolio(number_solutions = 5) %>% prioritizr::solve.ConservationProblem() selFreq <- splnr_get_selFreq(solnMany = dat_soln_portfolio, type = \"portfolio\") (splnr_plot_selectionFreq(selFreq))"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_solution.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot prioritizr solution — splnr_plot_solution","title":"Plot prioritizr solution — splnr_plot_solution","text":"splnr_plot_solution() allows plot solution prioritizr conservation problem without customisable way using ggplot2. function requires solution sf object column called solution_1 outputs ggobject. can combined spatialplanr function splnr_gg_add().","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_solution.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot prioritizr solution — splnr_plot_solution","text":"","code":"splnr_plot_solution( soln, colorVals = c(\"#c6dbef\", \"#3182bd\"), showLegend = TRUE, legendLabels = c(\"Not selected\", \"Selected\"), plotTitle = \"Solution\", legendTitle = \"Planning Units\", zones = FALSE )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_solution.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot prioritizr solution — splnr_plot_solution","text":"soln prioritizr solution colorVals list object named vectors match color value according name. \"TRUE\" stands selected planning units. showLegend logical command whether show legend solution (Default: TRUE). legendLabels Character values (number zones + 1) legend labelled. plotTitle character value title plot. Can empty (\"\"). legendTitle character value title legend. Can empty (\"\"). zones logical value, indicating whether spatial plan contains zones (default = FALSE).","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_solution.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot prioritizr solution — splnr_plot_solution","text":"ggplot object plot","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_solution.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot prioritizr solution — splnr_plot_solution","text":"","code":"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) # example 2 t2 <- matrix(NA, ncol = 2, nrow = 5) # create targets t2[, 1] <- 0.1 t2[, 2] <- 0.05 z2 <- prioritizr::zones( \"zone 1\" = c(\"Spp1\", \"Spp2\", \"Spp3\", \"Spp4\", \"Spp5\"), \"zone 2\" = c(\"Spp1\", \"Spp2\", \"Spp3\", \"Spp4\", \"Spp5\") ) # when giving sf input, we need as many cost columns as we have zones p2 <- prioritizr::problem( dat_species_bin %>% dplyr::mutate( Cost1 = runif(n = dim(.)[[1]]), Cost2 = runif(n = dim(.)[[1]]) ), z2, cost_column = c(\"Cost1\", \"Cost2\") ) %>% prioritizr::add_min_set_objective() %>% prioritizr::add_relative_targets(t2) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(verbose = FALSE) s2 <- p2 %>% prioritizr::solve.ConservationProblem() (splnr_plot_solution(s2, zones = TRUE, colorVals = c(\"#c6dbef\", \"#3182bd\", \"black\"), legendLabels = c(\"Not selected\", \"Zone 1\", \"Zone 2\") ))"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_replace_NAs.html","id":null,"dir":"Reference","previous_headings":"","what":"Remove NAs from spatial data using nearest neighbour — splnr_replace_NAs","title":"Remove NAs from spatial data using nearest neighbour — splnr_replace_NAs","text":"splnr_replace_NAs() allows replace NA values data value nearest neighbor. nearest neighbor determined using st_nearest_feature() sf package.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_replace_NAs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Remove NAs from spatial data using nearest neighbour — splnr_replace_NAs","text":"","code":"splnr_replace_NAs(df, vari)"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_replace_NAs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Remove NAs from spatial data using nearest neighbour — splnr_replace_NAs","text":"df sf dataframe vari Variable remove NAs ","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_replace_NAs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Remove NAs from spatial data using nearest neighbour — splnr_replace_NAs","text":"sf object NAs replaced nearest neighbour","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_replace_NAs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Remove NAs from spatial data using nearest neighbour — splnr_replace_NAs","text":"","code":"df <- dat_species_prob %>% splnr_replace_NAs(\"Spp2\")"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_scale_01.html","id":null,"dir":"Reference","previous_headings":"","what":"Scale spatial layers to between 0 and 1 — splnr_scale_01","title":"Scale spatial layers to between 0 and 1 — splnr_scale_01","text":"splnr_scale_01() allows re-scale data values greater 1 values 0 1.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_scale_01.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Scale spatial layers to between 0 and 1 — splnr_scale_01","text":"","code":"splnr_scale_01(dat, col_name)"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_scale_01.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Scale spatial layers to between 0 and 1 — splnr_scale_01","text":"dat sf dataframe col_name Name column scale","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_scale_01.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Scale spatial layers to between 0 and 1 — splnr_scale_01","text":"sf dataframe","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_scale_01.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Scale spatial layers to between 0 and 1 — splnr_scale_01","text":"","code":"df <- dat_species_prob %>% dplyr::mutate(Spp1 = Spp1 * 100) %>% splnr_scale_01(col_name = \"Spp1\")"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_targets_byCategory.html","id":null,"dir":"Reference","previous_headings":"","what":"Assign targets to all features by category — splnr_targets_byCategory","title":"Assign targets to all features by category — splnr_targets_byCategory","text":"splnr_targets_byCategory() allows assign targets conservation planning based species categories.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_targets_byCategory.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Assign targets to all features by category — splnr_targets_byCategory","text":"","code":"splnr_targets_byCategory(dat, catTarg, catName = \"Category\")"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_targets_byCategory.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Assign targets to all features by category — splnr_targets_byCategory","text":"dat sf object features categories catTarg named character vector categories target catName optional argument name category column dat","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_targets_byCategory.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Assign targets to all features by category — splnr_targets_byCategory","text":"sf object targets added","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_targets_byCategory.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Assign targets to all features by category — splnr_targets_byCategory","text":"","code":"dat <- splnr_targets_byCategory( dat = dat_category, catTarg = c(\"Group1\" = 0.5, \"Group2\" = 0.2), catName = \"category\" )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_targets_byIUCN.html","id":null,"dir":"Reference","previous_headings":"","what":"Assign targets bu IUCN Red List categories — splnr_targets_byIUCN","title":"Assign targets bu IUCN Red List categories — splnr_targets_byIUCN","text":"splnr_targets_byIUCN() allows assign targets species used conservation planning based IUCN categories. Species can extracted based IUCN categories spatoalplnrfunction splnr_get_IUCNRedList(). Accessing IUCN database requires login token rl_use_iucn() needs added environment using Sys.setenv(IUCN_REDLIST_KEY = \"[Token]\"). can start running rredlist::rl_use_iucn().","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_targets_byIUCN.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Assign targets bu IUCN Red List categories — splnr_targets_byIUCN","text":"","code":"splnr_targets_byIUCN(dat, IUCN_target, IUCN_col = \"IUCN_Category\")"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_targets_byIUCN.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Assign targets bu IUCN Red List categories — splnr_targets_byIUCN","text":"dat dataframe sf object IUCN categories IUCN_target Either numeric named numeric targets apply IUCN categories IUCN_col Optional string indicate name column IUCN categories","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_targets_byIUCN.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Assign targets bu IUCN Red List categories — splnr_targets_byIUCN","text":"dataframe sf object","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_targets_byIUCN.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Assign targets bu IUCN Red List categories — splnr_targets_byIUCN","text":"","code":"dat <- data.frame(IUCN_Category = c(\"EW\", \"EX\", NA), target = c(0.3, 0.3, 0.3)) IUCN_target <- c(\"EX\" = 0.8, \"EW\" = 0.6) dat <- splnr_targets_byIUCN(dat, IUCN_target)"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_targets_byInverseArea.html","id":null,"dir":"Reference","previous_headings":"","what":"Assign targets by Inverse Area — splnr_targets_byInverseArea","title":"Assign targets by Inverse Area — splnr_targets_byInverseArea","text":"function takes min (target_min) max (target_max) target range calculates inverse area target feature based areal coverage.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_targets_byInverseArea.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Assign targets by Inverse Area — splnr_targets_byInverseArea","text":"","code":"splnr_targets_byInverseArea(df, target_min, target_max)"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_targets_byInverseArea.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Assign targets by Inverse Area — splnr_targets_byInverseArea","text":"df sf dataframe features calculate target_min minimum target inverse area target_max maximum target inverse area","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_targets_byInverseArea.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Assign targets by Inverse Area — splnr_targets_byInverseArea","text":"sf dataframe Inverse Area Targets added Target","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_targets_byInverseArea.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Assign targets by Inverse Area — splnr_targets_byInverseArea","text":"","code":"targets <- dat_species_prob %>% splnr_targets_byInverseArea(target_min = 0.3, target_max = 0.8)"}] +[{"path":"https://mathmarecol.github.io/spatialplanr/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2023 Jason D. Everett Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/articles/ClimateSmart.html","id":"overview","dir":"Articles","previous_headings":"","what":"Overview","title":"Climate-Smart Spatial Planning","text":"code written simplify process running prioritizr analysis given region. still work progress feel free submit pull requests new features code improvements.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/articles/ClimateSmart.html","id":"set-user-parameters","dir":"Articles","previous_headings":"Overview","what":"Set user parameters","title":"Climate-Smart Spatial Planning","text":"Set diameter planning units. units CRS (usually metres degrees). can also use customised ggplot theme can passed list splnr_gg_add() can used plots. example:","code":"Region <- \"Coral Sea\" # \"Australia\" Type <- \"Oceans\" # \"EEZ\" cCRS <- \"ESRI:54009\" # Mollweide PU_size <- 107460 # m splnr_theme <- list( ggplot2::theme_bw(), ggplot2::theme( legend.position = \"right\", legend.direction = \"vertical\", text = ggplot2::element_text(size = 9, colour = \"black\"), axis.text = ggplot2::element_text(size = 9, colour = \"black\"), plot.title = ggplot2::element_text(size = 9), axis.title = ggplot2::element_blank() ) )"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/ClimateSmart.html","id":"analysis-region","dir":"Articles","previous_headings":"Overview","what":"Analysis Region","title":"Climate-Smart Spatial Planning","text":"Start analysis defining region setting planning units. Get boundary chosen region.","code":"Bndry <- splnr_get_boundary(Limits = Region, Type = Type, cCRS = cCRS) #> Reading layer `ne_10m_geography_marine_polys' from data source #> `/private/var/folders/_r/mcmw_qtn0m7cd23cbdqfszl40000gp/T/RtmpMuMJpx/ne_10m_geography_marine_polys.shp' #> using driver `ESRI Shapefile' #> Simple feature collection with 306 features and 37 fields #> Geometry type: MULTIPOLYGON #> Dimension: XY #> Bounding box: xmin: -180 ymin: -85.19206 xmax: 179.9999 ymax: 90 #> Geodetic CRS: WGS 84 landmass <- rnaturalearth::ne_countries(scale = \"medium\", returnclass = \"sf\") %>% sf::st_transform(cCRS)"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/ClimateSmart.html","id":"create-planning-units","dir":"Articles","previous_headings":"Overview","what":"Create Planning Units","title":"Climate-Smart Spatial Planning","text":"","code":"PUs <- spatialgridr::get_grid(boundary = Bndry, crs = cCRS, output = \"sf_hex\", resolution = PU_size)"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/ClimateSmart.html","id":"get-the-features","dir":"Articles","previous_headings":"Overview","what":"Get the features","title":"Climate-Smart Spatial Planning","text":"example, use small subset charismatic megafauna species Coral Sea inform conservation plan. filtered Aquamaps (Aquamaps.org) species distribution models study area following species: species chosen based importance region represent example visualization purposes. Note: structure tribbleabove required downstream plotting. Common denotes common name species, Scientific scientific name format used Aquamaps, Category category species belongs Class represents importance species conservation plan.","code":"Dict <- tibble::tribble( ~nameCommon, ~nameVariable, ~category, \"Green sea turtle\", \"Chelonia_mydas\", \"Reptiles\", \"Loggerhead sea turtle\", \"Caretta_caretta\", \"Reptiles\", \"Hawksbill sea turtle\", \"Eretmochelys_imbricata\", \"Reptiles\", \"Olive ridley sea turtle\", \"Lepidochelys_olivacea\", \"Reptiles\", \"Saltwater crocodile\", \"Crocodylus_porosus\", \"Reptiles\", \"Humpback whale\", \"Megaptera_novaeangliae\", \"Mammals\", \"Common Minke whale\", \"Balaenoptera_acutorostrata\", \"Mammals\", \"Dugong\", \"Dugong_dugon\", \"Mammals\", \"Grey nurse shark\", \"Carcharias_taurus\", \"Sharks and rays\", \"Tiger shark\", \"Galeocerdo_cuvier\", \"Sharks and rays\", \"Great hammerhead shark\", \"Sphyrna_mokarran\", \"Sharks and rays\", \"Giant oceanic manta ray\", \"Mobula_birostris\", \"Sharks and rays\", \"Reef manta ray\", \"Mobula_alfredi\", \"Sharks and rays\", \"Whitetip reef shark\", \"Triaenodon_obesus\", \"Sharks and rays\", \"Red-footed booby\", \"Sula_sula\", \"Birds\" )"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/ClimateSmart.html","id":"convert-the-probabilities-to-binary-data","dir":"Articles","previous_headings":"Overview > Get the features","what":"Convert the probabilities to binary data","title":"Climate-Smart Spatial Planning","text":"","code":"datEx_species_bin <- spDataFiltered %>% dplyr::as_tibble() %>% dplyr::mutate(dplyr::across( -dplyr::any_of(c(\"geometry\")), # Don't apply to geometry ~ dplyr::case_when( . >= 0.5 ~ 1, . < 0.5 ~ 0, is.na(.data) ~ 0 ) )) %>% sf::st_as_sf() col_name <- spDataFiltered %>% sf::st_drop_geometry() %>% colnames()"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/ClimateSmart.html","id":"climate-smart-spatial-planning","dir":"Articles","previous_headings":"Overview > Get the features","what":"Climate-smart spatial planning","title":"Climate-Smart Spatial Planning","text":"far, steps exactly spatial plan include climate change. make spatial plan climate smart, need climate metrics. use climate velocity data obtained x, y z models using SSP5-8.5. downstream analysis, rename column interest (: velocity data) metric. climate velocity data can visualized using splnr_plot_climData() function. case, areas low climate velocity, areas define climate refugia example. Usually, combine several metrics (e.g. exposure, velocity etc.) multiple SSP scenarios get robust climate refugia. example, randomly set areas high velocity value 0.85-1 visualize output (CHANGE LATER BETTER DATA). use climate priority area approach splnr_climate_priorityAreaApproach() detailed Buenafe et al (2023) determine climate refugia. Briefly, approach selects percentile (case 5%) suitable habitat feature considered climate-smart. also requires direction input indicating side metric range climate-smart areas can found. case, lower climate velocity denotes climate-smart (direction = -1), cases higher value might represent climate-smart planning units (direction = 1). Using approach also requires adaptation targets, since 5% suitable habitat species already protected climate-smart areas. can decide much 5% climate-smart areas supposed included spatial plan (: refugiaTarget = 1 protect 100% 5% climate-smart areas). now add information required perform spatial planning, cost, extract names used features.","code":"metric_df <- CoralSeaVelocity %>% dplyr::rename(metric = voccMag_transformed) (ggclim <- splnr_plot_climData(metric_df, \"metric\") + splnr_gg_add( Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme )) set.seed(5) metric_df <- CoralSeaVelocity %>% dplyr::rename(metric = voccMag_transformed) %>% dplyr::mutate( metricOG = metric, metric = ifelse(metric > 0.99, runif(., 0.85, 1.0), metric) ) (ggclim <- splnr_plot_climData(metric_df, \"metric\") + splnr_gg_add( Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme )) target <- datEx_species_bin %>% sf::st_drop_geometry() %>% colnames() %>% data.frame() %>% setNames(c(\"feature\")) %>% dplyr::mutate(target = 0.3) CPA_Approach <- splnr_climate_priorityAreaApproach( featuresDF = datEx_species_bin, metricDF = metric_df, targetsDF = target, direction = -1, refugiaTarget = 1 ) out_sf <- CPA_Approach$Features %>% sf::st_join( datEx_species_bin %>% dplyr::select( tidyselect::starts_with(\"Cost_\") ), join = sf::st_equals) %>% sf::st_join(metric_df, join = sf::st_equals) targets <- CPA_Approach$Targets out_sf$Cost_None <- rep(1, 397) usedFeatures <- out_sf %>% sf::st_drop_geometry() %>% dplyr::select( -tidyselect::starts_with(\"Cost_\"), -tidyselect::starts_with(\"metric\") ) %>% names()"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/ClimateSmart.html","id":"run-the-climate-smart-spatial-planning","dir":"Articles","previous_headings":"Overview > Get the features","what":"Run the climate-smart spatial planning","title":"Climate-Smart Spatial Planning","text":"prioritizrsteps including climate change running non-climate-smart spatial prioritization. can look resulting plan using splnr_plot_solution(). However, also interested climate-smart selected planning units solution actually . , can use kernel density plot.","code":"p1 <- prioritizr::problem(out_sf, usedFeatures, \"Cost_None\") %>% prioritizr::add_min_set_objective() %>% prioritizr::add_relative_targets(targets$target) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(verbose = FALSE) dat_solnClim <- prioritizr::solve.ConservationProblem(p1) (ggSoln <- splnr_plot_solution(dat_solnClim) + splnr_gg_add( Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme )) (ggClimDens <- splnr_plot_climKernelDensity( soln = list(dat_solnClim), names = c(\"Input 1\"), type = \"Normal\", legendTitle = \"Climate velocity (add unit)\", xAxisLab = \"Climate velocity\" ))"},{"path":[]},{"path":"https://mathmarecol.github.io/spatialplanr/articles/ClimateSmart.html","id":"percentile-approach","dir":"Articles","previous_headings":"Overview > Alternative Approaches","what":"Percentile Approach","title":"Climate-Smart Spatial Planning","text":"now add information required perform spatial planning, cost, extract names used features run prioritisation. can look resulting plan using splnr_plot_solution(). However, also interested climate-smart selected planning units solution actually . , can use kernel density plot","code":"target <- datEx_species_bin %>% sf::st_drop_geometry() %>% colnames() %>% data.frame() %>% setNames(c(\"feature\")) %>% dplyr::mutate(target = 30) Percentile_Approach <- splnr_climate_percentileApproach( featuresDF = datEx_species_bin, metricDF = metric_df, targetsDF = target, direction = -1, percentile = 35 ) #> [1] \"Lower values mean more climate-smart areas.\" out_sf <- Percentile_Approach$Features %>% sf::st_join( datEx_species_bin %>% dplyr::select( tidyselect::starts_with(\"Cost_\") ), join = sf::st_equals ) %>% sf::st_join(metric_df, join = sf::st_equals) targets <- Percentile_Approach$Targets out_sf$Cost_None <- rep(1, 397) usedFeatures <- out_sf %>% sf::st_drop_geometry() %>% dplyr::select( -tidyselect::starts_with(\"Cost_\"), -tidyselect::starts_with(\"metric\") ) %>% names() p2 <- prioritizr::problem(out_sf, usedFeatures, \"Cost_None\") %>% prioritizr::add_min_set_objective() %>% prioritizr::add_relative_targets(targets$target) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(verbose = FALSE) dat_solnClimPercentile <- prioritizr::solve.ConservationProblem(p2, force = TRUE ) (ggSoln <- splnr_plot_solution(dat_solnClimPercentile) + splnr_gg_add( Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme )) (ggClimDens <- splnr_plot_climKernelDensity( soln = list(dat_solnClimPercentile), names = c(\"Input 1\"), type = \"Normal\", legendTitle = \"Climate velocity (add unit)\", xAxisLab = \"Climate velocity\" ))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/ClimateSmart.html","id":"feature-approach","dir":"Articles","previous_headings":"Overview > Alternative Approaches","what":"Feature Approach","title":"Climate-Smart Spatial Planning","text":"now add information required perform spatial planning, cost, extract names used features run prioritisation. However, also interested climate-smart selected planning units solution actually . , can use kernel density plot","code":"target <- datEx_species_bin %>% sf::st_drop_geometry() %>% colnames() %>% data.frame() %>% setNames(c(\"feature\")) %>% dplyr::mutate(target = 0.3) Feature_Approach <- splnr_climate_featureApproach( featuresDF = datEx_species_bin, metricDF = metric_df, targetsDF = target, direction = 1 ) #> [1] \"Higher values mean more climate-smart areas.\" out_sf <- Feature_Approach$Features %>% sf::st_join( datEx_species_bin %>% dplyr::select( tidyselect::starts_with(\"Cost_\") ), join = sf::st_equals) %>% sf::st_join(metric_df, join = sf::st_equals) targets <- Feature_Approach$Targets out_sf$Cost_None <- rep(1, 397) usedFeatures <- out_sf %>% sf::st_drop_geometry() %>% dplyr::select( -tidyselect::starts_with(\"Cost_\"), -tidyselect::starts_with(\"metric\") ) %>% names() p3 <- prioritizr::problem(out_sf, usedFeatures, \"Cost_None\") %>% prioritizr::add_min_set_objective() %>% prioritizr::add_relative_targets(targets$target) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(verbose = FALSE) dat_solnClimFeature <- prioritizr::solve.ConservationProblem(p3) (ggSoln <- splnr_plot_solution(dat_solnClimFeature) + splnr_gg_add( Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme )) (ggClimDens <- splnr_plot_climKernelDensity( soln = list(dat_solnClimFeature), names = c(\"Input 1\"), type = \"Normal\", legendTitle = \"Climate velocity (add unit)\", xAxisLab = \"Climate velocity\" ))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/GlobalFishingWatch.html","id":"global-fishing-watch-r-package-gfwr","dir":"Articles","previous_headings":"","what":"Global Fishing Watch R Package (gfwr)","title":"Global Fishing Watch","text":"gfwr package provides convenient functions pull GFW data directly R usable formats. contains three main functions, including : get_vessel_info(), get_event() get_raster(). two first devoted retrieving information features one ore several specific vessels. last particular interest us allows us gather information global fishing watch raster fishing effort (details function appropriate section). mainly use splnr_get_gfw function created enable data retrieved processed variety ways, described . time spent fishing computed using Automatic Identification System (AIS) data, transmitted industrial fishing vessels. AIS data provides information location, speed, direction vessel, can used identify vessel actively fishing.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/articles/GlobalFishingWatch.html","id":"ais-caveats-and-limitations","dir":"Articles","previous_headings":"Global Fishing Watch R Package (gfwr)","what":"AIS Caveats and limitations","title":"Global Fishing Watch","text":"AIS coverage vessels several limitations : 1. number vessels captured (AIS provides approximately 70’000 2.8 million identified fishing vessels). 2. size vessels (52-85% vessels larger 24 meters 1% vessels 12 meters).Good know: IMO mandates AIS vessels larger 36 meters. 3. AIS interference areas high vessel density. 4. terrestrial satellites receive messages near shore.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/articles/GlobalFishingWatch.html","id":"installation","dir":"Articles","previous_headings":"Global Fishing Watch R Package (gfwr)","what":"Installation","title":"Global Fishing Watch","text":"","code":"remotes::install_github(\"GlobalFishingWatch/gfwr\") library(gfwr) library(spatialplanr)"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/GlobalFishingWatch.html","id":"api","dir":"Articles","previous_headings":"Global Fishing Watch R Package (gfwr)","what":"API","title":"Global Fishing Watch","text":"access GFW APIs, need : 1. register GFW account . 2. Request API key . token, add .Renviron file (executing chunk ), writing (GFW_TOKEN = “YOUR_TOKEN”) file. (asked restart R changes take effect.) save key object used gfwr functions.","code":"usethis::edit_r_environ() key <- gfwr::gfw_auth()"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/GlobalFishingWatch.html","id":"fishing-effort-visualization","dir":"Articles","previous_headings":"Global Fishing Watch R Package (gfwr)","what":"Fishing effort visualization","title":"Global Fishing Watch","text":"region_id necessary use get_raster function. get_raster function gets raster fishing effort API converts response data frame contains occurrences vessel grid cell (data binned grid cells different resolution), Vessel IDs, Flag, Geartype Apparent fishing Hours basically amount fishing hours vessel per grid cell (geometry). Data can provided : - DAILY, MONTHLY YEARLY temporal resolutions. - LOW (0.1 deg) HIGH (0.01 deg) spatial resolutions. - VESSEL_ID, FLAG, GEARTYPE, FLAGANDGEARTYPE. (can remove option message = FALSE see columns types.)","code":"region_id <- gfwr::get_region_id(region_name = \"Australia\", region_source = \"EEZ\", key = gfwr::gfw_auth())$id gfwr::get_raster( spatial_resolution = \"LOW\", temporal_resolution = \"MONTHLY\", group_by = \"FLAGANDGEARTYPE\", start_date = \"2022-01-01\", end_date = \"2023-01-01\", region = region_id, region_source = \"EEZ\", key = gfwr::gfw_auth() )"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/GlobalFishingWatch.html","id":"get_raster-caveats-and-limitations-","dir":"Articles","previous_headings":"Global Fishing Watch R Package (gfwr) > Fishing effort visualization","what":"get_raster caveats and limitations.","title":"Global Fishing Watch","text":"Date range limited 1-year. Nevertheless, modifications, can get round problems splnr_get_gfw.","code":"data_sf_combined <- splnr_get_gfw(region = \"Australia\", start_date = \"2019-01-01\", end_date = \"2023-12-31\", temp_res = \"YEARLY\", spat_res = \"LOW\", compress = FALSE)"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/GlobalFishingWatch.html","id":"visualization","dir":"Articles","previous_headings":"Global Fishing Watch R Package (gfwr)","what":"Visualization","title":"Global Fishing Watch","text":"display data, load : - coastline rnaturalearth package modify get sf object, constrain boundaries given data. - EEZ Polygons oceandatr package","code":"# Check and modify if necessary the spatial reference of data_sf_combined data_sf_combined <- sf::st_set_crs(data_sf_combined, sf::st_crs(rnaturalearth::ne_coastline(scale = \"large\"))) coast_clipped <- rnaturalearth::ne_coastline(scale = \"large\") %>% sf::st_as_sf() %>% sf::st_intersection(sf::st_as_sfc(sf::st_bbox(data_sf_combined))) # Load EEZ polygons eezs <- spatialgridr::get_boundary(name = \"Australia\", type = \"eez\", country_type = \"country\") %>% sf::st_transform(crs = sf::st_crs(data_sf_combined)) %>% sf::st_make_valid() %>% sf::st_intersection(sf::st_as_sfc(sf::st_bbox(data_sf_combined)))"},{"path":[]},{"path":[]},{"path":[]},{"path":"https://mathmarecol.github.io/spatialplanr/articles/GlobalFishingWatch.html","id":"year-on-year-comparison","dir":"Articles","previous_headings":"Global Fishing Watch R Package (gfwr) > Here we display the Fishing Effort in Australia from 2019 to 2023.","what":"Year-on-year comparison","title":"Global Fishing Watch","text":"may need compare different timeframes, seasons, see patterns. Note : vessels adopted AIS (mainly economically developed countries) since deployment technologies, rise activities must seen context increase necessarily intense fishing activity.","code":"# We need to change the temporal range according to our need group by it to display the total fishing hours.
data_sf_combined <- splnr_get_gfw(region = \"Australia\", start_date = \"2019-01-01\", end_date = \"2023-12-31\", temp_res = \"MONTHLY\", key = gfwr::gfw_auth()) %>% dplyr::group_by(Year, Month) %>% dplyr::summarize(Total_Fishing_Hours = sum(ApparentFishingHrs))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/GlobalFishingWatch.html","id":"fishing-gear-type","dir":"Articles","previous_headings":"Global Fishing Watch R Package (gfwr) > Here we display the Fishing Effort in Australia from 2019 to 2023.","what":"Fishing gear type","title":"Global Fishing Watch","text":"display Vessel activity ‘Micronesia’ 2020 according fishing gear type.","code":"data_sf_combined <- splnr_get_gfw(region = \"Micronesia\", start_date = \"2019-12-31\", end_date = \"2021-01-01\", temp_res = \"MONTHLY\")"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/GlobalFishingWatch.html","id":"flags","dir":"Articles","previous_headings":"Global Fishing Watch R Package (gfwr) > Here we display the Fishing Effort in Australia from 2019 to 2023.","what":"Flags","title":"Global Fishing Watch","text":"display Vessel activity Papua New Guinea according Vessels flags.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/articles/GlobalFishingWatch.html","id":"supplementary-materials-","dir":"Articles","previous_headings":"Global Fishing Watch R Package (gfwr) > Here we display the Fishing Effort in Australia from 2019 to 2023.","what":"Supplementary materials.","title":"Global Fishing Watch","text":"fishing detection model trained AIS data 503 vessels identified fishing activity 90% accuracy, means can identify fishing non-fishing activity high accuracy. details AIS operation limitations .","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/articles/GlobalFishingWatch.html","id":"hierarchy-of-vessels-gear-types","dir":"Articles","previous_headings":"Global Fishing Watch R Package (gfwr) > Here we display the Fishing Effort in Australia from 2019 to 2023.","what":"Hierarchy of vessels gear types :","title":"Global Fishing Watch","text":"Source : https://globalfishingwatch.org/datasets--code-vessel-identity/","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"overview","dir":"Articles","previous_headings":"","what":"Overview","title":"Spatial Planning With Zones","text":"code written simplify process running prioritizr analysis given region. still work progress feel free submit pull requests new features code improvements. workflow shown based prioritizr introduction zones.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"set-user-parameters","dir":"Articles","previous_headings":"Overview","what":"Set user parameters","title":"Spatial Planning With Zones","text":"Set diameter planning units. units CRS (usually metres degrees). Choose CRS analysis. use Mollweide","code":"Region <- \"Coral Sea\" # \"Australia\" Type <- \"Oceans\" # \"EEZ\" PU_size <- 107460 # m cCRS <- \"ESRI:54009\""},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"analysis-region","dir":"Articles","previous_headings":"Overview","what":"Analysis Region","title":"Spatial Planning With Zones","text":"Start analysis defining region setting planning units. Get boundary chosen region.","code":"Bndry <- splnr_get_boundary(Limits = Region, Type = Type, cCRS = cCRS) #> Reading layer `ne_10m_geography_marine_polys' from data source #> `/private/var/folders/_r/mcmw_qtn0m7cd23cbdqfszl40000gp/T/Rtmp0tUE3F/ne_10m_geography_marine_polys.shp' #> using driver `ESRI Shapefile' #> Simple feature collection with 306 features and 37 fields #> Geometry type: MULTIPOLYGON #> Dimension: XY #> Bounding box: xmin: -180 ymin: -85.19206 xmax: 179.9999 ymax: 90 #> Geodetic CRS: WGS 84 landmass <- rnaturalearth::ne_countries( scale = \"medium\", returnclass = \"sf\" ) %>% sf::st_transform(cCRS)"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"create-planning-units","dir":"Articles","previous_headings":"Overview","what":"Create Planning Units","title":"Spatial Planning With Zones","text":"can also use customised ggplot theme can passed list splnr_gg_add() can used plots. example:","code":"PUs <- spatialgridr::get_grid(boundary = Bndry, crs = cCRS, output = \"sf_hex\", resolution = PU_size) splnr_theme <- list( ggplot2::theme_bw(), ggplot2::theme( legend.position = \"right\", legend.direction = \"vertical\", text = ggplot2::element_text(size = 9, colour = \"black\"), axis.text = ggplot2::element_text(size = 9, colour = \"black\"), plot.title = ggplot2::element_text(size = 9), axis.title = ggplot2::element_blank() ) )"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"get-the-features","dir":"Articles","previous_headings":"Overview","what":"Get the features","title":"Spatial Planning With Zones","text":"example, use small subset charismatic megafauna species Coral Sea inform conservation plan. filtered Aquamaps (Aquamaps.org) species distribution models study area following species: species chosen based importance region represent example visualization purposes. Note: structure tribbleabove required downstream plotting. Common denotes common name species, Scientific scientific name format used Aquamaps, Category category species belongs Class represents importance species conservation plan.","code":"Dict <- tibble::tribble( ~nameCommon, ~nameVariable, ~category, \"Green sea turtle\", \"Chelonia_mydas\", \"Reptiles\", \"Loggerhead sea turtle\", \"Caretta_caretta\", \"Reptiles\", \"Hawksbill sea turtle\", \"Eretmochelys_imbricata\", \"Reptiles\", \"Olive ridley sea turtle\", \"Lepidochelys_olivacea\", \"Reptiles\", \"Saltwater crocodile\", \"Crocodylus_porosus\", \"Reptiles\", \"Humpback whale\", \"Megaptera_novaeangliae\", \"Mammals\", \"Common Minke whale\", \"Balaenoptera_acutorostrata\", \"Mammals\", \"Dugong\", \"Dugong_dugon\", \"Mammals\", \"Grey nurse shark\", \"Carcharias_taurus\", \"Sharks and rays\", \"Tiger shark\", \"Galeocerdo_cuvier\", \"Sharks and rays\", \"Great hammerhead shark\", \"Sphyrna_mokarran\", \"Sharks and rays\", \"Giant oceanic manta ray\", \"Mobula_birostris\", \"Sharks and rays\", \"Reef manta ray\", \"Mobula_alfredi\", \"Sharks and rays\", \"Whitetip reef shark\", \"Triaenodon_obesus\", \"Sharks and rays\", \"Red-footed booby\", \"Sula_sula\", \"Birds\" )"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"convert-the-probabilities-to-binary-data-and-feature-names","dir":"Articles","previous_headings":"Overview > Get the features","what":"Convert the probabilities to binary data and feature names","title":"Spatial Planning With Zones","text":"","code":"datEx_species_bin <- spDataFiltered %>% splnr_apply_cutoffs(Cutoffs = 0.5) col_name <- spDataFiltered %>% sf::st_drop_geometry() %>% colnames()"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"spatial-planning-including-zones","dir":"Articles","previous_headings":"Overview > Get the features","what":"Spatial planning including zones","title":"Spatial Planning With Zones","text":"far, steps exactly spatial plan include zones. direct comparison, first run spatial plan include zoning. , define targets features (: 30% features) create conservation problem include area-based cost prioritisation. solve problem plot solution. can also look well set target met. now look spatial plan needs extended include multiple management zones using zones().","code":"target <- rep(0.3, nrow(Dict)) p1 <- prioritizr::problem( datEx_species_bin %>% dplyr::mutate(Cost1 = rep(1, 397)), col_name, \"Cost1\" ) %>% prioritizr::add_min_set_objective() %>% prioritizr::add_relative_targets(target) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(verbose = FALSE) s1 <- p1 %>% prioritizr::solve.ConservationProblem() (ggSoln <- splnr_plot_solution(s1) + splnr_gg_add(PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme)) s1T <- s1 %>% dplyr::select(tidyselect::starts_with(c(\"solution\"))) %>% sf::st_drop_geometry() %>% tibble::as_tibble() r1 <- prioritizr::eval_feature_representation_summary(p1, s1T) print(r1) #> # A tibble: 15 × 5 #> summary feature total_amount absolute_held relative_held #> #> 1 overall Chelonia_mydas 22 10 0.455 #> 2 overall Caretta_caretta 22 10 0.455 #> 3 overall Eretmochelys_imbricata 24 10 0.417 #> 4 overall Lepidochelys_olivacea 22 10 0.455 #> 5 overall Crocodylus_porosus 21 9 0.429 #> 6 overall Megaptera_novaeangliae 388 120 0.309 #> 7 overall Balaenoptera_acutorostrata 238 74 0.311 #> 8 overall Dugong_dugon 13 5 0.385 #> 9 overall Carcharias_taurus 22 10 0.455 #> 10 overall Galeocerdo_cuvier 36 14 0.389 #> 11 overall Sphyrna_mokarran 397 123 0.310 #> 12 overall Mobula_birostris 20 8 0.4 #> 13 overall Mobula_alfredi 20 8 0.4 #> 14 overall Triaenodon_obesus 25 10 0.4 #> 15 overall Sula_sula 13 5 0.385"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"different-cost-layers","dir":"Articles","previous_headings":"Overview > Get the features","what":"Different cost layers","title":"Spatial Planning With Zones","text":"first assume zones interest set features, separate cost layers. , need set targets zones, case 20% features first zone 5% features second zone. create zones object specify number zones features zone. , define two zones features. zones need specified cost targets. use one area-based cost one cost layer uses random numbers, pre-defined targets pass zonesobject problem formulation solving conservation problem. solution can plotted using function splnr_plot_solution() argument zones set TRUE. can see now planning units selected, planning units either selected zone 1 zone 2.","code":"target2 <- matrix(NA, ncol = 2, nrow = nrow(Dict)) target2[, 1] <- 0.2 target2[, 2] <- 0.05 z2 <- prioritizr::zones(\"zone 1\" = col_name, \"zone 2\" = col_name) p2 <- prioritizr::problem( datEx_species_bin %>% dplyr::mutate( Cost1 = rep(1, 397), # when giving sf input, we need as many cost columns as we have zones Cost2 = runif(n = dim(.)[[1]]) ), z2, cost_column = c(\"Cost1\", \"Cost2\") ) %>% prioritizr::add_min_set_objective() %>% prioritizr::add_relative_targets(target2) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(verbose = FALSE) s2 <- p2 %>% prioritizr::solve.ConservationProblem() (gg_s2 <- splnr_plot_solution( s2, zones = TRUE, colorVals = c(\"#c6dbef\", \"#3182bd\", \"black\"), legendLabels = c(\"Not selected\", \"Zone 1\", \"Zone 2\") ) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"different-features","dir":"Articles","previous_headings":"Overview > Get the features","what":"Different features","title":"Spatial Planning With Zones","text":"using sf objects zones(), input feature names zones() need length contain features. means zones features, interest specific zone, target set 0. example, want separate example data zone reptiles another zone containing taxa reptiles, can specify following targets: sets target reptiles first zone 30% rest 0%. second zone, targets non-reptiles 10% reptiles 0% interest zone. Target data given matrix working zones, transform data frame matrix end. define conservation problem way solve . can also look well targets met zone (combined). can see 15 features listed (number) overall summary, summary zone 1 summary zone 2. looking relative_held column tibble, observe summary zone 1 (row 16 onwards), features >30% targets met, whereas others (feature 6 7) low percentage suitable habitat within selected planning units. can extract common names two features: marine mammals thus target 0% zone 1 reptile-specific zone. percentage selected suitable habitat 0% despite target 0 proportion suitable habitat mammals selected incidentally selecting planning units zone meeting targets reptiles. applies zone 2. can also plot final solution :","code":"targets2b <- Dict %>% dplyr::mutate( targetZ1 = dplyr::if_else(category == \"Reptiles\", 30 / 100, 0), targetZ2 = dplyr::if_else(category != \"Reptiles\", 10 / 100, 0) ) %>% dplyr::select(\"targetZ1\", \"targetZ2\") %>% as.matrix() # NOTE: when using sf input, we need as many cost columns as we have zones p2b <- prioritizr::problem( datEx_species_bin %>% dplyr::mutate( Cost1 = rep(1, 397), Cost2 = runif(n = dim(.)[[1]]) ), z2, cost_column = c(\"Cost1\", \"Cost2\") ) %>% prioritizr::add_min_set_objective() %>% prioritizr::add_relative_targets(targets2b) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(verbose = FALSE) s2b <- p2b %>% prioritizr::solve.ConservationProblem() r2b <- s2b %>% dplyr::select(tidyselect::starts_with(c(\"solution\"))) %>% sf::st_drop_geometry() %>% tibble::as_tibble() %>% prioritizr::eval_feature_representation_summary(p2b, .) print(r2b, n = 45) #> # A tibble: 45 × 5 #> summary feature total_amount absolute_held relative_held #> #> 1 overall 1 44 11 0.25 #> 2 overall 2 44 11 0.25 #> 3 overall 3 48 11 0.229 #> 4 overall 4 44 11 0.25 #> 5 overall 5 42 11 0.262 #> 6 overall 6 776 43 0.0554 #> 7 overall 7 476 26 0.0546 #> 8 overall 8 26 7 0.269 #> 9 overall 9 44 11 0.25 #> 10 overall 10 72 13 0.181 #> 11 overall 11 794 48 0.0605 #> 12 overall 12 40 11 0.275 #> 13 overall 13 40 11 0.275 #> 14 overall 14 50 12 0.24 #> 15 overall 15 26 8 0.308 #> 16 zone 1 1 22 8 0.364 #> 17 zone 1 2 22 8 0.364 #> 18 zone 1 3 24 8 0.333 #> 19 zone 1 4 22 8 0.364 #> 20 zone 1 5 21 8 0.381 #> 21 zone 1 6 388 4 0.0103 #> 22 zone 1 7 238 2 0.00840 #> 23 zone 1 8 13 5 0.385 #> 24 zone 1 9 22 8 0.364 #> 25 zone 1 10 36 8 0.222 #> 26 zone 1 11 397 8 0.0202 #> 27 zone 1 12 20 8 0.4 #> 28 zone 1 13 20 8 0.4 #> 29 zone 1 14 25 8 0.32 #> 30 zone 1 15 13 6 0.462 #> 31 zone 2 1 22 3 0.136 #> 32 zone 2 2 22 3 0.136 #> 33 zone 2 3 24 3 0.125 #> 34 zone 2 4 22 3 0.136 #> 35 zone 2 5 21 3 0.143 #> 36 zone 2 6 388 39 0.101 #> 37 zone 2 7 238 24 0.101 #> 38 zone 2 8 13 2 0.154 #> 39 zone 2 9 22 3 0.136 #> 40 zone 2 10 36 5 0.139 #> 41 zone 2 11 397 40 0.101 #> 42 zone 2 12 20 3 0.15 #> 43 zone 2 13 20 3 0.15 #> 44 zone 2 14 25 4 0.16 #> 45 zone 2 15 13 2 0.154 Dict[[1]][6] #> [1] \"Humpback whale\" Dict[[1]][7] #> [1] \"Common Minke whale\" (gg_s2b <- splnr_plot_solution( s2b, zones = TRUE, colorVals = c(\"#c6dbef\", \"#3182bd\", \"black\"), legendLabels = c(\"Not selected\", \"Zone 1\", \"Zone 2\") ) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"boundary-penalty","dir":"Articles","previous_headings":"Overview > Get the features","what":"Boundary penalty","title":"Spatial Planning With Zones","text":"Similar “normal” priritisations, zones also allows including boundary penalty. several options can done within zones zones.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"within-the-same-zone","dir":"Articles","previous_headings":"Overview > Get the features > Boundary penalty","what":"Within the same zone","title":"Spatial Planning With Zones","text":"zeros matrix denote penalty zones, whereas ones introduce boundary penalty define conservation problem. , introduce penalties within zone 1 zone 2 respectively. add_boundary_penalties() set penalty 0.5 zones defined zm1. purpose example, also set 10 second time limit prioritisation. results show less fragmentation previous solution without penalties: boundary penalty can also introduced one zone:","code":"zm1 <- diag(2) print(zm1) #> [,1] [,2] #> [1,] 1 0 #> [2,] 0 1 p3 <- prioritizr::problem( datEx_species_bin %>% dplyr::mutate( Cost1 = rep(1, 397), # when giving sf input, we need as many cost columns as we have zones Cost2 = runif(n = dim(.)[[1]]) ), z2, cost_column = c(\"Cost1\", \"Cost2\") ) %>% prioritizr::add_min_set_objective() %>% prioritizr::add_boundary_penalties(0.5, zone = zm1) %>% prioritizr::add_relative_targets(target2) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(time_limit = 10, verbose = FALSE) s3 <- p3 %>% prioritizr::solve.ConservationProblem() (gg_s3 <- splnr_plot_solution( s3, zones = TRUE, colorVals = c(\"#c6dbef\", \"#3182bd\", \"black\"), legendLabels = c(\"Not selected\", \"Zone 1\", \"Zone 2\") ) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme )) zm2 <- zm1 zm2[2, 2] <- 0 # NOTE: When using sf input, we need as many cost columns as we have zones p4 <- prioritizr::problem( datEx_species_bin %>% dplyr::mutate( Cost1 = rep(1, 397), Cost2 = runif(n = dim(.)[[1]]) ), z2, cost_column = c(\"Cost1\", \"Cost2\") ) %>% prioritizr::add_min_set_objective() %>% prioritizr::add_boundary_penalties(0.5, zone = zm2) %>% prioritizr::add_relative_targets(target2) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(time_limit = 10, verbose = FALSE) s4 <- p4 %>% prioritizr::solve.ConservationProblem() (gg_s4 <- splnr_plot_solution( s4, zones = TRUE, colorVals = c(\"#c6dbef\", \"#3182bd\", \"black\"), legendLabels = c(\"Not selected\", \"Zone 1\", \"Zone 2\") ) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"across-zones","dir":"Articles","previous_headings":"Overview > Get the features > Boundary penalty","what":"Across zones","title":"Spatial Planning With Zones","text":"Similarly, penalties can applied zones specified problem.","code":"zm3 <- matrix(1, ncol = 2, nrow = 2) print(zm3) #> [,1] [,2] #> [1,] 1 1 #> [2,] 1 1 p5 <- prioritizr::problem( datEx_species_bin %>% dplyr::mutate( Cost1 = rep(1, 397), # when giving sf input, we need as many cost columns as we have zones Cost2 = runif(n = dim(.)[[1]]) ), z2, cost_column = c(\"Cost1\", \"Cost2\") ) %>% prioritizr::add_min_set_objective() %>% prioritizr::add_boundary_penalties(0.5, zone = zm3) %>% prioritizr::add_relative_targets(target2) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(time_limit = 10, verbose = FALSE) s5 <- p5 %>% prioritizr::solve.ConservationProblem() (gg_s5 <- splnr_plot_solution( s5, zones = TRUE, colorVals = c(\"#c6dbef\", \"#3182bd\", \"black\"), legendLabels = c(\"Not selected\", \"Zone 1\", \"Zone 2\") ) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"adding-constraints","dir":"Articles","previous_headings":"Overview > Get the features","what":"Adding constraints","title":"Spatial Planning With Zones","text":"Another addition often used conservation planning constraints. often lock lock areas interest various reasons. example, lock already existing MPAs one zones. using zones constraints, use prioritizr function add_manual_locked_constraints() requires input specific format, first prepare MPA data. need specify zone constraint applied , give information planning unit identifier, rename column interest “status” filter planning units locked . results can visualized :","code":"mpas <- MPAsCoralSea %>% dplyr::mutate(zone = \"zone 1\") %>% dplyr::rename(status = wdpa) %>% tibble::rowid_to_column(\"pu\") %>% sf::st_drop_geometry() %>% tibble::tibble() %>% dplyr::filter(status == 1) # NOTE: When using sf input, we need as many cost columns as we have zones p6 <- prioritizr::problem( datEx_species_bin %>% dplyr::mutate( Cost1 = rep(1, 397), Cost2 = runif(n = dim(.)[[1]]) ), z2, cost_column = c(\"Cost1\", \"Cost2\") ) %>% prioritizr::add_min_set_objective() %>% prioritizr::add_manual_locked_constraints(mpas) %>% prioritizr::add_relative_targets(target2) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(time_limit = 10, verbose = FALSE) s6 <- p6 %>% prioritizr::solve.ConservationProblem() (gg_s6 <- splnr_plot_solution( s6, zones = TRUE, colorVals = c(\"#c6dbef\", \"#3182bd\", \"black\"), legendLabels = c(\"Not selected\", \"Zone 1\", \"Zone 2\") ) + splnr_gg_add( PUs = PUs, Bndry = Bndry, lockIn = MPAsCoralSea, nameLockIn = \"wdpa\", typeLockIn = \"Full\", colorLockIn = \"lightgrey\", alphaLockIn = 0.2, overlay = landmass, labelLockIn = \"Current MPAs\", cropOverlay = PUs, ggtheme = splnr_theme ))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"objective-functions","dir":"Articles","previous_headings":"Overview > Get the features","what":"Objective functions","title":"Spatial Planning With Zones","text":"far used minimum set objective function meet conservation targets whilst minimizing cost. However, objective function available prioritizr. example maximising mangrove ecosystem services, employed minimum shortfall objective function instead (Dabalà et al 2022). objective function, allocate budget exceeded (example area >30%) whilst still trying minimise cost meeting targets - targets might met (shortfall). Zones also works objective functions minimum set objective function. apply add_min_shortfall_objective() provide separate budgets two zones (8 0.3). can visualize output solving conservation problem.","code":"# NOTE: When using sf input, we need as many cost columns as we have zones p7 <- prioritizr::problem( datEx_species_bin %>% dplyr::mutate( Cost1 = rep(1, 397), Cost2 = runif(n = dim(.)[[1]]) ), z2, cost_column = c(\"Cost1\", \"Cost2\") ) %>% prioritizr::add_min_shortfall_objective(c(8, 0.3)) %>% prioritizr::add_relative_targets(target2) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(time_limit = 10, verbose = FALSE) s7 <- p7 %>% prioritizr::solve.ConservationProblem() (gg_s7 <- splnr_plot_solution( s7, zones = TRUE, colorVals = c(\"#c6dbef\", \"#3182bd\", \"black\"), legendLabels = c(\"Not selected\", \"Zone 1\", \"Zone 2\") ) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"alternative-linear-constraints","dir":"Articles","previous_headings":"Overview > Get the features","what":"Alternative: linear constraints","title":"Spatial Planning With Zones","text":"Sometimes spatial plan might needed requires minimising several costs , binary output (inside protected area/outside protected area) sufficient. case, using linear constraints instead zones might simpler time-efficient way forward. Linear constraints make sure planning units selected area meet criteria given constraint. example, using area-based cost (lowest number planning units meet target), might also simultaneously want minimise cost fisheries keep certain threshold. Inversely, might want minimise cost fisheries also select 30% area. example, fill first define targets random cost layer values ranging 0 1. define solve conservation problem: Based problem definition, want meet targets biodiversity features whilst selecting lowest number planning units possible. However, solution also depends threshold linear constraint specified add_linear_constraints()problem. Specifically, planning units selected solution can exceed 10% total cost planning units costRandom$CostR. can visualise solution : NOTE: can also use multiple linear constraints plan, however, might require normalization input data constraints comparable units, careful tuning thresholds, prioritizr still able solve problem.","code":"target8 <- rep(0.3, nrow(Dict)) set.seed <- 10 # Add seed so the problem below solves each time costRandom <- datEx_species_bin %>% dplyr::mutate(CostR = runif(n = dim(.)[[1]])) %>% dplyr::select(\"CostR\") p8 <- prioritizr::problem( datEx_species_bin %>% dplyr::mutate(Cost1 = rep(1, 397)), col_name, \"Cost1\" ) %>% prioritizr::add_min_set_objective() %>% prioritizr::add_relative_targets(target8) %>% prioritizr::add_linear_constraints(sum(costRandom$CostR) * 0.1, sense = \"<=\", costRandom$CostR ) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(verbose = FALSE) s8 <- p8 %>% prioritizr::solve.ConservationProblem() (gg_s8 <- splnr_plot_solution(s8) + splnr_gg_add(PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"common-targets-across-zones","dir":"Articles","previous_headings":"Overview > Get the features","what":"Common targets across zones","title":"Spatial Planning With Zones","text":"Sometimes might required meet (common) conservation target across multiple zones, several zones contribute reaching target. , need define target across zones (: 30% features across zones): need bring data specific format requires us individual column feature specific zone, spp1 two zones (zone1 zone2), two separate columns input data: spp1_zone1 spp1_zone2. species names zone names exactly specified zones() object separated _. also extract new feature names create zones object, joining two newly created data frames file used prioriztisation. can see defined (random) cost layers cost layer zone2 three times costly zone1. setting solving conservation problem, can look resulting solution well targets met. overall summary shows every feature’s suitable habitat represented least 30% combined target set. However, can see features zone1 lot frequently selected zone2 zone2 three times costly. plot also reflects observation PUs frequently selected zone1. wanted constrain , zone1 less often selected zone2 often?","code":"targetAcross <- dplyr::tibble( feature = col_name, zone = list(c(\"zone1\", \"zone2\"))[rep(1, length(col_name))], target = rep(0.3, length(col_name)), type = rep(\"relative\", length(col_name)) ) datSpecZone1 <- datEx_species_bin %>% dplyr::rename_at(dplyr::vars(-geometry), ~ paste0(.x, \"_zone1\")) featuresZone1 <- datSpecZone1 %>% sf::st_drop_geometry() %>% colnames() datSpecZone2 <- datEx_species_bin %>% dplyr::rename_at(dplyr::vars(-geometry), ~ paste0(.x, \"_zone2\")) featuresZone2 <- datSpecZone2 %>% sf::st_drop_geometry() %>% colnames() z10 <- prioritizr::zones( featuresZone1, featuresZone2, zone_names = c(\"zone1\", \"zone2\"), feature_names = col_name ) out_sf <- datSpecZone1 %>% sf::st_join(datSpecZone2, join = sf::st_equals) %>% dplyr::mutate( Cost1 = runif(n = dim(.)[[1]]) * 100, Cost2 = runif(n = dim(.)[[1]]) * 300 ) p10 <- prioritizr::problem(out_sf, z10, cost_column = c(\"Cost1\", \"Cost2\") ) %>% prioritizr::add_min_set_objective() %>% prioritizr::add_manual_targets(targetAcross) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(verbose = FALSE) s10 <- p10 %>% prioritizr::solve.ConservationProblem() s10F <- s10 %>% dplyr::select(tidyselect::starts_with(c(\"solution\"))) %>% sf::st_drop_geometry() %>% tibble::as_tibble() r10 <- prioritizr::eval_feature_representation_summary(p10, s10F) print(r10) #> # A tibble: 45 × 5 #> summary feature total_amount absolute_held relative_held #> #> 1 overall Chelonia_mydas 44 14 0.318 #> 2 overall Caretta_caretta 44 14 0.318 #> 3 overall Eretmochelys_imbricata 48 15 0.312 #> 4 overall Lepidochelys_olivacea 44 14 0.318 #> 5 overall Crocodylus_porosus 42 14 0.333 #> 6 overall Megaptera_novaeangliae 776 234 0.302 #> 7 overall Balaenoptera_acutorostrata 476 146 0.307 #> 8 overall Dugong_dugon 26 10 0.385 #> 9 overall Carcharias_taurus 44 14 0.318 #> 10 overall Galeocerdo_cuvier 72 25 0.347 #> # ℹ 35 more rows (gg_s10 <- splnr_plot_solution(s10, zones = TRUE, colorVals = c(\"#c6dbef\", \"#3182bd\", \"black\"), legendLabels = c(\"Not selected\", \"Zone 1\", \"Zone 2\") ) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"targets-across-zones-with-linear-constraints","dir":"Articles","previous_headings":"Overview > Get the features","what":"Targets across zones with linear constraints","title":"Spatial Planning With Zones","text":"can include linear constraints zone1 , area exceed 30% whole area. need create matrix contains data constraint want include. Although want put linear constraint zone1, prioritizr still requires matrix many columns zones. Thus, set area cost 1 zone1 want constraint 0 zone2 want introduce linear constraint. define conservation problem add linear constraint 30% area. selected planning units now equally distributed across zones, also observable plot: However, also expect cost spatial plan higher previous one.","code":"CostArea <- out_sf %>% dplyr::mutate( areaCostZone1 = rep(1, 397), areaCostZone2 = rep(0, 397) ) %>% sf::st_drop_geometry() %>% dplyr::select(\"areaCostZone1\", \"areaCostZone2\") %>% as.matrix() p11 <- prioritizr::problem(out_sf, z10, cost_column = c(\"Cost1\", \"Cost2\") ) %>% prioritizr::add_min_set_objective() %>% prioritizr::add_linear_constraints(sum(CostArea[, 1]) * 0.3, sense = \"<=\", CostArea ) %>% prioritizr::add_manual_targets(targetAcross) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(verbose = FALSE) s11 <- p11 %>% prioritizr::solve.ConservationProblem() s11F <- s11 %>% dplyr::select(tidyselect::starts_with(c(\"solution\"))) %>% sf::st_drop_geometry() %>% tibble::as_tibble() r11 <- prioritizr::eval_feature_representation_summary(p11, s11F) print(r11) #> # A tibble: 45 × 5 #> summary feature total_amount absolute_held relative_held #> #> 1 overall Chelonia_mydas 44 14 0.318 #> 2 overall Caretta_caretta 44 14 0.318 #> 3 overall Eretmochelys_imbricata 48 15 0.312 #> 4 overall Lepidochelys_olivacea 44 14 0.318 #> 5 overall Crocodylus_porosus 42 14 0.333 #> 6 overall Megaptera_novaeangliae 776 234 0.302 #> 7 overall Balaenoptera_acutorostrata 476 144 0.303 #> 8 overall Dugong_dugon 26 9 0.346 #> 9 overall Carcharias_taurus 44 14 0.318 #> 10 overall Galeocerdo_cuvier 72 24 0.333 #> # ℹ 35 more rows (gg_s11 <- splnr_plot_solution( s11, zones = TRUE, colorVals = c(\"#c6dbef\", \"#3182bd\", \"black\"), legendLabels = c(\"Not selected\", \"Zone 1\", \"Zone 2\") ) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"targets-across-some-but-not-all-zones","dir":"Articles","previous_headings":"Overview > Get the features","what":"Targets across some (but not all) zones","title":"Spatial Planning With Zones","text":"example, want target 30% suitable reptile habitat zone 1 zone 2. Additionally, set target 20% zone 2 marine mammals target 5% sharks rays zone 3. create zones object three different zones: create joint sf object zones respective costs.","code":"targetAcrossSome <- Dict %>% dplyr::mutate( target = dplyr::case_when( category == \"Reptiles\" ~ 30 / 100, category == \"Mammals\" ~ 10 / 100, category == \"Sharks and rays\" ~ 5 / 100, TRUE ~ 0 ), zone = dplyr::case_when( category == \"Reptiles\" ~ list(c(\"zone1\", \"zone2\")), category == \"Mammals\" ~ list(\"zone2\"), category == \"Sharks and rays\" ~ list(\"zone3\"), TRUE ~ list(c(\"zone1\", \"zone2\", \"zone3\")) ), type = rep(\"relative\", length(col_name)) ) %>% dplyr::rename(feature = \"nameVariable\") %>% dplyr::select(-\"category\", -\"nameCommon\") datSpecZone1 <- datEx_species_bin %>% dplyr::rename_at(dplyr::vars(-geometry), ~ paste0(.x, \"_zone1\")) featuresZone1 <- datSpecZone1 %>% sf::st_drop_geometry() %>% colnames() datSpecZone2 <- datEx_species_bin %>% dplyr::rename_at(dplyr::vars(-geometry), ~ paste0(.x, \"_zone2\")) featuresZone2 <- datSpecZone2 %>% sf::st_drop_geometry() %>% colnames() datSpecZone3 <- datEx_species_bin %>% dplyr::rename_at(dplyr::vars(-geometry), ~ paste0(.x, \"_zone3\")) featuresZone3 <- datSpecZone3 %>% sf::st_drop_geometry() %>% colnames() z12 <- prioritizr::zones( featuresZone1, featuresZone2, featuresZone3, zone_names = c(\"zone1\", \"zone2\", \"zone3\"), feature_names = col_name ) # NOTE: When using sf input, we need as many cost columns as we have zones out_sf <- datSpecZone1 %>% sf::st_join(datSpecZone2, join = sf::st_equals) %>% sf::st_join(datSpecZone3, join = sf::st_equals) %>% dplyr::mutate(geometry = datEx_species_bin$geometry) %>% sf::st_as_sf() %>% dplyr::mutate( Cost1 = runif(n = dim(.)[[1]]) * 100, Cost2 = runif(n = dim(.)[[1]]) * 300, Cost3 = runif(n = dim(.)[[1]]) * 200 ) p12 <- prioritizr::problem(out_sf, z12, cost_column = c(\"Cost1\", \"Cost2\", \"Cost3\") ) %>% prioritizr::add_min_set_objective() %>% prioritizr::add_manual_targets(targetAcrossSome) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(verbose = FALSE) s12 <- p12 %>% prioritizr::solve.ConservationProblem() s12F <- s12 %>% dplyr::select(tidyselect::starts_with(c(\"solution\"))) %>% sf::st_drop_geometry() %>% tibble::as_tibble() r12 <- prioritizr::eval_feature_representation_summary(p12, s12F) print(r12) #> # A tibble: 60 × 5 #> summary feature total_amount absolute_held relative_held #> #> 1 overall Chelonia_mydas 66 16 0.242 #> 2 overall Caretta_caretta 66 16 0.242 #> 3 overall Eretmochelys_imbricata 72 17 0.236 #> 4 overall Lepidochelys_olivacea 66 16 0.242 #> 5 overall Crocodylus_porosus 63 16 0.254 #> 6 overall Megaptera_novaeangliae 1164 64 0.0550 #> 7 overall Balaenoptera_acutorostrata 714 44 0.0616 #> 8 overall Dugong_dugon 39 8 0.205 #> 9 overall Carcharias_taurus 66 16 0.242 #> 10 overall Galeocerdo_cuvier 108 19 0.176 #> # ℹ 50 more rows (gg_s12 <- splnr_plot_solution( s12, zones = TRUE, colorVals = c(\"#c6dbef\", \"#3182bd\", \"navyblue\", \"black\"), legendLabels = c(\"Not selected\", \"Zone 1\", \"Zone 2\", \"Zone3\") ) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ))"},{"path":[]},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"short-term","dir":"Articles","previous_headings":"Overview > Get the features > Next steps","what":"Short-term","title":"Spatial Planning With Zones","text":"Test run time zones compared normal prioritisation Communicate zones outcomes effectively (e.g. targets, cost overlay etc.)","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/articles/MultipleUse.html","id":"longer-term","dir":"Articles","previous_headings":"Overview > Get the features > Next steps","what":"Longer-term","title":"Spatial Planning With Zones","text":"deal overlapping zones (moment prioritizr allocates PU single zone) connect climate-smart workflow zones handle inputs benefit using different objective functions (e.g. ecosystem services vs biodiversity features) Look commonly used data sets multiple use approaches think zone-specific costs, constraints, targets etc. Define (Waitt’s) understanding multiple-use want implement (can differ now future) EU Horizon 2020 MUSES-project: multiple use/multi-use “joint use resources close geographic proximity either single user multiple users. umbrella term covers multitude use combinations marine realm represents radical change concept exclusive resource rights inclusive sharing resources space one users.” Bonnevie et al. 2019: “multi-use specific co-location/coexistence resources shared.” Schupp et al. 2019: distinguishes different types multi-uses (one co-location) Types multiple use MSP according Schupp et al. 2019","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"overview","dir":"Articles","previous_headings":"","what":"Overview","title":"A Basic Spatial Planning Workflow","text":"code written simplify process running prioritizr analysis given region. still work progress feel free submit pull requests new features code improvements.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"set-user-parameters","dir":"Articles","previous_headings":"Overview","what":"Set user parameters","title":"A Basic Spatial Planning Workflow","text":"can set region defined splnr_get_planningUnits. can also define region square boundaries (degrees) need. Choose CRS analysis. case use Mollweide Set diameter planning units. units CRS (usually metres degrees).","code":"Region <- \"Coral Sea\" # \"Australia\" Type <- \"Oceans\" # \"EEZ\" Region <- c(xmin = 150, xmax = 160, ymin = -40, ymax = -30) cCRS <- \"ESRI:54009\" PU_size <- 107460 # m"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"analysis-region","dir":"Articles","previous_headings":"Overview","what":"Analysis Region","title":"A Basic Spatial Planning Workflow","text":"Start analysis defining region setting planning units. Get boundary chosen region. Get land boundaries remove overlap. object “landmass” represents land mass removed (inverse = FALSE)","code":"Bndry <- splnr_get_boundary(Limits = Region, Type = Type, cCRS = cCRS) #> Reading layer `ne_10m_geography_marine_polys' from data source #> `/private/var/folders/_r/mcmw_qtn0m7cd23cbdqfszl40000gp/T/RtmpYDUd6r/ne_10m_geography_marine_polys.shp' #> using driver `ESRI Shapefile' #> Simple feature collection with 306 features and 37 fields #> Geometry type: MULTIPOLYGON #> Dimension: XY #> Bounding box: xmin: -180 ymin: -85.19206 xmax: 179.9999 ymax: 90 #> Geodetic CRS: WGS 84 landmass <- rnaturalearth::ne_countries( scale = \"medium\", returnclass = \"sf\" ) %>% sf::st_transform(cCRS)"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"create-planning-units","dir":"Articles","previous_headings":"Overview","what":"Create Planning Units","title":"A Basic Spatial Planning Workflow","text":"can check PUs look like want add additional properties map, example landmass boundary, can use splnr_gg_add(). can also use customised ggplpot theme can passed list splnr_gg_add() can used plots. example:","code":"PUs <- spatialgridr::get_grid(boundary = Bndry, crs = cCRS, output = \"sf_hex\", resolution = PU_size) (ggPU <- splnr_plot(df = PUs) + ggplot2::theme_bw()) # Plot Planning Units (ggPU <- splnr_plot(df = PUs) + splnr_gg_add( Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = \"Default\" )) splnr_theme <- list( ggplot2::theme_bw(), ggplot2::theme( legend.position = \"right\", legend.direction = \"vertical\", text = ggplot2::element_text(size = 9, colour = \"black\"), axis.text = ggplot2::element_text(size = 9, colour = \"black\"), plot.title = ggplot2::element_text(size = 9), axis.title = ggplot2::element_blank() ) ) (ggPU <- splnr_plot(PUs) + splnr_gg_add( Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"get-the-features","dir":"Articles","previous_headings":"Overview","what":"Get the features","title":"A Basic Spatial Planning Workflow","text":"example, use small subset charismatic megafauna species Coral Sea inform conservation plan. filtered Aquamaps (Aquamaps.org) species distribution models study area following species: species chosen based importance region represent example visualization purposes. Note: structure tribbleabove required downstream plotting. Common denotes common name species, nameVariable scientific name format used Aquamaps, TaxGroup taxonomic grouping species belongs Category represents importance species conservation plan.","code":"Dict <- tibble::tribble( ~nameCommon, ~nameVariable, ~category, \"Green sea turtle\", \"Chelonia_mydas\", \"Reptiles\", \"Loggerhead sea turtle\", \"Caretta_caretta\", \"Reptiles\", \"Hawksbill sea turtle\", \"Eretmochelys_imbricata\", \"Reptiles\", \"Olive ridley sea turtle\", \"Lepidochelys_olivacea\", \"Reptiles\", \"Saltwater crocodile\", \"Crocodylus_porosus\", \"Reptiles\", \"Humpback whale\", \"Megaptera_novaeangliae\", \"Mammals\", \"Common Minke whale\", \"Balaenoptera_acutorostrata\", \"Mammals\", \"Dugong\", \"Dugong_dugon\", \"Mammals\", \"Grey nurse shark\", \"Carcharias_taurus\", \"Sharks and rays\", \"Tiger shark\", \"Galeocerdo_cuvier\", \"Sharks and rays\", \"Great hammerhead shark\", \"Sphyrna_mokarran\", \"Sharks and rays\", \"Giant oceanic manta ray\", \"Mobula_birostris\", \"Sharks and rays\", \"Reef manta ray\", \"Mobula_alfredi\", \"Sharks and rays\", \"Whitetip reef shark\", \"Triaenodon_obesus\", \"Sharks and rays\", \"Red-footed booby\", \"Sula_sula\", \"Birds\" )"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"convert-the-probabilities-to-binary-data","dir":"Articles","previous_headings":"Overview > Get the features","what":"Convert the probabilities to binary data","title":"A Basic Spatial Planning Workflow","text":"can now look feature data used spatial plan individually calling splnr_plot_binFeature(), example see binary habitat suitability map Green sea turtles: suitable habitat Green sea turtles predicted Aquamaps restricted cells close coast. now compare predicted suitable habitat Humpback whales, can see fairly ubiquitous across whole Coral Sea. example, reason classified species either representative suitable habitat wide-ranging within study region important restricted number cells. get better idea overall distribution used features, can also plot number features suitable habitat within planning unit study region.","code":"datEx_species_bin <- spDataFiltered %>% splnr_apply_cutoffs(Cutoffs = 0.5) (ggFeature1 <- splnr_plot( df = datEx_species_bin, col_names = \"Chelonia_mydas\", plot_title = \"Chelonia mydas\", legend_labels = c(\"Absence\", \"Presence\") ) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ) ) (ggFeature <- splnr_plot( datEx_species_bin, \"Megaptera_novaeangliae\", plot_title = \"Megaptera novaeangliae\" ) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme )) (ggFeatNo <- splnr_plot(df = datEx_species_bin, col_names = colnames(datEx_species_bin %>% sf::st_drop_geometry()), plot_title = \"\", legend_title = \"Number of features\") + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"prepare-data-for-prioritisation","dir":"Articles","previous_headings":"Overview","what":"Prepare Data for prioritisation","title":"A Basic Spatial Planning Workflow","text":"spatial prioritization also need extract names features pass prioritizr. also create sf object contains information needed prioritization.","code":"feature_names <- splnr_featureNames(datEx_species_bin) out_sf <- datEx_species_bin"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"add-cost","dir":"Articles","previous_headings":"Overview > Prepare Data for prioritisation","what":"Add Cost","title":"A Basic Spatial Planning Workflow","text":"example, use minimum set objective function, aims minimize cost whilst meeting conservation targets. add area-based cost include little area possible spatial plan whilst meeting conservation targets. , planning units assigned equal cost 1.","code":"out_sf$Cost_None <- 1 (ggCost <- splnr_plot(out_sf, col_names = \"Cost_None\", legend_title = \"Cost\", legend_labels = \"1\") + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ))"},{"path":[]},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"fishing-effort","dir":"Articles","previous_headings":"","what":"A Basic Spatial Planning Workflow","title":"A Basic Spatial Planning Workflow","text":"gfwr package allows us recover data fisheries across world, set parameter compress TRUE recover Apparent fishing hours per coordinates.","code":"gfw_data <- splnr_get_gfw(region = 'Australia', start_date = \"2022-01-01\", end_date = \"2022-12-31\", temp_res = \"yearly\", cCRS = cCRS, compress = TRUE) %>% sf::st_interpolate_aw(PUs, extensive = TRUE) out_sf$Apparent.Fishing.Hours <- 0 # Add column to PUs out_sf$Apparent.Fishing.Hours[as.numeric(rownames(PUs))] <- gfw_data$Apparent.Fishing.Hours # Put corresponding data in PUs (ggCost <- splnr_plot(out_sf, col_names = \"Apparent.Fishing.Hours\") + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"other-features-1","dir":"Articles","previous_headings":"","what":"A Basic Spatial Planning Workflow","title":"A Basic Spatial Planning Workflow","text":"Many features can taken account cost layers prioritization, provide different features oceandatrpackage.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"set-targets","dir":"Articles","previous_headings":"Overview","what":"Set Targets","title":"A Basic Spatial Planning Workflow","text":"shown previously, assigned conservation features class reflecting importance planning region. Conservation targets assigned target based class, case 30% suitable habitat important 10% representative features. Note: assigned classes targets based ecological information chosen visualization purposes.","code":"catTarg <- c(\"Reptiles\" = 0.3, \"Mammals\" = 0.1, \"Sharks and rays\" = 0.1, \"Birds\" = 0.1) target <- Dict %>% splnr_targets_byCategory(catTarg, catName = \"category\")"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"set-up-conservation-problem","dir":"Articles","previous_headings":"Overview","what":"Set up conservation problem","title":"A Basic Spatial Planning Workflow","text":"","code":"datEx_problem <- prioritizr::problem(out_sf, feature_names, \"Cost_None\") %>% prioritizr::add_min_set_objective() %>% prioritizr::add_relative_targets(target$target) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(verbose = FALSE)"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"solve-the-conservation-problem","dir":"Articles","previous_headings":"Overview","what":"Solve the conservation problem","title":"A Basic Spatial Planning Workflow","text":"","code":"datEx_soln <- datEx_problem %>% prioritizr::solve.ConservationProblem()"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"visualize-output","dir":"Articles","previous_headings":"Overview","what":"Visualize Output","title":"A Basic Spatial Planning Workflow","text":"different ways visualize output prioritization can loosely grouped three categories: + Visualization solution + Visualization targets + Visualization importance scores","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"visualization-of-the-solution","dir":"Articles","previous_headings":"Overview > Visualize Output","what":"Visualization of the solution","title":"A Basic Spatial Planning Workflow","text":"plot shows optimal solution planning region meets selected targets chosen features smallest area possible. categorical map displays, planning units selected important meeting conservation targets (dark blue) selected (light blue). can also done overlay cost show solution avoids highly costly areas: Note: example, cost equal planning units.","code":"(ggSoln <- splnr_plot(datEx_soln, col_names = \"solution_1\", legend_title = \"Solution\", legend_labels = c(\"0\",\"1\")) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme )) (ggCostOverlay <- splnr_plot_costOverlay( soln = datEx_soln, Cost = NA, Cost_name = \"Cost_None\" ) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"visualization-of-targets","dir":"Articles","previous_headings":"Overview > Visualize Output","what":"Visualization of targets","title":"A Basic Spatial Planning Workflow","text":"visualize well targets met, first need extract much suitable habitat feature selected spatial plan. also includes potential incidental coverage feature included spatial plan can still found planning region. circular bar plot, one additional step data preparation needs done.","code":"dfTarget <- splnr_get_featureRep(datEx_soln, datEx_problem, climsmart = FALSE, solnCol = \"solution_1\" ) (ggTarget <- splnr_plot_featureRep(dfTarget, category = Dict, renameFeatures = TRUE, namesToReplace = Dict, categoryFeatureCol = \"nameCommon\", nr = 1, showTarget = TRUE, )) dfTargetCirc <- dfTarget %>% dplyr::select(\"feature\", \"value\", \"group\") %>% na.omit() colors <- c( \"important\" = \"darkgreen\", \"representative\" = \"darkred\" ) legends <- c(\"Important\", \"Representative\") (ggCircTarg <- splnr_plot_circBplot(df = dfTargetCirc, legend_list = legends, legend_color = colors, impTarget = 30, repTarget = 10))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"visualization-of-importance-scores","dir":"Articles","previous_headings":"Overview > Visualize Output","what":"Visualization of importance scores","title":"A Basic Spatial Planning Workflow","text":"Importance scores can help assess relative importance individual selected planning unit spatial plan (information, see https://prioritizr.net/reference/importance.html) , use two different importance scores, Ferrier Score Rarity Weighted Richness. example, scores label similar -coastal- planning units important spatial plan.","code":"ggFerrier <- splnr_plot_importanceScore( soln = datEx_soln, pDat = datEx_problem, method = \"Ferrier\", decimals = 4, legendTitle = \"Importance Score \\n(Ferrier Score)\" ) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ) #> Ferrier Score. ggRWR <- splnr_plot_importanceScore( soln = datEx_soln, pDat = datEx_problem, method = \"RWR\", decimals = 2, legendTitle = \"Importance Score \\n(Rarity Weighted Richness)\" ) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ) #> Rarity Wighted Richness. (ggScores <- patchwork::wrap_plots(ggFerrier + ggRWR))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"comparing-spatial-plans","dir":"Articles","previous_headings":"Overview","what":"Comparing Spatial Plans","title":"A Basic Spatial Planning Workflow","text":"Sometimes can useful direct comparison two spatial plans. show achieve package, first need second conservation problem resulting solution. , second spatial plan include already existing marine protected areas area (https://www.protectedplanet.net/en/thematic-areas/wdpa?tab=WDPA) following characteristics: * Status = c(“Designated”, “Established”, “Inscribed”) * Designation Type = c(“National”, “Regional”, “International”, “Applicable”) * IUCN Category = c(“Ia”, “Ib”, “II”, “III”, “IV”) also include targets based IUCN categories prioritise species IUCN status : Vulnerable Endangered Critically Endangered Extinct Wild Extinct assign 30% target species within categories. species fall categories receive inverse area target, species greater area suitable habitat assigned lower target. can also adjust targets based IUCN Category. apply increased target 0.3 species increased thread level IUCN Red List(“EX”, “EW”, “CR”, “EN”, “VU”). Note: Accessing IUCN database requires login token rl_use_iucn() needs added environment using Sys.setenv(IUCN_REDLIST_KEY = \"[Token]\"). can start running rredlist::rl_use_iucn().","code":"# The user can download their own MPAs using this code, # but below we use data already within the package. LockedIn <- splnr_get_MPAs(PUs, \"Australia\") %>% splnr_apply_cutoffs(0.5) %>% dplyr::mutate(wdpa = as.logical(wdpa)) (ggMPA <- splnr_plot(MPAsCoralSea, \"wdpa\") + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme )) minTarget <- 0.1 maxTarget <- 0.2 # Create inverse area target IA_Targets <- splnr_targets_byInverseArea( datEx_species_bin, minTarget, maxTarget ) IUCN_IA_Targets <- IA_Targets %>% splnr_get_IUCNRedList(species_col = \"Species\") %>% # Add RL data to the df splnr_targets_byIUCN(IUCN_target = 0.3)"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"set-up-second-conservation-problem","dir":"Articles","previous_headings":"Overview > Comparing Spatial Plans","what":"Set up second conservation problem","title":"A Basic Spatial Planning Workflow","text":"locked areas already existing MPAs. want show overlap selected planning units current MPAs, can can add splnr_gg_add()function. instead want see contours locked areas can set typeLockIn = \"Contours\"splnr_gg_add().","code":"datEx_problem2 <- prioritizr::problem(out_sf, feature_names, \"Cost_None\") %>% prioritizr::add_min_set_objective() %>% prioritizr::add_relative_targets(IA_Targets$target) %>% prioritizr::add_locked_in_constraints(as.logical(MPAsCoralSea$wdpa)) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(verbose = FALSE) # Add a solution object datEx_soln2 <- datEx_problem2 %>% prioritizr::solve.ConservationProblem() (ggSoln2 <- splnr_plot_solution(datEx_soln2) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme )) (splnr_plot_solution(datEx_soln2) + splnr_gg_add( PUs = PUs, Bndry = Bndry, lockIn = MPAsCoralSea, nameLockIn = \"wdpa\", typeLockIn = \"Full\", colorLockIn = \"lightgrey\", alphaLockIn = 0.2, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme )) (splnr_plot_solution(datEx_soln2) + splnr_gg_add( lockIn = MPAsCoralSea, nameLockIn = \"wdpa\", typeLockIn = \"Contours\", colorLockIn = \"lightgrey\", alphaLockIn = 0.2, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"visualize-comparison","dir":"Articles","previous_headings":"Overview > Comparing Spatial Plans","what":"Visualize comparison","title":"A Basic Spatial Planning Workflow","text":"plot shows first solution (without current MPAs) differs second solution (including current MPAs. categorical map displays, planning units selected solution 2 solution 1 (red), solution 1 solution 2 (blue), selected solutions (grey). correlation matrix shows similarity Cohen’s Kappa correlation solution 1 solution 2.","code":"(ggComp <- splnr_plot_comparison(datEx_soln, datEx_soln2) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme )) CorrMat <- splnr_get_kappaCorrData(list(datEx_soln, datEx_soln2), name_sol = c(\"soln1\", \"soln2\") ) (ggCorr <- splnr_plot_corrMat(CorrMat, AxisLabels = c(\"Solution 1\", \"Solution 2\") ))"},{"path":"https://mathmarecol.github.io/spatialplanr/articles/spatialplanr.html","id":"plotting-selection-frequency","dir":"Articles","previous_headings":"Overview > Comparing Spatial Plans","what":"Plotting selection frequency","title":"A Basic Spatial Planning Workflow","text":"Sometimes multiple spatial plans generated, interested many times planning unit selected across array solutions. demonstrate can done using package, first create array (= portfolio) solutions. One example using portfolio","code":"datEx_soln_portfolio <- datEx_problem %>% prioritizr::add_cuts_portfolio(5) %>% # create a portfolio of solutions prioritizr::solve.ConservationProblem() selFreq <- datEx_soln_portfolio %>% # calculate selection frequency sf::st_drop_geometry() %>% dplyr::mutate(selFreq = as.factor(rowSums( dplyr::select(., dplyr::starts_with(\"solution_\")) ))) %>% sf::st_as_sf(geometry = datEx_soln_portfolio$geometry) %>% dplyr::select(selFreq) (ggselFreq <- splnr_plot_selectionFreq(selFreq) + splnr_gg_add( PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme ))"},{"path":"https://mathmarecol.github.io/spatialplanr/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Jason D. Everett. Author, maintainer. Sandra Neubert. Author.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Everett J, Neubert S (2024). spatialplanr: Help files prioritzr Spatial Planning projects. R package version 0.6.7, https://github.com/MathMarEcol/spatialplanr.","code":"@Manual{, title = {spatialplanr: Help files for prioritzr Spatial Planning projects}, author = {Jason D. Everett and Sandra Neubert}, year = {2024}, note = {R package version 0.6.7}, url = {https://github.com/MathMarEcol/spatialplanr}, }"},{"path":[]},{"path":"https://mathmarecol.github.io/spatialplanr/index.html","id":"overview","dir":"","previous_headings":"","what":"Overview","title":"Help files for prioritzr Spatial Planning projects","text":"package designed assist students staff Mathematical Marine Ecology Lab University Queensland. may useful others well. code written simplify process running prioritizr analysis given region use workflows data MME Lab. still work progress feel free submit pull requests new features code improvements.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Help files for prioritzr Spatial Planning projects","text":"aware package early stages development. Functions documentation complete installing moment risk. still interested, can install development version GitHub :","code":"# install.packages(\"devtools\") devtools::install_github(\"https://github.com/MathMarEcol/spatialplanr\")"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/CoralSeaVelocity.html","id":null,"dir":"Reference","previous_headings":"","what":"Example climate velocity for the example region of the coral sea — CoralSeaVelocity","title":"Example climate velocity for the example region of the coral sea — CoralSeaVelocity","text":"tsf file containing climate velocity (SSP5-8.5) coral sea","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/CoralSeaVelocity.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Example climate velocity for the example region of the coral sea — CoralSeaVelocity","text":"","code":"CoralSeaVelocity"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/CoralSeaVelocity.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Example climate velocity for the example region of the coral sea — CoralSeaVelocity","text":"CoralSeaVelocity data frame 397 rows 3 columns: vocMagg_transformed Climate velocity column geometry Geometry column sf object","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/CoralSeaVelocity.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Example climate velocity for the example region of the coral sea — CoralSeaVelocity","text":"https://www.iucnredlist.org/","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/IUCN_IA_Targets.html","id":null,"dir":"Reference","previous_headings":"","what":"IUCN and Inverse Area based Targets for Aquamaps example species — IUCN_IA_Targets","title":"IUCN and Inverse Area based Targets for Aquamaps example species — IUCN_IA_Targets","text":"tbl_df file containing IUCN IA targets selected species coral sea","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/IUCN_IA_Targets.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"IUCN and Inverse Area based Targets for Aquamaps example species — IUCN_IA_Targets","text":"","code":"IUCN_IA_Targets"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/IUCN_IA_Targets.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"IUCN and Inverse Area based Targets for Aquamaps example species — IUCN_IA_Targets","text":"IUCN_IA_Targets data frame 15 rows 4 columns: Species Species names found IUCN database Area km2 total suitable habitat species Target Individual species-specific target IUCN_Category IUCN category species","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/IUCN_IA_Targets.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"IUCN and Inverse Area based Targets for Aquamaps example species — IUCN_IA_Targets","text":"https://www.iucnredlist.org/","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/MPAsCoralSea.html","id":null,"dir":"Reference","previous_headings":"","what":"Current MPAs of the Coral Sea — MPAsCoralSea","title":"Current MPAs of the Coral Sea — MPAsCoralSea","text":"sf file containing current marine protected areas coral sea","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/MPAsCoralSea.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Current MPAs of the Coral Sea — MPAsCoralSea","text":"","code":"MPAsCoralSea"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/MPAsCoralSea.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Current MPAs of the Coral Sea — MPAsCoralSea","text":"MPAsCoralSea data frame 397 rows 17 columns: wdpa binary vector denoting presence absence current marine protected area","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/MPAsCoralSea.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Current MPAs of the Coral Sea — MPAsCoralSea","text":"https://www.protectedplanet.net/en/thematic-areas/wdpa?tab=WDPA","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_PUs.html","id":null,"dir":"Reference","previous_headings":"","what":"Planning Units — dat_PUs","title":"Planning Units — dat_PUs","text":"sf dataframe planning units spatial prioritisation","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_PUs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Planning Units — dat_PUs","text":"","code":"dat_PUs"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_PUs.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Planning Units — dat_PUs","text":"dat_PUs data frame XXXX rows XXX columns: geometry sf geometry column","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_PUs.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Planning Units — dat_PUs","text":"\"Made data\"","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_bathy.html","id":null,"dir":"Reference","previous_headings":"","what":"Bathymetry Data — dat_bathy","title":"Bathymetry Data — dat_bathy","text":"Bathymetry data downloaded via oceandatr package","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_bathy.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Bathymetry Data — dat_bathy","text":"","code":"dat_bathy"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_bathy.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Bathymetry Data — dat_bathy","text":"dat_bathy data frame bathymetry data bathymetry Bathymetry data geometry sf geometry column","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_bathy.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Bathymetry Data — dat_bathy","text":"\"oceandatr package\"","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_bndry.html","id":null,"dir":"Reference","previous_headings":"","what":"Boundary of planning units — dat_bndry","title":"Boundary of planning units — dat_bndry","text":"sf dataframe planning units spatial prioritisation","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_bndry.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Boundary of planning units — dat_bndry","text":"","code":"dat_bndry"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_bndry.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Boundary of planning units — dat_bndry","text":"dat_bndry data frame XXXX rows XXX columns: geometry sf geometry column","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_bndry.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Boundary of planning units — dat_bndry","text":"\"Made data\"","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_category.html","id":null,"dir":"Reference","previous_headings":"","what":"Category vector — dat_category","title":"Category vector — dat_category","text":"tibble containing specific grouping features","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_category.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Category vector — dat_category","text":"","code":"dat_category"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_category.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Category vector — dat_category","text":"dat_category data frame XXXX rows XXX columns: feature features available spatial prioritisation category categories features","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_category.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Category vector — dat_category","text":"\"Made data\"","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_category2.html","id":null,"dir":"Reference","previous_headings":"","what":"Category vector — dat_category2","title":"Category vector — dat_category2","text":"tibble containing specific grouping features","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_category2.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Category vector — dat_category2","text":"","code":"dat_category2"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_category2.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Category vector — dat_category2","text":"dat_category2 data frame XXXX rows XXX columns: feature features available spatial prioritisation category categories features","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_category2.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Category vector — dat_category2","text":"\"Made data\"","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_clim.html","id":null,"dir":"Reference","previous_headings":"","what":"Climate metric data — dat_clim","title":"Climate metric data — dat_clim","text":"sf dataframe planning units spatial prioritisation","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_clim.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Climate metric data — dat_clim","text":"","code":"dat_clim"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_clim.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Climate metric data — dat_clim","text":"dat_clim data frame 780 rows 3 columns: geometry sf geometry column metric climate metric information","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_clim.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Climate metric data — dat_clim","text":"\"Made data\"","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_mpas.html","id":null,"dir":"Reference","previous_headings":"","what":"MPA Data — dat_mpas","title":"MPA Data — dat_mpas","text":"sf dataframe planning units spatial prioritisation","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_mpas.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"MPA Data — dat_mpas","text":"","code":"dat_mpas"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_mpas.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"MPA Data — dat_mpas","text":"dat_mpas data frame XXXX rows XXX columns: geometry sf geometry column wdpa binary MPA information (1: MPA)","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_mpas.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"MPA Data — dat_mpas","text":"\"Made data\"","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_region.html","id":null,"dir":"Reference","previous_headings":"","what":"Regionalisation — dat_region","title":"Regionalisation — dat_region","text":"sf dataframe planning units spatial prioritisation","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_region.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Regionalisation — dat_region","text":"","code":"dat_region"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_region.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Regionalisation — dat_region","text":"dat_region data frame XXXX rows XXX columns: geometry sf geometry column","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_region.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Regionalisation — dat_region","text":"\"Made data\"","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_species_bin.html","id":null,"dir":"Reference","previous_headings":"","what":"Binary Species Data — dat_species_bin","title":"Binary Species Data — dat_species_bin","text":"sf dataframe planning units spatial prioritisation","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_species_bin.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Binary Species Data — dat_species_bin","text":"","code":"dat_species_bin"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_species_bin.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Binary Species Data — dat_species_bin","text":"dat_species_bin data frame XXXX rows XXX columns: geometry sf geometry column","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_species_bin.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Binary Species Data — dat_species_bin","text":"\"Made data\"","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_species_bin2.html","id":null,"dir":"Reference","previous_headings":"","what":"Binary Species Data 2 — dat_species_bin2","title":"Binary Species Data 2 — dat_species_bin2","text":"sf dataframe planning units spatial prioritisation","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_species_bin2.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Binary Species Data 2 — dat_species_bin2","text":"","code":"dat_species_bin2"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_species_bin2.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Binary Species Data 2 — dat_species_bin2","text":"dat_species_bin2 data frame XXXX rows XXX columns: geometry sf geometry column","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_species_bin2.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Binary Species Data 2 — dat_species_bin2","text":"\"Made data\"","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_species_prob.html","id":null,"dir":"Reference","previous_headings":"","what":"Probability Species Data — dat_species_prob","title":"Probability Species Data — dat_species_prob","text":"sf dataframe planning units spatial prioritisation","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_species_prob.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Probability Species Data — dat_species_prob","text":"","code":"dat_species_prob"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_species_prob.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Probability Species Data — dat_species_prob","text":"dat_species_prob data frame XXXX rows XXX columns: geometry sf geometry column","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/dat_species_prob.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Probability Species Data — dat_species_prob","text":"\"Made data\"","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/pipe.html","id":null,"dir":"Reference","previous_headings":"","what":"Pipe operator — %>%","title":"Pipe operator — %>%","text":"See magrittr::%>% details.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/pipe.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Pipe operator — %>%","text":"","code":"lhs %>% rhs"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/spDataFiltered.html","id":null,"dir":"Reference","previous_headings":"","what":"Example data — spDataFiltered","title":"Example data — spDataFiltered","text":"Example data","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/spDataFiltered.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Example data — spDataFiltered","text":"","code":"spDataFiltered"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/spDataFiltered.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Example data — spDataFiltered","text":"spDataFiltered data frame sample species data Species Species names","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/spDataFiltered.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"Example data — spDataFiltered","text":"\"Made data\"","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/spatialplanr-package.html","id":null,"dir":"Reference","previous_headings":"","what":"spatialplanr: Help files for prioritzr Spatial Planning projects — spatialplanr-package","title":"spatialplanr: Help files for prioritzr Spatial Planning projects — spatialplanr-package","text":"package provides range tools setting , running plotting spatial plan using prioritizr. intended use Mathematical Marine Ecology Lab UQ, sets projects using approach data sets.","code":""},{"path":[]},{"path":"https://mathmarecol.github.io/spatialplanr/reference/spatialplanr-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"spatialplanr: Help files for prioritzr Spatial Planning projects — spatialplanr-package","text":"Maintainer: Jason D. Everett JaseEverett@gmail.com (ORCID) Authors: Sandra Neubert sandra.neubert97@gmail.com (ORCID)","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_apply_cutoffs.html","id":null,"dir":"Reference","previous_headings":"","what":"Function to apply cutoffs to feature data — splnr_apply_cutoffs","title":"Function to apply cutoffs to feature data — splnr_apply_cutoffs","text":"Function apply cutoffs feature data","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_apply_cutoffs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Function to apply cutoffs to feature data — splnr_apply_cutoffs","text":"","code":"splnr_apply_cutoffs(features, Cutoffs, inverse = FALSE)"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_apply_cutoffs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Function to apply cutoffs to feature data — splnr_apply_cutoffs","text":"features sf dataframe feature information Cutoffs single value named vector cutoffs. inverse TRUE, values Cutoffs used. FALSE (default), values kept.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_apply_cutoffs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Function to apply cutoffs to feature data — splnr_apply_cutoffs","text":"new sf dataframe cutoffs applied.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_apply_cutoffs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Function to apply cutoffs to feature data — splnr_apply_cutoffs","text":"","code":"df <- splnr_apply_cutoffs(dat_species_prob, Cutoffs = 0.5)"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_arrangeFeatures.html","id":null,"dir":"Reference","previous_headings":"","what":"Ensure all features are in the same order. — splnr_arrangeFeatures","title":"Ensure all features are in the same order. — splnr_arrangeFeatures","text":"splnr_arrangeFeatures() sorts data based longitude latitude values.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_arrangeFeatures.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Ensure all features are in the same order. — splnr_arrangeFeatures","text":"","code":"splnr_arrangeFeatures(df)"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_arrangeFeatures.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Ensure all features are in the same order. — splnr_arrangeFeatures","text":"df sf object sort Lon Lat","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_arrangeFeatures.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Ensure all features are in the same order. — splnr_arrangeFeatures","text":"sorted sf object","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_arrangeFeatures.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Ensure all features are in the same order. — splnr_arrangeFeatures","text":"","code":"df <- dat_species_prob %>% splnr_arrangeFeatures()"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_climate_featureApproach.html","id":null,"dir":"Reference","previous_headings":"","what":"Function to run the feature approach — splnr_climate_featureApproach","title":"Function to run the feature approach — splnr_climate_featureApproach","text":"Function run feature approach","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_climate_featureApproach.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Function to run the feature approach — splnr_climate_featureApproach","text":"","code":"splnr_climate_featureApproach( featuresDF, metricDF, targetsDF, direction, percentile = 35, refugiaTarget = 0.3 )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_climate_featureApproach.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Function to run the feature approach — splnr_climate_featureApproach","text":"featuresDF feature sfobject metricDF climate metric data.frame 'metric' column name metric values per planning unit. targetsDF data.framewith list features \"feature\" column corresponding targets \"target\" column direction direction = 1, metric values low (least climate-smart) high (climate-smart). direction = -1, metric values high (least climate-smart) low (climate-smart). percentile cut-threshold determining whether area climate priority area (e.g., lower 35th percentile warming upper 65th percentile acidification). Note percentile lower limit threshold. refugiaTarget target assigned climate-smart areas","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_climate_featureApproach.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Function to run the feature approach — splnr_climate_featureApproach","text":"list two components: 1. data frame passed prioritizr creating conservation problem containing binary information per planning unit per feature. 2. targets features conservation problem CPA approach used.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_climate_featureApproach.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Function to run the feature approach — splnr_climate_featureApproach","text":"","code":"Features <- dat_species_bin target <- Features %>% sf::st_drop_geometry() %>% colnames() %>% data.frame() %>% setNames(c(\"feature\")) %>% dplyr::mutate(target = 0.3) metric_df <- dat_clim Feature_Approach <- splnr_climate_featureApproach( featuresDF = dat_species_bin, metricDF = metric_df, targetsDF = target, direction = 1 ) #> [1] \"Higher values mean more climate-smart areas.\" out_sf <- Feature_Approach$Features targets <- Feature_Approach$Targets"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_climate_percentileApproach.html","id":null,"dir":"Reference","previous_headings":"","what":"Function to run the percentile approach — splnr_climate_percentileApproach","title":"Function to run the percentile approach — splnr_climate_percentileApproach","text":"Function run percentile approach","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_climate_percentileApproach.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Function to run the percentile approach — splnr_climate_percentileApproach","text":"","code":"splnr_climate_percentileApproach( featuresDF, metricDF, targetsDF, direction, percentile = 35 )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_climate_percentileApproach.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Function to run the percentile approach — splnr_climate_percentileApproach","text":"featuresDF feature sfobject metricDF climate metric data.frame 'metric' column name metric values per planning unit. targetsDF data.framewith list features \"feature\" column corresponding targets \"target\" column direction direction = 1, metric values low (least climate-smart) high (climate-smart). direction = -1, metric values high (least climate-smart) low (climate-smart). percentile cut-threshold determining whether area climate priority area (e.g., lower 35th percentile warming upper 65th percentile acidification). Note percentile lower limit threshold.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_climate_percentileApproach.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Function to run the percentile approach — splnr_climate_percentileApproach","text":"list two components: 1. data frame passed prioritizr creating conservation problem containing binary information per planning unit per feature. 2. targets features conservation problem CPA approach used.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_climate_percentileApproach.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Function to run the percentile approach — splnr_climate_percentileApproach","text":"","code":"Features <- dat_species_bin target <- Features %>% sf::st_drop_geometry() %>% colnames() %>% data.frame() %>% setNames(c(\"feature\")) %>% dplyr::mutate(target = 0.3) metric_df <- dat_clim Percentile_Approach <- splnr_climate_percentileApproach( featuresDF = dat_species_bin, metricDF = metric_df, targetsDF = target, direction = 1 ) #> [1] \"Higher values mean more climate-smart areas.\" out_sf <- Percentile_Approach$Features targets <- Percentile_Approach$Targets"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_climate_priorityAreaApproach.html","id":null,"dir":"Reference","previous_headings":"","what":"Function to run the climate-priority-area approach — splnr_climate_priorityAreaApproach","title":"Function to run the climate-priority-area approach — splnr_climate_priorityAreaApproach","text":"Function run climate-priority-area approach","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_climate_priorityAreaApproach.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Function to run the climate-priority-area approach — splnr_climate_priorityAreaApproach","text":"","code":"splnr_climate_priorityAreaApproach( featuresDF, metricDF, targetsDF, direction, percentile = 5, refugiaTarget = 1 )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_climate_priorityAreaApproach.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Function to run the climate-priority-area approach — splnr_climate_priorityAreaApproach","text":"featuresDF feature sfobject metricDF climate metric data.frame 'metric' column name metric values per planning unit. targetsDF data.framewith list features \"feature\" column corresponding targets \"target\" column direction direction = 1, metric values low (least climate-smart) high (climate-smart). direction = -1, metric values high (least climate-smart) low (climate-smart). percentile cut-threshold determining whether area climate priority area (e.g., lower 35th percentile warming upper 65th percentile acidification). Note percentile lower limit threshold. refugiaTarget target assigned climate-smart areas","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_climate_priorityAreaApproach.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Function to run the climate-priority-area approach — splnr_climate_priorityAreaApproach","text":"list two components: 1. data frame passed prioritizr creating conservation problem containing binary information per planning unit per feature. 2. targets features conservation problem CPA approach used.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_climate_priorityAreaApproach.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Function to run the climate-priority-area approach — splnr_climate_priorityAreaApproach","text":"","code":"Features <- dat_species_bin target <- Features %>% sf::st_drop_geometry() %>% colnames() %>% data.frame() %>% setNames(c(\"feature\")) %>% dplyr::mutate(target = 0.3) metric_df <- dat_clim CPA_Approach <- splnr_climate_priorityAreaApproach( featuresDF = dat_species_bin, metricDF = metric_df, targetsDF = target, direction = -1 ) out_sf <- CPA_Approach$Features targets <- CPA_Approach$Targets"},{"path":[]},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_convert_regionalisation.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Function to interpolate regionalisation data onto Planning Units — splnr_convert_regionalisation","text":"","code":"splnr_convert_regionalisation(dat, PUs, cat_name = NA, col_name = NA)"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_convert_regionalisation.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Function to interpolate regionalisation data onto Planning Units — splnr_convert_regionalisation","text":"dat Dataset raster sf format. PUs sf object Planning Units cat_name character string categories regionalisation col_name name layer","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_convert_regionalisation.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Function to interpolate regionalisation data onto Planning Units — splnr_convert_regionalisation","text":"sf object containing Planning Units feature.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_convert_regionalisation.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Function to interpolate regionalisation data onto Planning Units — splnr_convert_regionalisation","text":"wrapper splnr_Convert2PUs() deals need processes layer seperately dataset needs raster vector format. input contains continuous data, output area-averaged mean planning unit. input binary, output proportion planning unit covered.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_convert_regionalisation.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Function to interpolate regionalisation data onto Planning Units — splnr_convert_regionalisation","text":"","code":"if (FALSE) { # \\dontrun{ df <- splnr_convert_regionalisation(dat, PUs) } # }"},{"path":[]},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_convert_toPUs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Function to interpolate data onto Planning Units — splnr_convert_toPUs","text":"","code":"splnr_convert_toPUs(dat, PlanUnits)"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_convert_toPUs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Function to interpolate data onto Planning Units — splnr_convert_toPUs","text":"dat Dataset filename dataset PlanUnits sf object Planning Units","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_convert_toPUs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Function to interpolate data onto Planning Units — splnr_convert_toPUs","text":"sf object containing Planning Units feature.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_convert_toPUs.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Function to interpolate data onto Planning Units — splnr_convert_toPUs","text":"dataset needs raster vector format. input contains continuous data, output area-averaged mean planning unit. input binary, output proportion planning unit covered.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_convert_toPUs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Function to interpolate data onto Planning Units — splnr_convert_toPUs","text":"","code":"if (FALSE) { # \\dontrun{ df <- splnr_convert_toPUs(dat, PlanUnits) } # }"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_create_polygon.html","id":null,"dir":"Reference","previous_headings":"","what":"Function for creating polygon — splnr_create_polygon","title":"Function for creating polygon — splnr_create_polygon","text":"splnr_create_polygon() allows create polygon based longitude latitude coordinates input data.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_create_polygon.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Function for creating polygon — splnr_create_polygon","text":"","code":"splnr_create_polygon(x, cCRS = \"EPSG:4326\")"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_create_polygon.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Function for creating polygon — splnr_create_polygon","text":"x named vector lon/lat coordinates make sf polygon cCRS CRS use polygon","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_create_polygon.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Function for creating polygon — splnr_create_polygon","text":"sf object polygon","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_create_polygon.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Function for creating polygon — splnr_create_polygon","text":"","code":"splnr_create_polygon(x = dplyr::tibble(x = seq(-50, 50, by = 1), y = 120) %>% dplyr::bind_rows(dplyr::tibble(x = 50, y = seq(120, 180, by = 1))) %>% dplyr::bind_rows(dplyr::tibble(x = seq(50, -50, by = -1), y = 180)) %>% dplyr::bind_rows(dplyr::tibble(x = -50, y = seq(150, 120, by = -1))))"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_featureNames.html","id":null,"dir":"Reference","previous_headings":"","what":"Returns the feature names — splnr_featureNames","title":"Returns the feature names — splnr_featureNames","text":"splnr_featureNames() allows extract names features want pass prioritizr prioritization. requires sf object input returns column names object excluding columns specify exclude argument.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_featureNames.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Returns the feature names — splnr_featureNames","text":"","code":"splnr_featureNames(dat, exclude = NA)"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_featureNames.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Returns the feature names — splnr_featureNames","text":"dat sf dataframe features exclude Character vector columns exclude","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_featureNames.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Returns the feature names — splnr_featureNames","text":"character vector names","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_featureNames.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Returns the feature names — splnr_featureNames","text":"","code":"df <- dat_species_prob %>% splnr_featureNames()"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_IUCNRedList.html","id":null,"dir":"Reference","previous_headings":"","what":"Match Species to IUCN RedList — splnr_get_IUCNRedList","title":"Match Species to IUCN RedList — splnr_get_IUCNRedList","text":"First need API key, alphanumeric string provided IUCN need send every request; following function takes website, need fill form (might take 1-2 days receive key) rl_use_iucn() receive email API key, set environmental variable (MUST named IUCN_REDLIST_KEY) need re-step everytime restart R Sys.setenv(IUCN_REDLIST_KEY = \"\") add IUCN_REDLIST_KEY = \"\" .Renviron file permanently set Sys.getenv(\"IUCN_REDLIST_KEY\") #' check Evaluated DD: Data Deficient LC: Least Concern NT: Near Threatened VU: Vulnerable EN: Endangered CR: Critically Endangered EW: Extinct Wild EX: Extinct LRlc: Low risk – least concern LRnt: Low risk – near threatened LRcd: Low risk - conservation dependent Categories care cate <- c(\"EX\",\"EW\",\"CR\",\"EN\",\"VU\")","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_IUCNRedList.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Match Species to IUCN RedList — splnr_get_IUCNRedList","text":"","code":"splnr_get_IUCNRedList(df, species_col = \"Species\")"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_IUCNRedList.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Match Species to IUCN RedList — splnr_get_IUCNRedList","text":"df dataframe containing species matched IUCN redlist species_col string name column containting species name","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_IUCNRedList.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Match Species to IUCN RedList — splnr_get_IUCNRedList","text":"dataframe additional column IUCN_Category","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_IUCNRedList.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Match Species to IUCN RedList — splnr_get_IUCNRedList","text":"","code":"if (FALSE) { # \\dontrun{ df <- data.frame(Species = c(\"Diomedea exulans\", \"Hippocampus kuda\", \"Squatina squatina\")) %>% splnr_get_IUCNRedList() } # }"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_MPAs.html","id":null,"dir":"Reference","previous_headings":"","what":"Get marine parks from the WDPA. — splnr_get_MPAs","title":"Get marine parks from the WDPA. — splnr_get_MPAs","text":"code wrapper wonderful wdpar package written Jeffrey O. Hanson. data interfaced planning units. sf object returned PU area covered selected marine protected areas.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_MPAs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get marine parks from the WDPA. — splnr_get_MPAs","text":"","code":"splnr_get_MPAs( PlanUnits, Countries, Status = c(\"Designated\", \"Established\", \"Inscribed\"), Desig = c(\"National\", \"Regional\", \"International\", \"Not Applicable\"), Category = c(\"Ia\", \"Ib\", \"II\", \"III\", \"IV\"), ... )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_MPAs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get marine parks from the WDPA. — splnr_get_MPAs","text":"PlanUnits Planning Units sf object Countries character vector countries extract MPAs. get MPAs, use \"global\" . Status status field WDPA provides information whether protected area established, designated, proposed time data submitted. Desig designation type category type protected area legally/officially designated proposed. Category Stores IUCN Protected Area Management Categories (recorded field IUCN_CAT) protected areas categories reported ... arguments passed wdpa_fetch()","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_MPAs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get marine parks from the WDPA. — splnr_get_MPAs","text":"sf object MPAs intersected planning units","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_MPAs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get marine parks from the WDPA. — splnr_get_MPAs","text":"","code":"dat <- splnr_get_MPAs(PlanUnits = dat_PUs, Countries = \"Australia\") #> ! importing local data (version Apr 2024); use \"force=TRUE\" if you need latest version. #> Linking to GEOS 3.13.0, GDAL 3.9.3, PROJ 9.5.0; sf_use_s2() is TRUE #> Warning: attribute variables are assumed to be spatially constant throughout all geometries #> Warning: attribute variables are assumed to be spatially constant throughout all geometries aust <- rnaturalearth::ne_countries(country = \"Australia\", returnclass = \"sf\") gg <- ggplot2::ggplot() + ggplot2::geom_sf(data = dat, ggplot2::aes(fill = wdpa)) + ggplot2::geom_sf(data = aust, fill = \"grey50\")"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_boundary.html","id":null,"dir":"Reference","previous_headings":"","what":"Get the boundary of the planning region. — splnr_get_boundary","title":"Get the boundary of the planning region. — splnr_get_boundary","text":"splnr_get_boundary() allows create sf object planning region either based specific coordinate information, rnaturalearth inputs ocean data. Creating boundary often first step conservation planning requirement downstream function sin spatialplanr.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_boundary.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get the boundary of the planning region. — splnr_get_boundary","text":"","code":"splnr_get_boundary(Limits, Type = NULL, res = 1, cCRS = \"ESRI:54009\")"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_boundary.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get the boundary of the planning region. — splnr_get_boundary","text":"Limits limits boundary. can either 4 element numeric named vector (c(xmin = 150, xmax = 160, ymin = -40, ymax = -30)), vector ocean/sea names, vector EEZs., Type type Limits provided. Options \"Ocean\" \"EEZ\". (required numeric \"Global\" limits provided) res resolution (degrees) create boundary polygon numeric limits provided. cCRS CRS boundary returned ","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_boundary.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get the boundary of the planning region. — splnr_get_boundary","text":"boundary planning region","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_boundary.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get the boundary of the planning region. — splnr_get_boundary","text":"","code":"Bndry <- splnr_get_boundary(Limits = \"North Atlantic Ocean\", Type = \"Ocean\") #> Reading layer `ne_10m_geography_marine_polys' from data source #> `/private/var/folders/_r/mcmw_qtn0m7cd23cbdqfszl40000gp/T/RtmpUmnXWF/ne_10m_geography_marine_polys.shp' #> using driver `ESRI Shapefile' #> Simple feature collection with 306 features and 37 fields #> Geometry type: MULTIPOLYGON #> Dimension: XY #> Bounding box: xmin: -180 ymin: -85.19206 xmax: 179.9999 ymax: 90 #> Geodetic CRS: WGS 84 Bndry <- splnr_get_boundary(Limits = \"Global\") Bndry <- splnr_get_boundary(Limits = c(\"xmin\" = 150, \"xmax\" = 170, \"ymin\" = -40, \"ymax\" = -20))"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_distCoast.html","id":null,"dir":"Reference","previous_headings":"","what":"Function to compute distances to nearest coastline for each centroid of each planning unit in the 'sf' object provided. — splnr_get_distCoast","title":"Function to compute distances to nearest coastline for each centroid of each planning unit in the 'sf' object provided. — splnr_get_distCoast","text":"code takes sf object return updated new coastDistance column. output inherits crs sf object ensure correct projection needs","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_distCoast.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Function to compute distances to nearest coastline for each centroid of each planning unit in the 'sf' object provided. — splnr_get_distCoast","text":"","code":"splnr_get_distCoast(dat_sf, custom_coast = NULL, res = NULL)"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_distCoast.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Function to compute distances to nearest coastline for each centroid of each planning unit in the 'sf' object provided. — splnr_get_distCoast","text":"dat_sf sf object. custom_coast sf coastline object (optional) res Allow user choose resolution (small, medium, large) rnaturalearth data used coastline.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_distCoast.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Function to compute distances to nearest coastline for each centroid of each planning unit in the 'sf' object provided. — splnr_get_distCoast","text":"sf object distances nearest coast","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_distCoast.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Function to compute distances to nearest coastline for each centroid of each planning unit in the 'sf' object provided. — splnr_get_distCoast","text":"Written Kristine Buenafe Written: March/April 2023 Modified Kilian Barreiro Updated: December 2023","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_distCoast.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Function to compute distances to nearest coastline for each centroid of each planning unit in the 'sf' object provided. — splnr_get_distCoast","text":"","code":"bbox <- sf::st_bbox(c(xmin = 0, ymin = 0, xmax = 3, ymax = 3)) grid <- sf::st_make_grid(bbox, n = c(3, 3), what = \"polygons\") grid <- sf::st_sf(geometry = grid) %>% sf::st_set_crs(\"EPSG:4326\") splnr_get_distCoast(grid) #> Simple feature collection with 9 features and 1 field #> Geometry type: POLYGON #> Dimension: XY #> Bounding box: xmin: 0 ymin: 0 xmax: 3 ymax: 3 #> Geodetic CRS: WGS 84 #> geometry coastDistance_km #> 1 POLYGON ((0 0, 1 0, 1 1, 0 ... 544.9762 #> 2 POLYGON ((1 0, 2 0, 2 1, 1 ... 553.2552 #> 3 POLYGON ((2 0, 3 0, 3 1, 2 ... 442.2715 #> 4 POLYGON ((0 1, 1 1, 1 2, 0 ... 438.7047 #> 5 POLYGON ((1 1, 2 1, 2 2, 1 ... 480.9762 #> 6 POLYGON ((2 1, 3 1, 3 2, 2 ... 462.5574 #> 7 POLYGON ((0 2, 1 2, 1 3, 0 ... 335.6332 #> 8 POLYGON ((1 2, 2 2, 2 3, 1 ... 371.9517 #> 9 POLYGON ((2 2, 3 2, 3 3, 2 ... 406.2456 cCRS <- \"ESRI:54009\" Bndry <- splnr_get_boundary(Limits = \"Coral Sea\", Type = \"Oceans\", cCRS = cCRS) #> Reading layer `ne_10m_geography_marine_polys' from data source #> `/private/var/folders/_r/mcmw_qtn0m7cd23cbdqfszl40000gp/T/RtmpUmnXWF/ne_10m_geography_marine_polys.shp' #> using driver `ESRI Shapefile' #> Simple feature collection with 306 features and 37 fields #> Geometry type: MULTIPOLYGON #> Dimension: XY #> Bounding box: xmin: -180 ymin: -85.19206 xmax: 179.9999 ymax: 90 #> Geodetic CRS: WGS 84 landmass <- rnaturalearth::ne_countries( scale = \"medium\", returnclass = \"sf\" ) %>% sf::st_transform(cCRS)"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_featureRep.html","id":null,"dir":"Reference","previous_headings":"","what":"Prepare data to plot how well targets are met — splnr_get_featureRep","title":"Prepare data to plot how well targets are met — splnr_get_featureRep","text":"Prepare data plot well targets met","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_featureRep.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Prepare data to plot how well targets are met — splnr_get_featureRep","text":"","code":"splnr_get_featureRep( soln, pDat, targetsDF = NA, climsmart = FALSE, climsmartApproach = 0, solnCol = \"solution_1\" )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_featureRep.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Prepare data to plot how well targets are met — splnr_get_featureRep","text":"soln prioritizr solution pDat prioritizr problem targetsDF data.framewith list features \"feature\" column corresponding targets \"target\" column climsmart logical denoting whether spatial planning done climate-smart (targets calculated differently) climsmartApproach either 0,1,2 3 depending climate-smart approach used (0 = None; 1 = Climate Priority Area; 2 = Feature; 3 = Percentile). solnCol Name column solution","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_featureRep.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Prepare data to plot how well targets are met — splnr_get_featureRep","text":"tbl_df dataframe","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_featureRep.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Prepare data to plot how well targets are met — splnr_get_featureRep","text":"","code":"pDat <- prioritizr::problem(dat_species_bin %>% dplyr::mutate(Cost = runif(n = dim(.)[[1]])), features = c(\"Spp1\", \"Spp2\", \"Spp3\"), cost_column = \"Cost\" ) %>% prioritizr::add_min_set_objective() %>% prioritizr::add_relative_targets(0.3) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(verbose = FALSE) soln <- pDat %>% prioritizr::solve.ConservationProblem() df <- splnr_get_featureRep( soln = soln, pDat = pDat )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_gfw.html","id":null,"dir":"Reference","previous_headings":"","what":"The get_gfwData function recover the data of Global Fishing Watch and returns it as a sf object. — splnr_get_gfw","title":"The get_gfwData function recover the data of Global Fishing Watch and returns it as a sf object. — splnr_get_gfw","text":"possibilities offered function explained vignette(\"GlobalFishingWatch\")","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_gfw.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"The get_gfwData function recover the data of Global Fishing Watch and returns it as a sf object. — splnr_get_gfw","text":"","code":"splnr_get_gfw( region, start_date, end_date, temp_res, spat_res = \"LOW\", region_source = \"EEZ\", key = gfwr::gfw_auth(), cCRS = \"EPSG:4326\", compress = FALSE )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_gfw.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"The get_gfwData function recover the data of Global Fishing Watch and returns it as a sf object. — splnr_get_gfw","text":"region Region studied (character) geojson shape filter raster start_date Start date (waited format : \"%Y-%m-%d\"). end_date End date (waited format : \"%Y-%m-%d\"). temp_res Temporal resolution (\"daily\",\"monthly\",\"yearly\"). spat_res Spatial resolution (\"low\" 0.1 degree, \"high\" 0.01 degree). region_source source region ('eez','mpa', 'rfmo' 'user_json') key Token GFW API (see details GlobalFishingWatch vignette). cCRS crs sf returned (default = \"EPSG:4326\"). compress Binary operator compress (aggregate) data per coordinates (default = FALSE).","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_gfw.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"The get_gfwData function recover the data of Global Fishing Watch and returns it as a sf object. — splnr_get_gfw","text":"sf object gfw data.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_gfw.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"The get_gfwData function recover the data of Global Fishing Watch and returns it as a sf object. — splnr_get_gfw","text":"parameters get_raster function, plus cCRS crs sf_modification Different possible values can combined : Time Range, Flag, Geartype. (combination can : c('Time Range','Geartype'), want get sum fishing hours per date geartype, example want display drifting longline fishing specific year) Notes : moment limited EEZs region, can potentially restrict working area specific MPAs. Days indicated the__ start_date end_date __variables included data recovery. code takes several parameters described return sf object gfw data aggregated (param compress)","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_gfw.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"The get_gfwData function recover the data of Global Fishing Watch and returns it as a sf object. — splnr_get_gfw","text":"","code":"if (FALSE) { # \\dontrun{ gfw_data <- splnr_get_gfw('Australia', \"2021-01-01\", \"2022-12-31\", \"YEARLY\", cCRS = \"ESRI:54009\", compress = TRUE) } # }"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_kappaCorrData.html","id":null,"dir":"Reference","previous_headings":"","what":"Prepare data to plot Cohen's Kappa correlation matrix — splnr_get_kappaCorrData","title":"Prepare data to plot Cohen's Kappa correlation matrix — splnr_get_kappaCorrData","text":"Conservation planning often requires comparison outputs solutions different conservation problems. One way compare solutions correlating solutions using Cohen's Kappa. splnr_get_kappaCorrData() takes list prioritizr solutions perform Cohen's Kappa correlation solution. resulting correlation matrix symmetrical along main diagonal contains Cohen's Kappa pairwise correlation solutions. main diagonal always 1. correlation matrix obtained function can passed onto splnr_plot_corrMat().","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_kappaCorrData.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Prepare data to plot Cohen's Kappa correlation matrix — splnr_get_kappaCorrData","text":"","code":"splnr_get_kappaCorrData(sol, name_sol)"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_kappaCorrData.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Prepare data to plot Cohen's Kappa correlation matrix — splnr_get_kappaCorrData","text":"sol List prioritizr solutions (sf objects) solutions column name solution_1 name_sol Name tags different solutions","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_kappaCorrData.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Prepare data to plot Cohen's Kappa correlation matrix — splnr_get_kappaCorrData","text":"matrixOut matrix","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_kappaCorrData.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Prepare data to plot Cohen's Kappa correlation matrix — splnr_get_kappaCorrData","text":"","code":"# 30 % target for problem/solution 1 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() # 50 % target for problem/solution 2 dat_problem2 <- 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.5) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(verbose = FALSE) dat_soln2 <- dat_problem2 %>% prioritizr::solve.ConservationProblem() corrMat <- splnr_get_kappaCorrData(list(dat_soln, dat_soln2), name_sol = c(\"soln1\", \"soln2\")) #> New names: #> • `soln1` -> `soln1...1` #> • `soln1` -> `soln1...2` #> New names: #> • `soln2` -> `soln2...1` #> • `soln2` -> `soln2...2` #> New names: #> • `` -> `...1` #> • `` -> `...2`"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_selFreq.html","id":null,"dir":"Reference","previous_headings":"","what":"Prepare data to plot Selection Frequency of planning units — splnr_get_selFreq","title":"Prepare data to plot Selection Frequency of planning units — splnr_get_selFreq","text":"multiple spatial plans generated, often interested many times planning unit selected across array solutions. array can either list solutions different conservation problems generated portfolio approach prioritizr. splnr_get_selFreq() allows calculate selection frequency planning unit either list portfolio solutions. resulting sf object can passed visualization spatialplanr function splnr_plot_selectionFreq().","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_selFreq.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Prepare data to plot Selection Frequency of planning units — splnr_get_selFreq","text":"","code":"splnr_get_selFreq(solnMany, type = \"portfolio\")"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_selFreq.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Prepare data to plot Selection Frequency of planning units — splnr_get_selFreq","text":"solnMany List portfolio prioritizr solutions type Either \"portfolio\" (sf object) portfolio produced using prioritizr \"list\" list solutions","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_selFreq.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Prepare data to plot Selection Frequency of planning units — splnr_get_selFreq","text":"selFreq sf object containing column selection frequency (sum solutions).","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_get_selFreq.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Prepare data to plot Selection Frequency of planning units — splnr_get_selFreq","text":"","code":"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() # create conservation problem that contains a portfolio of solutions dat_soln_portfolio <- dat_problem %>% prioritizr::add_cuts_portfolio(number_solutions = 5) %>% prioritizr::solve.ConservationProblem() selFreq <- splnr_get_selFreq(solnMany = dat_soln_portfolio, type = \"portfolio\") (splnr_plot_selectionFreq(selFreq))"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_gg_add.html","id":null,"dir":"Reference","previous_headings":"","what":"Add-ons for plotting — splnr_gg_add","title":"Add-ons for plotting — splnr_gg_add","text":"function allows customise plots simple reproducible way, giving option several inputs can included maps produced functions package.can combined spatialplanr spatial plotting functions.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_gg_add.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add-ons for plotting — splnr_gg_add","text":"","code":"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\" )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_gg_add.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add-ons for plotting — splnr_gg_add","text":"PUs Planning Units sf object colorPUs color value outline planning units. Bndry planning region boundaries sf object colorBndry color value outline boundary. overlay sf object overlay polygon. colorOverlay color value overlay. overlay2 sf object overlay polygon. colorOverlay2 color value overlay. overlay3 sf object overlay polygon. colorOverlay3 color value overlay. contours sf object contours important visualise (e.g. outline sea mounts, ridges; can produced terra::.contour()); 6 different contours possible. colorConts color value contours. cropOverlay sf object boundary box used cropping overlay object. lockIn sf object binary data locked areas prioritisation (e.g. MPAs). typeLockIn Either \"Full\" \"Contours\"; \"Full\" maps locked areas top planning units; \"Contours\" draws outline locked areas. nameLockIn column data frame contains binary information locked areas plot alphaLockIn value (0-1) opacity locked areas plotted top plots. colorLockIn color value locked areas. legendLockIn character value title legend locked areas. Can empty (\"\"). labelLockIn legend label locked area (e.g. MPAs) ggtheme theme applied plot. Can either NA (default ggplot), \"Default\" (default spatialplanr: theme_bw() basic theme settings) user-defined list theme properties.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_gg_add.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add-ons for plotting — splnr_gg_add","text":"ggplot object plot","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_gg_add.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add-ons for plotting — splnr_gg_add","text":"","code":"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."},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_match_names.html","id":null,"dir":"Reference","previous_headings":"","what":"Substitute numbers for all_names in regionalisations — splnr_match_names","title":"Substitute numbers for all_names in regionalisations — splnr_match_names","text":"Many regionalisations numeric values shape files correspond vector names. provide function quickly replace numbers names.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_match_names.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Substitute numbers for all_names in regionalisations — splnr_match_names","text":"","code":"splnr_match_names(dat, nam)"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_match_names.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Substitute numbers for all_names in regionalisations — splnr_match_names","text":"dat sf data frame one column numeric/integer corresponding nam nam Named character vector names corresponding column dat recode","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_match_names.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Substitute numbers for all_names in regionalisations — splnr_match_names","text":"sf dataframe numeric regionalisations substituted category names","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_match_names.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Substitute numbers for all_names in regionalisations — splnr_match_names","text":"","code":"dat <- dat_region nam <- c(\"Region1\" = \"SE Aust\", \"Region2\" = \"Tas\", \"Region3\" = \"NE Aust\") df <- splnr_match_names(dat, nam)"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot.html","id":null,"dir":"Reference","previous_headings":"","what":"Function to plot data. — splnr_plot","title":"Function to plot data. — splnr_plot","text":"(now can replace splnr_plot_cost(), splnr_plot_binFeature(), splnr_plot_MPAs(), splnr_plot_featureNo())","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Function to plot data. — splnr_plot","text":"","code":"splnr_plot( df, col_names = NULL, paletteName = \"YlGnBu\", colourVals = c(\"#c6dbef\", \"#3182bd\"), plot_title = \"\", legend_title = NULL, legend_labels = NULL )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Function to plot data. — splnr_plot","text":"df dataframe containing data plotted. must include geometry column used geom_sf. col_names list column names include plot. specified, columns used colour plot. paletteName name colour palette use filling. Default \"YlGnBu\". colourVals colour values use col_names specified data binary. plot_title title plot. legend_title title legend. legend_labels vector strings containing labels use legend values.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Function to plot data. — splnr_plot","text":"ggplot object.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Function to plot data. — splnr_plot","text":"Written Kilian Barreiro Jason Everett Written: February 2024","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Function to plot data. — splnr_plot","text":"","code":"# Binary plot of species distribution splnr_plot(df = dat_species_bin, col_names = \"Spp1\", legend_title = \"Legend\", legend_labels = c(\"Absent\", \"Present\")) #> Coordinate system already present. Adding new coordinate system, which will #> replace the existing one. # Logical plot of species distribution splnr_plot(df = dat_species_bin %>% dplyr::mutate(dplyr::across( tidyselect::starts_with(\"Spp\"), as.logical)), col_names = \"Spp1\", legend_title = \"Legend\", legend_labels = c(\"Absent\", \"Present\")) #> Coordinate system already present. Adding new coordinate system, which will #> replace the existing one. # Continuous plot of bathymetry# splnr_plot(df = dat_bathy, col_names = \"bathymetry\", plot_title = \"Bathymetry\", legend_title = \"Bathymetry (m)\") #> Coordinate system already present. Adding new coordinate system, which will #> replace the existing one. # Plot Planning Units splnr_plot(df = dat_PUs) #> Coordinate system already present. Adding new coordinate system, which will #> replace the existing one. # Multi binary features splnr_plot(df = dat_species_bin, col_names = colnames(dat_species_bin %>% sf::st_drop_geometry() %>% dplyr::select( tidyselect::starts_with(\"Spp\"))), legend_title = \"Number of features\") #> Coordinate system already present. Adding new coordinate system, which will #> replace the existing one."},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_MPAs.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot MPAs — splnr_plot_MPAs","title":"Plot MPAs — splnr_plot_MPAs","text":"splnr_plot_MPAs() allows plot either outline area MPAs existing planning region (example extracted spatialplanrfunction splnr_get_MPAs()) customisable way using ggplot2. function requires sf object containing information whether planning unit planning region lies within MPA column called wdpa outputs ggobject. can combined spatialplanr function splnr_gg_add().","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_MPAs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot MPAs — splnr_plot_MPAs","text":"","code":"splnr_plot_MPAs( df, colorVals = c(`TRUE` = \"blue\", `FALSE` = \"white\"), showLegend = TRUE, plotTitle = \"Locked In Areas\", legendTitle = \"\" )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_MPAs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot MPAs — splnr_plot_MPAs","text":"df sf object marine protected areas colorVals list object named vectors match color value according name. \"TRUE\" stands selected planning units. showLegend logical command whether show legend solution (Default: TRUE). plotTitle character value title plot. Can empty (\"\"). legendTitle character value title legend. Can empty (\"\").","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_MPAs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot MPAs — splnr_plot_MPAs","text":"ggplot object plot","code":""},{"path":[]},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_MPAs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot MPAs — splnr_plot_MPAs","text":"","code":"if (FALSE) { # \\dontrun{ splnr_plot_MPAs(dat_mpas) } # }"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_binFeature.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot binary feature — splnr_plot_binFeature","title":"Plot binary feature — splnr_plot_binFeature","text":"splnr_plot_binFeature() allows plot presences absences feature planning region customisable way using ggplot2. function requires sf object binary information feature(0 absences 1 presences, example created continuous data spatialplanr function splnr_apply_cutoffs()). outputs ggobject can combined spatialplanr function splnr_gg_add().","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_binFeature.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot binary feature — splnr_plot_binFeature","text":"","code":"splnr_plot_binFeature( df, colInterest, colorVals = c(Suitable = \"#3182bd\", `Not Suitable` = \"#c6dbef\"), showLegend = TRUE, plotTitle = \" \", legendTitle = \"Habitat\" )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_binFeature.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot binary feature — splnr_plot_binFeature","text":"df data frame binary feature information colInterest column data frame contains binary information feature plot colorVals list object named vectors match color value according name. \"TRUE\" stands selected planning units. showLegend logical command whether show legend solution (Default: TRUE). plotTitle character value title plot. Can empty (\"\"). legendTitle character value title legend. Can empty (\"\").","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_binFeature.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot binary feature — splnr_plot_binFeature","text":"ggplot object plot","code":""},{"path":[]},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_binFeature.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot binary feature — splnr_plot_binFeature","text":"","code":"if (FALSE) { # \\dontrun{ splnr_plot_binFeature(dat_species_bin, dat_species_bin$Spp1) } # }"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_circBplot.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot circular barplot — splnr_plot_circBplot","title":"Plot circular barplot — splnr_plot_circBplot","text":"Plot circular barplot","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_circBplot.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot circular barplot — splnr_plot_circBplot","text":"","code":"splnr_plot_circBplot( df, legend_color, legend_list, indicateTargets = TRUE, impTarget = NA, repTarget = NA, colTarget = \"red\" )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_circBplot.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot circular barplot — splnr_plot_circBplot","text":"df data frame following column names: feature, value, group legend_color vector list colors; group names corresponding colors legend_list list groups/legends groups indicateTargets logical whether show targets set impTarget target important features (%) repTarget target representative features (%) colTarget string colour value indicator line","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_circBplot.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot circular barplot — splnr_plot_circBplot","text":"ggplot object plot","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_circBplot.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot circular barplot — splnr_plot_circBplot","text":"","code":"# DISCLAIMER: THIS SOLUTION IS NOT ACTUALLY RUN WITH THESE TARGETS YET 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() s1 <- dat_soln %>% tibble::as_tibble() p1 <- dat_problem df_rep_imp <- prioritizr::eval_feature_representation_summary( p1, s1[, \"solution_1\"] ) %>% dplyr::select(feature, relative_held) %>% dplyr::mutate(relative_held = relative_held * 100) imp_layers <- c(\"Spp1\", \"Spp3\") target <- data.frame(feature = c(\"Spp1\", \"Spp2\", \"Spp3\", \"Spp4\", \"Spp5\")) %>% dplyr::mutate(class = dplyr::if_else(.data$feature %in% imp_layers, \"important\", \"representative\" )) %>% dplyr::mutate(target = dplyr::if_else(class == \"important\", 50 / 100, 30 / 100 )) df <- merge(df_rep_imp, target) %>% dplyr::select(-target) %>% na.omit() %>% dplyr::rename(value = relative_held) %>% dplyr::rename(group = class) colors <- c( \"important\" = \"darkgreen\", \"representative\" = \"darkred\" ) legends <- c(\"Important\", \"Representative\") (splnr_plot_circBplot(df, legend_list = legends, legend_color = colors, impTarget = 50, repTarget = 30 )) #> Warning: Removed 4 rows containing missing values or values outside the scale range #> (`geom_bar()`). #> Warning: Removed 6 rows containing missing values or values outside the scale range #> (`geom_text()`)."},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_climData.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot climate data — splnr_plot_climData","title":"Plot climate data — splnr_plot_climData","text":"Plot climate data","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_climData.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot climate data — splnr_plot_climData","text":"","code":"splnr_plot_climData( df, colInterest, colorMap = \"C\", plotTitle = \" \", legendTitle = \"Climate metric\" )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_climData.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot climate data — splnr_plot_climData","text":"df sf object climate metric information colInterest column data frame contains metric informatin colorMap character string indicating color map use (see https://ggplot2.tidyverse.org/reference/scale_viridis.html options) plotTitle character value title plot. Can empty (\"\"). legendTitle character value title legend. Can empty (\"\").","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_climData.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot climate data — splnr_plot_climData","text":"ggplot object plot","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_climData.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot climate data — splnr_plot_climData","text":"","code":"splnr_plot_climData(df = dat_clim, colInterest = \"metric\")"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_climKernelDensity.html","id":null,"dir":"Reference","previous_headings":"","what":"Kernel Density Plots for climate-smart spatial plans — splnr_plot_climKernelDensity","title":"Kernel Density Plots for climate-smart spatial plans — splnr_plot_climKernelDensity","text":"Kernel Density Plots climate-smart spatial plans","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_climKernelDensity.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Kernel Density Plots for climate-smart spatial plans — splnr_plot_climKernelDensity","text":"","code":"splnr_plot_climKernelDensity( soln, names = NA, type = \"Normal\", colorMap = \"C\", legendTitle = expression(\" °C y\"^\"-1\" * \"\"), xAxisLab = expression(\"Climate warming ( °C y\"^\"-1\" * \")\") )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_climKernelDensity.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Kernel Density Plots for climate-smart spatial plans — splnr_plot_climKernelDensity","text":"soln type \"Publication\": list prioirtizr solutions (e.g. solution_list = list(s1, s2)) containing \"metric\" column containing used climate metric information; type \"App\": needs prioritizr solution names list names solutions (names = c(\"Input 1\", \"Input 2\")) type plotting style kernel density plots. Either \"Publication\" gives axis information etc., \"App\" condenses information plot simplify stakeholders. colorMap character string indicating color map use (see https://ggplot2.tidyverse.org/reference/scale_viridis.html options) legendTitle character value title legend. Can empty (\"\"). xAxisLab characted value x Axis label depending climate metric input","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_climKernelDensity.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Kernel Density Plots for climate-smart spatial plans — splnr_plot_climKernelDensity","text":"ggplot object plot","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_climKernelDensity.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Kernel Density Plots for climate-smart spatial plans — splnr_plot_climKernelDensity","text":"","code":"target <- dat_species_bin %>% 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)) %>% sf::st_join(dat_clim, join = sf::st_equals) usedFeatures <- out_sf %>% sf::st_drop_geometry() %>% dplyr::select(-tidyselect::starts_with(\"Cost_\"), -\"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\")"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_comparison.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot solution comparison — splnr_plot_comparison","title":"Plot solution comparison — splnr_plot_comparison","text":"Conservation planning often requires comparison outputs solutions different conservation problems. One way compare solutions spatially visualising different planning units selected two separate solutions conservation problems. splnr_plot_comparison() allows map differences two solutions customisable way using ggplot2. function requires two separate sf objects containing solution_1 column indicating binary solution (selected vs selected) prioritizr conservation problem. outputs ggobject can combined spatialplanr function splnr_gg_add().","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_comparison.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot solution comparison — splnr_plot_comparison","text":"","code":"splnr_plot_comparison( soln1, soln2, legendTitle = \"Scenario 2 compared to Scenario 1:\" )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_comparison.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot solution comparison — splnr_plot_comparison","text":"soln1 first prioritizr solution soln2 second prioritizr solution legendTitle character value title legend. Can empty (\"\").","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_comparison.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot solution comparison — splnr_plot_comparison","text":"ggplot object plot","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_comparison.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot solution comparison — splnr_plot_comparison","text":"","code":"# 30 % target for problem/solution 1 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() # 50 % target for problem/solution 2 dat_problem2 <- 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.5) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(verbose = FALSE) dat_soln2 <- dat_problem2 %>% prioritizr::solve.ConservationProblem() (splnr_plot_comparison(dat_soln, dat_soln2))"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_corrMat.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot correlation matrices — splnr_plot_corrMat","title":"Plot correlation matrices — splnr_plot_corrMat","text":"Conservation planning often requires comparison outputs solutions different conservation problems. One way compare solutions correlating solutions using Cohen's Kappa. splnr_plot_corrMat() allows visualize correlation matrix different solutions (example produced spatialplanr function splnr_get_kappaCorrData()).","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_corrMat.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot correlation matrices — splnr_plot_corrMat","text":"","code":"splnr_plot_corrMat( x, colourGradient = c(\"#BB4444\", \"#FFFFFF\", \"#4477AA\"), legendTitle = \"Correlation \\ncoefficient\", AxisLabels = NULL, plotTitle = \"\" )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_corrMat.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot correlation matrices — splnr_plot_corrMat","text":"x correlation matrix prioritizr solutions colourGradient list three colour values high positive, high negative correlation legendTitle character value title legend. Can empty (\"\"). AxisLabels list labels solutions correlated (Default: NULL). Length needs match number correlated solutions. plotTitle character value title plot. Can empty (\"\").","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_corrMat.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot correlation matrices — splnr_plot_corrMat","text":"ggplot object plot","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_corrMat.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot correlation matrices — splnr_plot_corrMat","text":"","code":"# 30 % target for problem/solution 1 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() # 50 % target for problem/solution 2 dat_problem2 <- 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.5) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(verbose = FALSE) dat_soln2 <- dat_problem2 %>% prioritizr::solve.ConservationProblem() CorrMat <- splnr_get_kappaCorrData(list(dat_soln, dat_soln2), name_sol = c(\"soln1\", \"soln2\")) #> New names: #> • `soln1` -> `soln1...1` #> • `soln1` -> `soln1...2` #> New names: #> • `soln2` -> `soln2...1` #> • `soln2` -> `soln2...2` #> New names: #> • `` -> `...1` #> • `` -> `...2` (splnr_plot_corrMat(CorrMat, AxisLabels = c(\"Solution 1\", \"Solution 2\"))) #> Scale for fill is already present. #> Adding another scale for fill, which will replace the existing scale. #> Scale for x is already present. #> Adding another scale for x, which will replace the existing scale."},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_cost.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot cost — splnr_plot_cost","title":"Plot cost — splnr_plot_cost","text":"splnr_plot_cost() allows plot cost within planning units planning region customisable way using ggplot2. function requires sf object cost column outputs ggobject. can combined spatialplanr function splnr_gg_add().","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_cost.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot cost — splnr_plot_cost","text":"","code":"splnr_plot_cost( Cost, Cost_name = \"Cost\", legendTitle = \"Cost\", paletteName = \"YlGnBu\", plotTitle = \"\" )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_cost.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot cost — splnr_plot_cost","text":"Cost sf object cost prioritizr Cost_name Name cost column legendTitle character value title legend. Can empty (\"\"). paletteName string (number) color palette use. Available palettes can found https://ggplot2.tidyverse.org/reference/scale_brewer.html. plotTitle character value title plot. Can empty (\"\").","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_cost.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot cost — splnr_plot_cost","text":"ggplot object plot","code":""},{"path":[]},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_cost.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot cost — splnr_plot_cost","text":"","code":"if (FALSE) { # \\dontrun{ 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() dat_cost <- dat_soln %>% dplyr::mutate(Cost = runif(n = dim(.)[[1]])) (splnr_plot_cost(dat_cost)) } # }"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_costOverlay.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot cost overlay — splnr_plot_costOverlay","title":"Plot cost overlay — splnr_plot_costOverlay","text":"splnr_plot_costOverlay() allows plot cost planning units planning region top solution conservation problem created prioritizr customisable way using ggplot2. function requires solution sf object column called solution_1 well cost column outputs ggobject. can combined spatialplanr function splnr_gg_add().","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_costOverlay.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot cost overlay — splnr_plot_costOverlay","text":"","code":"splnr_plot_costOverlay( soln, Cost = NA, Cost_name = \"Cost\", legendTitle = \"Cost\", plotTitle = \"Solution overlaid with cost\" )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_costOverlay.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot cost overlay — splnr_plot_costOverlay","text":"soln prioritizr solution Cost sf object cost prioritizr.case prioritizrsolution contain cost, alternative cost object provided used generate solution (default: NA). Cost_name Name cost column legendTitle character value title legend. Can empty (\"\"). plotTitle character value title plot. Can empty (\"\").","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_costOverlay.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot cost overlay — splnr_plot_costOverlay","text":"ggplot object plot","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_costOverlay.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot cost overlay — splnr_plot_costOverlay","text":"","code":"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_costOverlay(soln = dat_soln)"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_featureNo.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot number of features — splnr_plot_featureNo","title":"Plot number of features — splnr_plot_featureNo","text":"splnr_plot_featureNo() allows use ggplot2 visually inspect number features per planning unit used inputs conservation problem. features species, map can seen visualisation species richness planning region.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_featureNo.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot number of features — splnr_plot_featureNo","text":"","code":"splnr_plot_featureNo( df, showLegend = TRUE, paletteName = \"YlGnBu\", plotTitle = \"Number of Features\", legendTitle = \"Features\" )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_featureNo.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot number of features — splnr_plot_featureNo","text":"df sf object features showLegend logical command whether show legend solution (Default: TRUE). paletteName string (number) color palette use. Available palettes can found https://ggplot2.tidyverse.org/reference/scale_brewer.html. plotTitle character value title plot. Can empty (\"\"). legendTitle character value title legend. Can empty (\"\").","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_featureNo.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot number of features — splnr_plot_featureNo","text":"ggplot object plot","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_featureNo.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Plot number of features — splnr_plot_featureNo","text":"function requires sf object binary information features want include richness plot (0 absences 1 presences, example created continuous data spatialplanr function splnr_apply_cutoffs()). outputs ggobject can combined spatialplanr function splnr_gg_add().","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_featureNo.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot number of features — splnr_plot_featureNo","text":"","code":"if (FALSE) { # \\dontrun{ (splnr_plot_featureNo(dat_species_bin)) } # }"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_featureRep.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot how well targets are met — splnr_plot_featureRep","title":"Plot how well targets are met — splnr_plot_featureRep","text":"Plot well targets met","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_featureRep.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot how well targets are met — splnr_plot_featureRep","text":"","code":"splnr_plot_featureRep( df, category = NA, categoryFeatureCol = NA, renameFeatures = FALSE, namesToReplace = NA, nr = 1, showTarget = NA, plotTitle = \"\", ... )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_featureRep.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot how well targets are met — splnr_plot_featureRep","text":"df df containing target information (resulting splnr_get_featureRep() function) category named data frame feature category grouping plot output categoryFeatureCol character column containing feature infromation plotted category data frame contain column named 'feature' can matched 'df' infromation. renameFeatures logical whether variable names used replaced common names namesToReplace data frame containing variable name ('nameVariable') common name ('nameCommon'). nr Number rows legend showTarget logical targets shown bar plot plotTitle character value title plot. Can empty (\"\"). ... arguments passed ggplot2::theme()","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_featureRep.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot how well targets are met — splnr_plot_featureRep","text":"ggplot object plot","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_featureRep.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot how well targets are met — splnr_plot_featureRep","text":"","code":"pDat <- 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) soln <- pDat %>% prioritizr::solve.ConservationProblem() # including incidental species coverage df <- splnr_get_featureRep( soln = soln, pDat = pDat ) (splnr_plot_featureRep(df, category = dat_category))"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_importanceScore.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot importance score — splnr_plot_importanceScore","title":"Plot importance score — splnr_plot_importanceScore","text":"Importance scores mean reflect irreplaceability planning unit solution prioirtizr conservation problem. Based prioritizr package, splnr_plot_importanceScore() allows visualize three different types importance scores ggplot2 used based conservation problem hand. prioritizr development team generally recommend using replacement cost score, however might feasible conservation problems many planning units features.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_importanceScore.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot importance score — splnr_plot_importanceScore","text":"","code":"splnr_plot_importanceScore( soln, pDat, method = \"Ferrier\", plotTitle = \"\", colorMap = \"A\", decimals = 4, legendTitle = \"Importance Score\" )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_importanceScore.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot importance score — splnr_plot_importanceScore","text":"soln prioritizr solution pDat prioritizr problem method method calcualting importance scores. Can either \"Ferrier\" Ferrier Score, can used minimum set objective function, \"RWR\" Rarity Weighted Richness Score, \"RC\" Replacement Cost takes longer approaches due iterative process. plotTitle character value title plot. Can empty (\"\"). colorMap character string indicating color map use (see https://ggplot2.tidyverse.org/reference/scale_viridis.html options) decimals number decimals shown plot. Ferrier Score often requires higher number decimals (>4) two approaches (2) analysis work. legendTitle character value title legend. Can empty (\"\").","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_importanceScore.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot importance score — splnr_plot_importanceScore","text":"ggplot object plot","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_importanceScore.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Plot importance score — splnr_plot_importanceScore","text":"function outputs ggobject can combined spatialplanr function splnr_gg_add().","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_importanceScore.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot importance score — splnr_plot_importanceScore","text":"","code":"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_importanceScore(soln = dat_soln, pDat = dat_problem, method = \"Ferrier\", decimals = 4)) #> Ferrier Score."},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_selectionFreq.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot selection frequency of a planning unit in an array of prioritisations — splnr_plot_selectionFreq","title":"Plot selection frequency of a planning unit in an array of prioritisations — splnr_plot_selectionFreq","text":"multiple spatial plans generated, often interested many times planning unit selected across array solutions. array can either made solutions different conservation problems generated portfolio approach prioritizr. Either way, function requires sf object input contains column (selFreq) selection frequency planning unit can generated spatialplanrfunction splnr_get_selFreq(). splnr_plot_selectionFreq() allows visualize selection frequency using ggplot2. outputs ggobject can combined spatialplanr function splnr_gg_add().","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_selectionFreq.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot selection frequency of a planning unit in an array of prioritisations — splnr_plot_selectionFreq","text":"","code":"splnr_plot_selectionFreq( selFreq, plotTitle = \"\", paletteName = \"Greens\", legendTitle = \"Selection \\nFrequency\" )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_selectionFreq.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot selection frequency of a planning unit in an array of prioritisations — splnr_plot_selectionFreq","text":"selFreq sf object containing selection frequency planning unit array solutions plotTitle character value title plot. Can empty (\"\"). paletteName string (number) color palette use. Available palettes can found https://ggplot2.tidyverse.org/reference/scale_brewer.html. legendTitle character value title legend. Can empty (\"\").","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_selectionFreq.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot selection frequency of a planning unit in an array of prioritisations — splnr_plot_selectionFreq","text":"ggplot object plot","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_selectionFreq.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot selection frequency of a planning unit in an array of prioritisations — splnr_plot_selectionFreq","text":"","code":"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) # create conservation problem that contains a portfolio of solutions dat_soln_portfolio <- dat_problem %>% prioritizr::add_cuts_portfolio(number_solutions = 5) %>% prioritizr::solve.ConservationProblem() selFreq <- splnr_get_selFreq(solnMany = dat_soln_portfolio, type = \"portfolio\") (splnr_plot_selectionFreq(selFreq))"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_solution.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot prioritizr solution — splnr_plot_solution","title":"Plot prioritizr solution — splnr_plot_solution","text":"splnr_plot_solution() allows plot solution prioritizr conservation problem without customisable way using ggplot2. function requires solution sf object column called solution_1 outputs ggobject. can combined spatialplanr function splnr_gg_add().","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_solution.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot prioritizr solution — splnr_plot_solution","text":"","code":"splnr_plot_solution( soln, colorVals = c(\"#c6dbef\", \"#3182bd\"), showLegend = TRUE, legendLabels = c(\"Not selected\", \"Selected\"), plotTitle = \"Solution\", legendTitle = \"Planning Units\", zones = FALSE )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_solution.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot prioritizr solution — splnr_plot_solution","text":"soln prioritizr solution colorVals list object named vectors match color value according name. \"TRUE\" stands selected planning units. showLegend logical command whether show legend solution (Default: TRUE). legendLabels Character values (number zones + 1) legend labelled. plotTitle character value title plot. Can empty (\"\"). legendTitle character value title legend. Can empty (\"\"). zones logical value, indicating whether spatial plan contains zones (default = FALSE).","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_solution.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot prioritizr solution — splnr_plot_solution","text":"ggplot object plot","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_plot_solution.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot prioritizr solution — splnr_plot_solution","text":"","code":"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) # example 2 t2 <- matrix(NA, ncol = 2, nrow = 5) # create targets t2[, 1] <- 0.1 t2[, 2] <- 0.05 z2 <- prioritizr::zones( \"zone 1\" = c(\"Spp1\", \"Spp2\", \"Spp3\", \"Spp4\", \"Spp5\"), \"zone 2\" = c(\"Spp1\", \"Spp2\", \"Spp3\", \"Spp4\", \"Spp5\") ) # when giving sf input, we need as many cost columns as we have zones p2 <- prioritizr::problem( dat_species_bin %>% dplyr::mutate( Cost1 = runif(n = dim(.)[[1]]), Cost2 = runif(n = dim(.)[[1]]) ), z2, cost_column = c(\"Cost1\", \"Cost2\") ) %>% prioritizr::add_min_set_objective() %>% prioritizr::add_relative_targets(t2) %>% prioritizr::add_binary_decisions() %>% prioritizr::add_default_solver(verbose = FALSE) s2 <- p2 %>% prioritizr::solve.ConservationProblem() (splnr_plot_solution(s2, zones = TRUE, colorVals = c(\"#c6dbef\", \"#3182bd\", \"black\"), legendLabels = c(\"Not selected\", \"Zone 1\", \"Zone 2\") ))"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_replace_NAs.html","id":null,"dir":"Reference","previous_headings":"","what":"Remove NAs from spatial data using nearest neighbour — splnr_replace_NAs","title":"Remove NAs from spatial data using nearest neighbour — splnr_replace_NAs","text":"splnr_replace_NAs() allows replace NA values data value nearest neighbour. nearest neighbour determined using st_nearest_feature() sf package.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_replace_NAs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Remove NAs from spatial data using nearest neighbour — splnr_replace_NAs","text":"","code":"splnr_replace_NAs(df, vari)"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_replace_NAs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Remove NAs from spatial data using nearest neighbour — splnr_replace_NAs","text":"df sf dataframe vari Variable remove NAs ","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_replace_NAs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Remove NAs from spatial data using nearest neighbour — splnr_replace_NAs","text":"sf object NAs replaced nearest neighbour","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_replace_NAs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Remove NAs from spatial data using nearest neighbour — splnr_replace_NAs","text":"","code":"df <- dat_species_prob %>% splnr_replace_NAs(\"Spp2\")"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_scale_01.html","id":null,"dir":"Reference","previous_headings":"","what":"Scale spatial layers to between 0 and 1 — splnr_scale_01","title":"Scale spatial layers to between 0 and 1 — splnr_scale_01","text":"splnr_scale_01() allows re-scale data values greater 1 values 0 1.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_scale_01.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Scale spatial layers to between 0 and 1 — splnr_scale_01","text":"","code":"splnr_scale_01(dat, col_name)"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_scale_01.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Scale spatial layers to between 0 and 1 — splnr_scale_01","text":"dat sf dataframe col_name Name column scale","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_scale_01.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Scale spatial layers to between 0 and 1 — splnr_scale_01","text":"sf dataframe","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_scale_01.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Scale spatial layers to between 0 and 1 — splnr_scale_01","text":"","code":"df <- dat_species_prob %>% dplyr::mutate(Spp1 = Spp1 * 100) %>% splnr_scale_01(col_name = \"Spp1\")"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_targets_byCategory.html","id":null,"dir":"Reference","previous_headings":"","what":"Assign targets to all features by category — splnr_targets_byCategory","title":"Assign targets to all features by category — splnr_targets_byCategory","text":"splnr_targets_byCategory() allows assign targets conservation planning based species categories.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_targets_byCategory.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Assign targets to all features by category — splnr_targets_byCategory","text":"","code":"splnr_targets_byCategory(dat, catTarg, catName = \"Category\")"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_targets_byCategory.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Assign targets to all features by category — splnr_targets_byCategory","text":"dat sf object features categories catTarg named character vector categories target catName optional argument name category column dat","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_targets_byCategory.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Assign targets to all features by category — splnr_targets_byCategory","text":"sf object targets added","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_targets_byCategory.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Assign targets to all features by category — splnr_targets_byCategory","text":"","code":"dat <- splnr_targets_byCategory( dat = dat_category, catTarg = c(\"Group1\" = 0.5, \"Group2\" = 0.2), catName = \"category\" )"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_targets_byIUCN.html","id":null,"dir":"Reference","previous_headings":"","what":"Assign targets bu IUCN Red List categories — splnr_targets_byIUCN","title":"Assign targets bu IUCN Red List categories — splnr_targets_byIUCN","text":"splnr_targets_byIUCN() allows assign targets species used conservation planning based IUCN categories. Species can extracted based IUCN categories spatoalplnrfunction splnr_get_IUCNRedList(). Accessing IUCN database requires login token rl_use_iucn() needs added environment using Sys.setenv(IUCN_REDLIST_KEY = \"[Token]\"). can start running rredlist::rl_use_iucn().","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_targets_byIUCN.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Assign targets bu IUCN Red List categories — splnr_targets_byIUCN","text":"","code":"splnr_targets_byIUCN(dat, IUCN_target, IUCN_col = \"IUCN_Category\")"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_targets_byIUCN.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Assign targets bu IUCN Red List categories — splnr_targets_byIUCN","text":"dat dataframe sf object IUCN categories IUCN_target Either numeric named numeric targets apply IUCN categories IUCN_col Optional string indicate name column IUCN categories","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_targets_byIUCN.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Assign targets bu IUCN Red List categories — splnr_targets_byIUCN","text":"dataframe sf object","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_targets_byIUCN.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Assign targets bu IUCN Red List categories — splnr_targets_byIUCN","text":"","code":"dat <- data.frame(IUCN_Category = c(\"EW\", \"EX\", NA), target = c(0.3, 0.3, 0.3)) IUCN_target <- c(\"EX\" = 0.8, \"EW\" = 0.6) dat <- splnr_targets_byIUCN(dat, IUCN_target)"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_targets_byInverseArea.html","id":null,"dir":"Reference","previous_headings":"","what":"Assign targets by Inverse Area — splnr_targets_byInverseArea","title":"Assign targets by Inverse Area — splnr_targets_byInverseArea","text":"function takes min (target_min) max (target_max) target range calculates inverse area target feature based areal coverage.","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_targets_byInverseArea.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Assign targets by Inverse Area — splnr_targets_byInverseArea","text":"","code":"splnr_targets_byInverseArea(df, target_min, target_max)"},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_targets_byInverseArea.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Assign targets by Inverse Area — splnr_targets_byInverseArea","text":"df sf dataframe features calculate target_min minimum target inverse area target_max maximum target inverse area","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_targets_byInverseArea.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Assign targets by Inverse Area — splnr_targets_byInverseArea","text":"sf dataframe Inverse Area Targets added Target","code":""},{"path":"https://mathmarecol.github.io/spatialplanr/reference/splnr_targets_byInverseArea.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Assign targets by Inverse Area — splnr_targets_byInverseArea","text":"","code":"targets <- dat_species_prob %>% splnr_targets_byInverseArea(target_min = 0.3, target_max = 0.8)"}] diff --git a/man/CoralSeaVelocity.Rd b/man/CoralSeaVelocity.Rd index 70ef6aae..c9b68c00 100644 --- a/man/CoralSeaVelocity.Rd +++ b/man/CoralSeaVelocity.Rd @@ -8,7 +8,6 @@ \code{CoralSeaVelocity} A data frame with 397 rows and 3 columns: \describe{ -\item{cellID}{cell ID of the planning units} \item{vocMagg_transformed}{Climate velocity column} \item{geometry}{Geometry column of sf object} ... diff --git a/man/MPAsCoralSea.Rd b/man/MPAsCoralSea.Rd index b559bf29..f555ced9 100644 --- a/man/MPAsCoralSea.Rd +++ b/man/MPAsCoralSea.Rd @@ -9,7 +9,6 @@ A data frame with 397 rows and 17 columns: \describe{ \item{wdpa}{binary vector denoting presence or absence of a current marine protected area} -\item{cellID}{cell ID of planning units} ... } } diff --git a/man/dat_PUs.Rd b/man/dat_PUs.Rd index e618c9a8..49da8aa5 100644 --- a/man/dat_PUs.Rd +++ b/man/dat_PUs.Rd @@ -8,7 +8,6 @@ \code{dat_PUs} A data frame with XXXX rows and XXX columns: \describe{ -\item{cellID}{ID number for each row (or cell) of the dataset} \item{geometry}{sf geometry column} ... } diff --git a/man/dat_bathy.Rd b/man/dat_bathy.Rd index 0575bf38..b5a0a49b 100644 --- a/man/dat_bathy.Rd +++ b/man/dat_bathy.Rd @@ -8,7 +8,6 @@ \code{dat_bathy} A data frame with bathymetry data \describe{ -\item{cellID}{ID number for each row (or cell) of the dataset} \item{bathymetry}{Bathymetry data} \item{geometry}{sf geometry column} ... diff --git a/man/dat_bndry.Rd b/man/dat_bndry.Rd index 99c2763e..8e82b80b 100644 --- a/man/dat_bndry.Rd +++ b/man/dat_bndry.Rd @@ -8,7 +8,6 @@ \code{dat_bndry} A data frame with XXXX rows and XXX columns: \describe{ -\item{cellID}{ID number for each row (or cell) of the dataset} \item{geometry}{sf geometry column} ... } diff --git a/man/dat_clim.Rd b/man/dat_clim.Rd index 7f7ed489..0a686c54 100644 --- a/man/dat_clim.Rd +++ b/man/dat_clim.Rd @@ -8,7 +8,6 @@ \code{dat_clim} A data frame with 780 rows and 3 columns: \describe{ -\item{cellID}{ID number for each row (or cell) of the dataset} \item{geometry}{sf geometry column} \item{metric}{climate metric information} ... diff --git a/man/dat_mpas.Rd b/man/dat_mpas.Rd index 2d53e01d..a6d627a7 100644 --- a/man/dat_mpas.Rd +++ b/man/dat_mpas.Rd @@ -8,7 +8,6 @@ \code{dat_mpas} A data frame with XXXX rows and XXX columns: \describe{ -\item{cellID}{ID number for each row (or cell) of the dataset} \item{geometry}{sf geometry column} \item{wdpa}{binary MPA information (1: MPA)} ... diff --git a/man/dat_region.Rd b/man/dat_region.Rd index d3226ff0..3e551ec2 100644 --- a/man/dat_region.Rd +++ b/man/dat_region.Rd @@ -8,7 +8,6 @@ \code{dat_region} A data frame with XXXX rows and XXX columns: \describe{ -\item{cellID}{ID number for each row (or cell) of the dataset} \item{geometry}{sf geometry column} ... } diff --git a/man/dat_species_bin.Rd b/man/dat_species_bin.Rd index f2032faa..fde343e9 100644 --- a/man/dat_species_bin.Rd +++ b/man/dat_species_bin.Rd @@ -8,7 +8,6 @@ \code{dat_species_bin} A data frame with XXXX rows and XXX columns: \describe{ -\item{cellID}{ID number for each row (or cell) of the dataset} \item{geometry}{sf geometry column} ... } diff --git a/man/dat_species_bin2.Rd b/man/dat_species_bin2.Rd index 1bdbc892..1b2b77eb 100644 --- a/man/dat_species_bin2.Rd +++ b/man/dat_species_bin2.Rd @@ -8,7 +8,6 @@ \code{dat_species_bin2} A data frame with XXXX rows and XXX columns: \describe{ -\item{cellID}{ID number for each row (or cell) of the dataset} \item{geometry}{sf geometry column} ... } diff --git a/man/dat_species_prob.Rd b/man/dat_species_prob.Rd index 18187284..6628ce45 100644 --- a/man/dat_species_prob.Rd +++ b/man/dat_species_prob.Rd @@ -8,7 +8,6 @@ \code{dat_species_prob} A data frame with XXXX rows and XXX columns: \describe{ -\item{cellID}{ID number for each row (or cell) of the dataset} \item{geometry}{sf geometry column} ... } diff --git a/man/splnr_arrangeFeatures.Rd b/man/splnr_arrangeFeatures.Rd index 70ee939f..eee875d7 100644 --- a/man/splnr_arrangeFeatures.Rd +++ b/man/splnr_arrangeFeatures.Rd @@ -10,7 +10,7 @@ splnr_arrangeFeatures(df) \item{df}{An sf object to sort by Lon and Lat} } \value{ -A sorted sf object with the additionl cellID column +A sorted sf object } \description{ \code{splnr_arrangeFeatures()} sorts your data based on longitude and latitude values. diff --git a/man/splnr_climate_featureApproach.Rd b/man/splnr_climate_featureApproach.Rd index 25f1677c..de729f0b 100644 --- a/man/splnr_climate_featureApproach.Rd +++ b/man/splnr_climate_featureApproach.Rd @@ -5,20 +5,20 @@ \title{Function to run the feature approach} \usage{ splnr_climate_featureApproach( - featuresDF, - metricDF, - targetsDF, + features, + metric, + targets, direction, percentile = 35, refugiaTarget = 0.3 ) } \arguments{ -\item{featuresDF}{feature \code{sf}object which should have a column for cellID} +\item{features}{feature \code{sf}object} -\item{metricDF}{climate metric data.frame with 'metric' as the column name of the metric values per planning unit. This should also have a column for the cellID} +\item{metric}{climate metric \code{sf} object with 'metric' as the column name of the metric values per planning unit.} -\item{targetsDF}{\code{data.frame}with list of features under "feature" column and their corresponding targets under "target" column} +\item{targets}{\code{data.frame}with list of features under "feature" column and their corresponding targets under "target" column} \item{direction}{If direction = 1, metric values are from low (least climate-smart) to high (most climate-smart). If direction = -1, metric values are from high (least climate-smart) to low (most climate-smart).} @@ -33,22 +33,20 @@ A \code{list} with two components: 1. is the data frame passed to \code{prioriti Function to run the feature approach } \examples{ -Features <- dat_species_bin \%>\% - dplyr::select(-"cellID") +Features <- dat_species_bin -target <- Features \%>\% +targets <- Features \%>\% sf::st_drop_geometry() \%>\% colnames() \%>\% data.frame() \%>\% setNames(c("feature")) \%>\% dplyr::mutate(target = 0.3) -metric_df <- dat_clim - - Feature_Approach <- splnr_climate_featureApproach( - featuresDF = dat_species_bin, - metricDF = metric_df, targetsDF = target, direction = 1 + features = dat_species_bin, + metric = dat_clim, + targets = targets, + direction = 1 ) out_sf <- Feature_Approach$Features targets <- Feature_Approach$Targets diff --git a/man/splnr_climate_percentileApproach.Rd b/man/splnr_climate_percentileApproach.Rd index 180eeb46..3a891c58 100644 --- a/man/splnr_climate_percentileApproach.Rd +++ b/man/splnr_climate_percentileApproach.Rd @@ -5,19 +5,19 @@ \title{Function to run the percentile approach} \usage{ splnr_climate_percentileApproach( - featuresDF, - metricDF, - targetsDF, + features, + metric, + targets, direction, percentile = 35 ) } \arguments{ -\item{featuresDF}{feature \code{sf}object which should have a column for cellID} +\item{features}{feature \code{sf}object} -\item{metricDF}{climate metric data.frame with 'metric' as the column name of the metric values per planning unit. This should also have a column for the cellID} +\item{metric}{climate metric \code{sf} object with 'metric' as the column name of the metric values per planning unit.} -\item{targetsDF}{\code{data.frame}with list of features under "feature" column and their corresponding targets under "target" column} +\item{targets}{\code{data.frame}with list of features under "feature" column and their corresponding targets under "target" column} \item{direction}{If direction = 1, metric values are from low (least climate-smart) to high (most climate-smart). If direction = -1, metric values are from high (least climate-smart) to low (most climate-smart).} @@ -30,22 +30,19 @@ A \code{list} with two components: 1. is the data frame passed to \code{prioriti Function to run the percentile approach } \examples{ -Features <- dat_species_bin \%>\% - dplyr::select(-"cellID") -target <- Features \%>\% +targets <- dat_species_bin \%>\% sf::st_drop_geometry() \%>\% colnames() \%>\% data.frame() \%>\% setNames(c("feature")) \%>\% dplyr::mutate(target = 0.3) -metric_df <- dat_clim - - Percentile_Approach <- splnr_climate_percentileApproach( - featuresDF = dat_species_bin, - metricDF = metric_df, targetsDF = target, direction = 1 + features = dat_species_bin, + metric = dat_clim, + targets = targets, + direction = 1 ) out_sf <- Percentile_Approach$Features targets <- Percentile_Approach$Targets diff --git a/man/splnr_climate_priorityAreaApproach.Rd b/man/splnr_climate_priorityAreaApproach.Rd index cc7e5d76..d76d4fbf 100644 --- a/man/splnr_climate_priorityAreaApproach.Rd +++ b/man/splnr_climate_priorityAreaApproach.Rd @@ -5,20 +5,20 @@ \title{Function to run the climate-priority-area approach} \usage{ splnr_climate_priorityAreaApproach( - featuresDF, - metricDF, - targetsDF, + features, + metric, + targets, direction, percentile = 5, refugiaTarget = 1 ) } \arguments{ -\item{featuresDF}{feature \code{sf}object which should have a column for cellID} +\item{features}{feature \code{sf}object} -\item{metricDF}{climate metric data.frame with 'metric' as the column name of the metric values per planning unit. This should also have a column for the cellID} +\item{metric}{climate metric \code{sf} object with 'metric' as the column name of the metric values per planning unit.} -\item{targetsDF}{\code{data.frame}with list of features under "feature" column and their corresponding targets under "target" column} +\item{targets}{\code{data.frame}with list of features under "feature" column and their corresponding targets under "target" column} \item{direction}{If direction = 1, metric values are from low (least climate-smart) to high (most climate-smart). If direction = -1, metric values are from high (least climate-smart) to low (most climate-smart).} @@ -33,22 +33,19 @@ A \code{list} with two components: 1. is the data frame passed to \code{prioriti Function to run the climate-priority-area approach } \examples{ -Features <- dat_species_bin \%>\% - dplyr::select(-"cellID") -target <- Features \%>\% +targets <- dat_species_bin \%>\% sf::st_drop_geometry() \%>\% colnames() \%>\% data.frame() \%>\% setNames(c("feature")) \%>\% dplyr::mutate(target = 0.3) -metric_df <- dat_clim - - CPA_Approach <- splnr_climate_priorityAreaApproach( - featuresDF = dat_species_bin, - metricDF = metric_df, targetsDF = target, direction = -1 + features = dat_species_bin, + metric = dat_clim, + targets = targets, + direction = -1 ) out_sf <- CPA_Approach$Features targets <- CPA_Approach$Targets diff --git a/man/splnr_featureNames.Rd b/man/splnr_featureNames.Rd index 4fd2bf16..93f57313 100644 --- a/man/splnr_featureNames.Rd +++ b/man/splnr_featureNames.Rd @@ -20,5 +20,5 @@ It requires an \code{sf} object input and returns the column names of the object } \examples{ df <- dat_species_prob \%>\% - splnr_featureNames(exclude = c("cellID")) + splnr_featureNames() } diff --git a/man/splnr_get_featureRep.Rd b/man/splnr_get_featureRep.Rd index c7d56d03..90dd70eb 100644 --- a/man/splnr_get_featureRep.Rd +++ b/man/splnr_get_featureRep.Rd @@ -7,7 +7,7 @@ splnr_get_featureRep( soln, pDat, - targetsDF = NA, + targets = NA, climsmart = FALSE, climsmartApproach = 0, solnCol = "solution_1" @@ -18,7 +18,7 @@ splnr_get_featureRep( \item{pDat}{The \code{prioritizr} problem} -\item{targetsDF}{\code{data.frame}with list of features under "feature" column and their corresponding targets under "target" column} +\item{targets}{\code{data.frame}with list of features under "feature" column and their corresponding targets under "target" column} \item{climsmart}{logical denoting whether spatial planning was done climate-smart (and targets have to be calculated differently)} diff --git a/man/splnr_match_names.Rd b/man/splnr_match_names.Rd index 919f99bc..dea1a52d 100644 --- a/man/splnr_match_names.Rd +++ b/man/splnr_match_names.Rd @@ -20,7 +20,7 @@ to a vector of names. Here we provide a function to quickly replace the numbers with names. } \examples{ -dat <- dat_region \%>\% dplyr::select(-cellID) +dat <- dat_region nam <- c("Region1" = "SE Aust", "Region2" = "Tas", "Region3" = "NE Aust") df <- splnr_match_names(dat, nam) } diff --git a/man/splnr_plot.Rd b/man/splnr_plot.Rd index 4b7bbe3f..0ede1af4 100644 --- a/man/splnr_plot.Rd +++ b/man/splnr_plot.Rd @@ -17,11 +17,11 @@ splnr_plot( \arguments{ \item{df}{The dataframe containing the data to be plotted. It must include a geometry column to be used with geom_sf.} -\item{col_names}{A list of column names to include in the plot. If specified, only these columns will be used to color the plot.} +\item{col_names}{A list of column names to include in the plot. If specified, only these columns will be used to colour the plot.} -\item{paletteName}{The name of the color palette to use for filling. Default is "YlGnBu".} +\item{paletteName}{The name of the colour palette to use for filling. Default is "YlGnBu".} -\item{colourVals}{The color values to use if col_names is specified and the data is binary.} +\item{colourVals}{The colour values to use if col_names is specified and the data is binary.} \item{plot_title}{The title of the plot.} @@ -36,10 +36,8 @@ A ggplot object. (For now can replace splnr_plot_cost(), splnr_plot_binFeature(), splnr_plot_MPAs(), splnr_plot_featureNo()) } \details{ -Written by Kilian Barreiro +Written by Kilian Barreiro and Jason Everett Written: February 2024 - -Plot Spatial Data, returns a gg object } \examples{ # Binary plot of species distribution diff --git a/man/splnr_plot_climKernelDensity.Rd b/man/splnr_plot_climKernelDensity.Rd index 6e89f5c1..621e15c9 100644 --- a/man/splnr_plot_climKernelDensity.Rd +++ b/man/splnr_plot_climKernelDensity.Rd @@ -34,7 +34,6 @@ Kernel Density Plots for climate-smart spatial plans } \examples{ target <- dat_species_bin \%>\% - dplyr::select(-"cellID") \%>\% sf::st_drop_geometry() \%>\% colnames() \%>\% data.frame() \%>\% @@ -42,21 +41,20 @@ target <- dat_species_bin \%>\% dplyr::mutate(target = 0.3) CPA <- splnr_climate_priorityAreaApproach( - featuresDF = dat_species_bin, - metricDF = dat_clim, - targetsDF = target, + features = dat_species_bin, + metric = dat_clim, + targets = 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") + sf::st_join(dat_clim, join = sf::st_equals) usedFeatures <- out_sf \%>\% sf::st_drop_geometry() \%>\% - dplyr::select(-tidyselect::starts_with("Cost_"), -"cellID", -"metric") \%>\% + dplyr::select(-tidyselect::starts_with("Cost_"), -"metric") \%>\% names() p1 <- prioritizr::problem(out_sf, usedFeatures, "Cost_None") \%>\% diff --git a/man/splnr_replace_NAs.Rd b/man/splnr_replace_NAs.Rd index a2c7877b..027e2092 100644 --- a/man/splnr_replace_NAs.Rd +++ b/man/splnr_replace_NAs.Rd @@ -15,8 +15,8 @@ splnr_replace_NAs(df, vari) An \code{sf} object with NAs replaced with the nearest neighbour } \description{ -\code{splnr_replace_NAs()} allows you to replace NA values in your data with the value of the nearest neighbor. -The nearest neighbor is determined using \code{st_nearest_feature()} from the \code{sf} package. +\code{splnr_replace_NAs()} allows you to replace NA values in your data with the value of the nearest neighbour. +The nearest neighbour is determined using \code{st_nearest_feature()} from the \code{sf} package. } \examples{ df <- dat_species_prob \%>\% diff --git a/tests/testthat/test-splnr_get_distCoast.R b/tests/testthat/test-splnr_get_distCoast.R index dd1e553c..6a68d4ab 100644 --- a/tests/testthat/test-splnr_get_distCoast.R +++ b/tests/testthat/test-splnr_get_distCoast.R @@ -2,7 +2,7 @@ testthat::test_that("Correct function output", { crs <- sf::st_crs("+proj=longlat +datum=WGS84 +no_defs") bbox <- sf::st_bbox(c(xmin = 0, ymin = 0, xmax = 3, ymax = 3)) grid <- sf::st_make_grid(bbox, n = c(3, 3), what = "polygons") - grid <- sf::st_sf(cellID = 1:length(grid), geometry = grid) %>% + grid <- sf::st_sf(geometry = grid) %>% sf::st_set_crs(crs) result <- splnr_get_distCoast(grid) diff --git a/tests/testthat/test-splnr_plotting_climate.R b/tests/testthat/test-splnr_plotting_climate.R index 60f3b66f..e10c3a2f 100644 --- a/tests/testthat/test-splnr_plotting_climate.R +++ b/tests/testthat/test-splnr_plotting_climate.R @@ -1,6 +1,5 @@ -target <- dat_species_bin %>% - dplyr::select(-"cellID") %>% +targets <- dat_species_bin %>% sf::st_drop_geometry() %>% colnames() %>% data.frame() %>% @@ -8,21 +7,19 @@ target <- dat_species_bin %>% dplyr::mutate(target = 0.3) CPA <- splnr_climate_priorityAreaApproach( - featuresDF = dat_species_bin, - metricDF = dat_clim, - targetsDF = target, + features = dat_species_bin, + metric = dat_clim, + targets = targets, direction = -1, - refugiaTarget = 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") + sf::st_join(dat_clim, join = sf::st_equals) usedFeatures <- out_sf %>% sf::st_drop_geometry() %>% - dplyr::select(-tidyselect::starts_with("Cost_"), -"cellID", -"metric") %>% + dplyr::select(-tidyselect::starts_with("Cost_"), -"metric") %>% names() p1 <- prioritizr::problem(out_sf, usedFeatures, "Cost_None") %>% diff --git a/tests/testthat/test-utils-climate.R b/tests/testthat/test-utils-climate.R index 96d0f8fd..07d5ac4d 100644 --- a/tests/testthat/test-utils-climate.R +++ b/tests/testthat/test-utils-climate.R @@ -1,26 +1,19 @@ -Features <- dat_species_bin %>% - dplyr::select(-"cellID") - -target <- Features %>% +targets <- dat_species_bin %>% sf::st_drop_geometry() %>% colnames() %>% data.frame() %>% setNames(c("feature")) %>% dplyr::mutate(target = 0.3) -metric_df <- dat_clim - -dat_species_binDF <- dat_species_bin %>% - sf::st_drop_geometry() - - testthat::test_that("Correct function output", { expect_true( rlang::is_list(splnr_climate_priorityAreaApproach( - featuresDF = dat_species_bin, - metricDF = metric_df, targetsDF = target, direction = -1)) + features = dat_species_bin, + metric = dat_clim, + targets = targets, + direction = -1)) , "sf" ) }) @@ -31,8 +24,10 @@ testthat::test_that("Correct function output", { expect_true( rlang::is_list( splnr_climate_featureApproach( - featuresDF = dat_species_bin, - metricDF = metric_df, targetsDF = target, direction = 1)) + features = dat_species_bin, + metric = dat_clim, + targets = targets, + direction = 1)) , "sf" ) }) @@ -42,8 +37,10 @@ testthat::test_that("Correct function output", { expect_true( rlang::is_list( splnr_climate_percentileApproach( - featuresDF = dat_species_bin, - metricDF = metric_df, targetsDF = target, direction = 1)) + features = dat_species_bin, + metric = dat_clim, + targets = targets, + direction = 1)) , "sf" ) }) diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index ae777667..12e21071 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -25,7 +25,7 @@ testthat::test_that("Correct function output", { testthat::test_that("Correct function output", { expect_s3_class( - splnr_match_names(dat_region %>% dplyr::select(-cellID), + splnr_match_names(dat_region, c("Region1" = "SE Aust", "Region2" = "Tas", "Region3" = "NE Aust")), "sf" ) }) @@ -43,7 +43,7 @@ testthat::test_that("Correct function output", { testthat::test_that("Correct function output", { expect_vector( dat_species_prob %>% - splnr_featureNames(exclude = c("cellID")) + splnr_featureNames() ) }) @@ -73,7 +73,7 @@ testthat::test_that("Correct function output", { testthat::test_that("Correct function output", { expect_vector(dat_species_prob %>% - splnr_featureNames(exclude = c("cellID")) + splnr_featureNames() ) }) diff --git a/vignettes/ClimateSmart.R b/vignettes/ClimateSmart.R new file mode 100644 index 00000000..50d922bd --- /dev/null +++ b/vignettes/ClimateSmart.R @@ -0,0 +1,174 @@ +## ----include = FALSE---------------------------------------------------------- +knitr::opts_chunk$set( +collapse = TRUE, +comment = "#>", +warning = FALSE, +cache = FALSE, +message = FALSE, +eval = TRUE, +fig.width = 9 +) + +## ----setup-------------------------------------------------------------------- +library(spatialplanr) + +## ----------------------------------------------------------------------------- +Region <- "Coral Sea" # "Australia" +Type <- "Oceans" # "EEZ" +cCRS <- "ESRI:54009" # Mollweide + +## ----------------------------------------------------------------------------- +PU_size <- 107460 # m + +## ----------------------------------------------------------------------------- +splnr_theme <- list( + ggplot2::theme_bw(), + ggplot2::theme( + legend.position = "right", + legend.direction = "vertical", + text = ggplot2::element_text(size = 9, colour = "black"), + axis.text = ggplot2::element_text(size = 9, colour = "black"), + plot.title = ggplot2::element_text(size = 9), + axis.title = ggplot2::element_blank() + ) +) + +## ----------------------------------------------------------------------------- +Bndry <- splnr_get_boundary(Limits = Region, Type = Type, cCRS = cCRS) + +landmass <- rnaturalearth::ne_countries(scale = "medium", returnclass = "sf") %>% + sf::st_transform(cCRS) + +## ----------------------------------------------------------------------------- +PUs <- spatialgridr::get_grid(boundary = Bndry, + crs = cCRS, + output = "sf_hex", + resolution = PU_size) + +## ----------------------------------------------------------------------------- +Dict <- tibble::tribble( + ~nameCommon, ~nameVariable, ~category, + "Green sea turtle", "Chelonia_mydas", "Reptiles", + "Loggerhead sea turtle", "Caretta_caretta", "Reptiles", + "Hawksbill sea turtle", "Eretmochelys_imbricata", "Reptiles", + "Olive ridley sea turtle", "Lepidochelys_olivacea", "Reptiles", + "Saltwater crocodile", "Crocodylus_porosus", "Reptiles", + "Humpback whale", "Megaptera_novaeangliae", "Mammals", + "Common Minke whale", "Balaenoptera_acutorostrata", "Mammals", + "Dugong", "Dugong_dugon", "Mammals", + "Grey nurse shark", "Carcharias_taurus", "Sharks and rays", + "Tiger shark", "Galeocerdo_cuvier", "Sharks and rays", + "Great hammerhead shark", "Sphyrna_mokarran", + "Sharks and rays", + "Giant oceanic manta ray", "Mobula_birostris", "Sharks and rays", + "Reef manta ray", "Mobula_alfredi", "Sharks and rays", + "Whitetip reef shark", "Triaenodon_obesus", "Sharks and rays", + "Red-footed booby", "Sula_sula", "Birds" +) + +## ----------------------------------------------------------------------------- +datEx_species_bin <- spDataFiltered %>% + dplyr::as_tibble() %>% + dplyr::mutate(dplyr::across( + -dplyr::any_of(c("geometry")), # Don't apply to geometry + ~ dplyr::case_when( + . >= 0.5 ~ 1, + . < 0.5 ~ 0, + is.na(.data) ~ 0 + ) + )) %>% + sf::st_as_sf() + +col_name <- spDataFiltered %>% + sf::st_drop_geometry() %>% + colnames() + +## ----------------------------------------------------------------------------- +metric_df <- CoralSeaVelocity %>% + dplyr::rename(metric = voccMag_transformed) + +## ----fig.width = 9------------------------------------------------------------ +(ggclim <- splnr_plot_climData(metric_df, "metric") + + splnr_gg_add( + Bndry = Bndry, overlay = landmass, + cropOverlay = PUs, ggtheme = splnr_theme + )) + +## ----fig.width = 9------------------------------------------------------------ +set.seed(5) + +metric_df <- CoralSeaVelocity %>% + dplyr::rename(metric = voccMag_transformed) %>% + dplyr::mutate( + metricOG = metric, + metric = ifelse(metric > 0.99, runif(., 0.85, 1.0), metric) + ) + +(ggclim <- splnr_plot_climData(metric_df, "metric") + + splnr_gg_add( + Bndry = Bndry, overlay = landmass, + cropOverlay = PUs, ggtheme = splnr_theme + )) + +## ----------------------------------------------------------------------------- +target <- datEx_species_bin %>% + sf::st_drop_geometry() %>% + colnames() %>% + data.frame() %>% + setNames(c("feature")) %>% + dplyr::mutate(target = 0.3) + + +CPA_Approach <- splnr_climate_priorityAreaApproach( + featuresDF = datEx_species_bin, + metricDF = metric_df, + targetsDF = target, + direction = -1, refugiaTarget = 1 +) + +out_sf <- CPA_Approach$Features %>% + sf::st_join( + datEx_species_bin %>% + dplyr::select( + tidyselect::starts_with("Cost_") + ), + join = sf::st_equals) %>% + sf::st_join(metric_df, join = sf::st_equals) + +targets <- CPA_Approach$Targets + +## ----------------------------------------------------------------------------- +out_sf$Cost_None <- rep(1, 397) + +usedFeatures <- out_sf %>% + sf::st_drop_geometry() %>% + dplyr::select( + -tidyselect::starts_with("Cost_"), + -tidyselect::starts_with("metric") + ) %>% + names() + +## ----------------------------------------------------------------------------- +p1 <- prioritizr::problem(out_sf, usedFeatures, "Cost_None") %>% + prioritizr::add_min_set_objective() %>% + prioritizr::add_relative_targets(targets$target) %>% + prioritizr::add_binary_decisions() %>% + prioritizr::add_default_solver(verbose = FALSE) + +dat_solnClim <- prioritizr::solve.ConservationProblem(p1) + +## ----fig.width = 9------------------------------------------------------------ +(ggSoln <- splnr_plot_solution(dat_solnClim) + + splnr_gg_add( + Bndry = Bndry, overlay = landmass, + cropOverlay = PUs, ggtheme = splnr_theme + )) + +## ----fig.width = 9------------------------------------------------------------ +(ggClimDens <- splnr_plot_climKernelDensity( + soln = list(dat_solnClim), + names = c("Input 1"), type = "Normal", + legendTitle = "Climate velocity (add unit)", + xAxisLab = "Climate velocity" +)) + diff --git a/vignettes/ClimateSmart.Rmd b/vignettes/ClimateSmart.Rmd index 29b077e5..5ca351b0 100644 --- a/vignettes/ClimateSmart.Rmd +++ b/vignettes/ClimateSmart.Rmd @@ -111,7 +111,7 @@ These species were not chosen based on their importance for this region and only datEx_species_bin <- spDataFiltered %>% dplyr::as_tibble() %>% dplyr::mutate(dplyr::across( - -dplyr::any_of(c("cellID", "geometry")), # Don't apply to geometry/cellID + -dplyr::any_of(c("geometry")), # Don't apply to geometry ~ dplyr::case_when( . >= 0.5 ~ 1, . < 0.5 ~ 0, @@ -122,7 +122,6 @@ datEx_species_bin <- spDataFiltered %>% col_name <- spDataFiltered %>% sf::st_drop_geometry() %>% - dplyr::select(-"cellID") %>% colnames() ``` @@ -133,14 +132,14 @@ So far, all steps were exactly the same as in a spatial plan that does not inclu We will use climate velocity data obtained from x, y and z models using SSP5-8.5. For downstream analysis, we rename the column of interest (here: the velocity data) `metric`. ```{r} -metric_df <- CoralSeaVelocity %>% +metric <- CoralSeaVelocity %>% dplyr::rename(metric = voccMag_transformed) ``` The climate velocity data can be visualized using the `splnr_plot_climData()` function. ```{r, fig.width = 9} -(ggclim <- splnr_plot_climData(metric_df, "metric") + +(ggclim <- splnr_plot_climData(metric, "metric") + splnr_gg_add( Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme @@ -152,14 +151,14 @@ In our case, there were few areas with low climate velocity, which are the areas ```{r, fig.width = 9} set.seed(5) -metric_df <- CoralSeaVelocity %>% +metric <- CoralSeaVelocity %>% dplyr::rename(metric = voccMag_transformed) %>% dplyr::mutate( metricOG = metric, metric = ifelse(metric > 0.99, runif(., 0.85, 1.0), metric) ) -(ggclim <- splnr_plot_climData(metric_df, "metric") + +(ggclim <- splnr_plot_climData(metric, "metric") + splnr_gg_add( Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme @@ -172,9 +171,8 @@ Using this approach also requires an adaptation of the targets, since 5% of the ```{r} -target <- datEx_species_bin %>% +targets <- datEx_species_bin %>% sf::st_drop_geometry() %>% - dplyr::select(-"cellID") %>% colnames() %>% data.frame() %>% setNames(c("feature")) %>% @@ -182,22 +180,21 @@ target <- datEx_species_bin %>% CPA_Approach <- splnr_climate_priorityAreaApproach( - featuresDF = datEx_species_bin, - metricDF = metric_df, targetsDF = target, direction = -1, refugiaTarget = 1 + features = datEx_species_bin, + metric = metric, + targets = targets, + direction = -1, + refugiaTarget = 1 ) out_sf <- CPA_Approach$Features %>% - dplyr::left_join( + sf::st_join( datEx_species_bin %>% - sf::st_drop_geometry() %>% dplyr::select( - "cellID", tidyselect::starts_with("Cost_") ), - by = "cellID" - ) %>% - dplyr::left_join(metric_df %>% - sf::st_drop_geometry(), by = "cellID") + join = sf::st_equals) %>% + sf::st_join(metric, join = sf::st_equals) targets <- CPA_Approach$Targets ``` @@ -212,7 +209,6 @@ usedFeatures <- out_sf %>% sf::st_drop_geometry() %>% dplyr::select( -tidyselect::starts_with("Cost_"), - -"cellID", -tidyselect::starts_with("metric") ) %>% names() @@ -242,8 +238,7 @@ We can look at the resulting plan using `splnr_plot_solution()`. )) ``` -However, we are also interested how climate-smart the selected planning units in the solution actually are. For this, we can use a kernel density plot - +However, we are also interested how climate-smart the selected planning units in the solution actually are. For this, we can use a kernel density plot. ```{r, fig.width = 9} (ggClimDens <- splnr_plot_climKernelDensity( @@ -259,31 +254,30 @@ However, we are also interested how climate-smart the selected planning units in ### Percentile Approach ```{r} -target <- datEx_species_bin %>% +targets <- datEx_species_bin %>% sf::st_drop_geometry() %>% - dplyr::select(-"cellID") %>% colnames() %>% data.frame() %>% setNames(c("feature")) %>% dplyr::mutate(target = 30) Percentile_Approach <- splnr_climate_percentileApproach( - featuresDF = datEx_species_bin, - metricDF = metric_df, targetsDF = target, direction = -1, percentile = 35 + features = datEx_species_bin, + metric = metric, + targets = targets, + direction = -1, + percentile = 35 ) out_sf <- Percentile_Approach$Features %>% - dplyr::left_join( + sf::st_join( datEx_species_bin %>% - sf::st_drop_geometry() %>% dplyr::select( - "cellID", tidyselect::starts_with("Cost_") ), - by = "cellID" + join = sf::st_equals ) %>% - dplyr::left_join(metric_df %>% - sf::st_drop_geometry(), by = "cellID") + sf::st_join(metric, join = sf::st_equals) targets <- Percentile_Approach$Targets ``` @@ -298,7 +292,6 @@ usedFeatures <- out_sf %>% sf::st_drop_geometry() %>% dplyr::select( -tidyselect::starts_with("Cost_"), - -"cellID", -tidyselect::starts_with("metric") ) %>% names() @@ -339,31 +332,28 @@ However, we are also interested how climate-smart the selected planning units in ### Feature Approach ```{r} -target <- datEx_species_bin %>% +targets <- datEx_species_bin %>% sf::st_drop_geometry() %>% - dplyr::select(-"cellID") %>% colnames() %>% data.frame() %>% setNames(c("feature")) %>% dplyr::mutate(target = 0.3) Feature_Approach <- splnr_climate_featureApproach( - featuresDF = datEx_species_bin, - metricDF = metric_df, targetsDF = target, direction = 1 + features = datEx_species_bin, + metric = metric, + targets = targets, + direction = 1 ) out_sf <- Feature_Approach$Features %>% - dplyr::left_join( + sf::st_join( datEx_species_bin %>% - sf::st_drop_geometry() %>% dplyr::select( - "cellID", tidyselect::starts_with("Cost_") ), - by = "cellID" - ) %>% - dplyr::left_join(metric_df %>% - sf::st_drop_geometry(), by = "cellID") + join = sf::st_equals) %>% + sf::st_join(metric, join = sf::st_equals) targets <- Feature_Approach$Targets ``` @@ -378,7 +368,6 @@ usedFeatures <- out_sf %>% sf::st_drop_geometry() %>% dplyr::select( -tidyselect::starts_with("Cost_"), - -"cellID", -tidyselect::starts_with("metric") ) %>% names() diff --git a/vignettes/GlobalFishingWatch.R b/vignettes/GlobalFishingWatch.R new file mode 100644 index 00000000..ca398e53 --- /dev/null +++ b/vignettes/GlobalFishingWatch.R @@ -0,0 +1,204 @@ +## ----setup_chunks, include=FALSE---------------------------------------------- +knitr::opts_chunk$set(echo = TRUE, warning = FALSE) + +## ----eval=FALSE--------------------------------------------------------------- +# remotes::install_github("GlobalFishingWatch/gfwr") + +## ----setup-------------------------------------------------------------------- +library(gfwr) +library(spatialplanr) + +## ----eval=FALSE--------------------------------------------------------------- +# usethis::edit_r_environ() + +## ----eval=FALSE--------------------------------------------------------------- +# key <- gfwr::gfw_auth() + +## ----results='hide'----------------------------------------------------------- +region_id <- gfwr::get_region_id(region_name = "Australia", + region_source = "EEZ", + key = gfwr::gfw_auth())$id + +## ----eval=FALSE, message=FALSE------------------------------------------------ +# gfwr::get_raster( +# spatial_resolution = "LOW", +# temporal_resolution = "MONTHLY", +# group_by = "FLAGANDGEARTYPE", +# start_date = "2022-01-01", +# end_date = "2023-01-01", +# region = region_id, +# region_source = "EEZ", +# key = gfwr::gfw_auth() +# ) + +## ----message=FALSE------------------------------------------------------------ +data_sf_combined <- splnr_get_gfw(region = "Australia", + start_date = "2019-01-01", + end_date = "2023-12-31", + temp_res = "YEARLY", + spat_res = "LOW", + compress = FALSE) + +## ----message = FALSE, results='hide'------------------------------------------ +# Check and modify if necessary the spatial reference of data_sf_combined +data_sf_combined <- sf::st_set_crs(data_sf_combined, + sf::st_crs(rnaturalearth::ne_coastline(scale = "large"))) + +coast_clipped <- rnaturalearth::ne_coastline(scale = "large") %>% + sf::st_as_sf() %>% + sf::st_intersection(sf::st_as_sfc(sf::st_bbox(data_sf_combined))) + +# Load EEZ polygons +eezs <- spatialgridr::get_boundary(name = "Australia", type = "eez", country_type = "country") %>% + sf::st_transform(crs = sf::st_crs(data_sf_combined)) %>% + sf::st_make_valid() %>% + sf::st_intersection(sf::st_as_sfc(sf::st_bbox(data_sf_combined))) + +## ----echo=FALSE--------------------------------------------------------------- +main_plot <- ggplot2::ggplot(data_sf_combined) + + ggplot2::geom_sf(ggplot2::aes(color = log10(ApparentFishingHrs))) + + ggplot2::geom_sf(data = coast_clipped, color = "black", fill = NA) + # Add coastline + ggplot2::geom_sf(data = eezs, fill = NA, color = "red") + # Add the EEZ with hatching + ggplot2::scale_color_viridis_c(guide = "legend") + + ggplot2::theme_minimal() + + ggplot2::labs(title = "2022 Vessel Activity Map", + subtitle = "Fishing Hours recorded by GFW in Australia", + color = "Fishing Hours (log10)") + + ggplot2::theme( + legend.position = "bottom", + legend.text = ggplot2::element_text(size = 8), + legend.title = ggplot2::element_text(size = 10) + ) + + ggplot2::guides(color = ggplot2::guide_colorbar( + title.position = "top", + title.vjust = 0.5, + title.hjust = -0.5, + label.theme = ggplot2::element_text(size = 8), + barwidth = 5, + barheight = 0.5 + )) + +# The display and writing in this section is for information purposes only, to understand how the information on the grid is translated. +overlay_plot <- ggplot2::ggplot(data_sf_combined) + + ggplot2::geom_rect(ggplot2::aes(xmin = -Inf,xmax = Inf,ymin = -Inf,ymax = Inf), fill = "white") + + ggplot2::geom_sf(ggplot2::aes(color = log10(ApparentFishingHrs))) + + ggplot2::geom_sf(data = coast_clipped, color = "black", fill = NA) + # Add coastline + ggplot2::geom_sf(data = eezs, fill = NA, color = "red") + + ggplot2::scale_color_viridis_c(guide = "legend") + + ggplot2::labs(title = "Vessel Activity Map in Australia between 2019 and 2023", + subtitle = "Fishing Hours data recorded by GFW", + color = "Fishing Hours \n (log10)") + + ggplot2::theme_minimal() + + ggplot2::theme( + legend.position = "none", + title = ggplot2::element_blank(), + axis.text.x = ggplot2::element_blank(), + axis.text.y = ggplot2::element_blank(), + axis.title.x = ggplot2::element_blank(), + axis.title.y = ggplot2::element_blank(), + panel.border = ggplot2::element_rect(color = "black", fill = NA, linewidth = 1) + ) + + ggplot2::coord_sf(xlim = c(152, 155), ylim = c(-27, -29)) + +main_plot + + ggplot2::annotation_custom( + ggplot2::ggplotGrob(overlay_plot), + xmin = 130, + xmax = 170, + ymin = -20, + ymax = -36 + ) + +## ----echo=FALSE--------------------------------------------------------------- +ggplot2::ggplot(data_sf_combined) + + ggplot2::geom_sf(ggplot2::aes(color = as.factor(Year))) + + ggplot2::geom_sf(data = coast_clipped, color = "black", fill = NA) + # Add coastline + ggplot2::geom_sf(data = eezs, color = "red", fill = NA) + # Add the EEZ + ggplot2::theme_minimal() + + ggplot2::scale_color_viridis_d(guide = "legend") + + ggplot2::labs(title = "Vessel Activity Map in Australia between 2019 and 2024", subtitle = "Fishing Hours data recorded by GFW", color = "Years") + + ggplot2::theme( + legend.position = "bottom", + legend.text = ggplot2::element_text(size = 8), + legend.title = ggplot2::element_text(size = 10) + ) + +## ----message=FALSE------------------------------------------------------------ +# We need to change the temporal range according to our need group by it to display the total fishing hours.
+data_sf_combined <- splnr_get_gfw(region = "Australia", + start_date = "2019-01-01", + end_date = "2023-12-31", + temp_res = "MONTHLY", + key = gfwr::gfw_auth()) %>% + dplyr::group_by(Year, Month) %>% + dplyr::summarize(Total_Fishing_Hours = sum(ApparentFishingHrs)) + +## ----echo=FALSE--------------------------------------------------------------- +ggplot2::ggplot(data_sf_combined, ggplot2::aes(x = Month, y = Total_Fishing_Hours, color = Year, group = Year)) + + ggplot2::geom_line() + + ggplot2::geom_point() + + ggplot2::labs( + title = "Total Fishing Hours per month (2014-2023)", + x = "Month", y = "Total Fishing Hours" + ) + + ggplot2::theme_minimal() + +## ----message=FALSE------------------------------------------------------------ +data_sf_combined <- splnr_get_gfw(region = "Micronesia", + start_date = "2019-12-31", + end_date = "2021-01-01", + temp_res = "MONTHLY") + +## ----echo=FALSE, message=FALSE, results='hide'-------------------------------- +# Check and modify if necessary the spatial reference of data_sf_combined +data_sf_combined <- sf::st_set_crs(data_sf_combined, sf::st_crs(rnaturalearth::ne_coastline(scale = "large"))) + +coast_clipped <- rnaturalearth::ne_coastline(scale = "large") %>% + sf::st_as_sf() %>% + sf::st_intersection(sf::st_as_sfc(sf::st_bbox(data_sf_combined))) + +# Load EEZ polygons +eezs <- spatialgridr::get_boundary(name = "Micronesia", type = "eez", country_type = "country") %>% + sf::st_transform(crs = sf::st_crs(data_sf_combined)) %>% + sf::st_make_valid() %>% + sf::st_intersection(sf::st_as_sfc(sf::st_bbox(data_sf_combined))) + +## ----echo=FALSE--------------------------------------------------------------- +# Create the map +ggplot2::ggplot(data_sf_combined) + + ggplot2::geom_sf(ggplot2::aes(color = `Geartype`)) + + ggplot2::geom_sf(data = coast_clipped, color = "black", fill = NA) + # Add coastline + ggplot2::geom_sf(data = eezs, color = "red", fill = NA) + # Ajouter la EEZ avec hachures + ggplot2::theme_minimal() + + ggplot2::labs(title = "2020 Vessel Activity Map", subtitle = "recorded by GFW in Micronesia", color = "Gear types") + + ggplot2::theme(legend.position = "right") + +## ----echo=FALSE, message=FALSE, results='hide'-------------------------------- +data_sf_combined <- splnr_get_gfw(region = "Papua New Guinea", + start_date = "2019-12-31", + end_date = "2021-01-01", + temp_res = "YEARLY", + spat_res = "LOW") %>% + sf::st_set_crs(sf::st_crs(rnaturalearth::ne_coastline(scale = "large"))) + +coast_clipped <- rnaturalearth::ne_coastline(scale = "large") %>% + sf::st_as_sf() %>% + sf::st_intersection(sf::st_as_sfc(sf::st_bbox(data_sf_combined))) + +# Load EEZ polygons +eezs <- spatialgridr::get_boundary(name = "Papua New Guinea", type = "eez", country_type = "country") %>% + sf::st_transform(crs = sf::st_crs(data_sf_combined)) %>% + sf::st_make_valid() %>% + sf::st_intersection(sf::st_as_sfc(sf::st_bbox(data_sf_combined))) + +## ----echo=FALSE--------------------------------------------------------------- +# Create the map +ggplot2::ggplot(data_sf_combined) + + ggplot2::geom_sf(ggplot2::aes(color = `Flag`)) + + ggplot2::geom_sf(data = coast_clipped, color = "black", fill = NA) + # Add coastline + ggplot2::geom_sf(data = eezs, color = "red", fill = NA) + # Add EEZ + ggplot2::scale_size_continuous(range = c(1, 10), guide = "legend", name = "Flag") + + ggplot2::theme_minimal() + + ggplot2::labs(title = "2021 Vessel Activity Map", subtitle = "recorded by GFW in Papua New Guinea", color = "Flag") + + ggplot2::theme(legend.position = "right") + diff --git a/vignettes/GlobalFishingWatch.html b/vignettes/GlobalFishingWatch.html new file mode 100644 index 00000000..4b8b52a2 --- /dev/null +++ b/vignettes/GlobalFishingWatch.html @@ -0,0 +1,535 @@ + + + + + + + + + + + + + + +Global Fishing Watch + + + + + + + + + + + + + + + + + + + + + + + + + + +

Global Fishing Watch

+ + + +
+

Global Fishing Watch R Package (gfwr)

+

The gfwr package provides convenient functions to pull +GFW data directly into R into usable formats. It contains three main +functions, including : get_vessel_info(), +get_event() and get_raster(). The two first +being devoted to retrieving information and features on one ore several +specific vessels. The last is of particular interest to us because it +allows us to gather information from global fishing watch raster on the +fishing effort (further details in the function appropriate section). +Here we mainly use the splnr_get_gfw function which has +been created to enable data to be retrieved and processed in a variety +of ways, some of which are described here.

+

The time spent fishing is computed using Automatic Identification +System (AIS) data, which is transmitted by most industrial fishing +vessels. The AIS data provides information on the location, speed, and +direction of the vessel, which can be used to identify when the vessel +is actively fishing.

+
+

AIS Caveats and limitations

+

The AIS coverage of vessels has several limitations such as:
+1. The number of vessels that are captured (AIS provides approximately +70’000 of the 2.8 million identified fishing vessels).
+2. The size of the vessels (52-85% for vessels larger than 24 meters +against 1% for vessels under 12 meters).
+Good to know: IMO mandates AIS for most vessels larger than 36 +meters.
+3. AIS interference with each other in areas of high vessel +density.
+4. Some terrestrial satellites only receive messages near shore.

+
+
+

Installation

+
remotes::install_github("GlobalFishingWatch/gfwr")
+
library(gfwr)
+library(spatialplanr)
+
+
+

API

+

To access GFW APIs, you need to :
1. register for a GFW account +here.
+2. Request API key here.

+

Once you have your token, add it to your .Renviron file (by executing +the chunk below), by writing (GFW_TOKEN = “YOUR_TOKEN”) in the file. +
(You could be asked to restart R for changes to take +effect.)

+
usethis::edit_r_environ()
+

We save the key in an object that will be used in gfwr functions.

+
key <- gfwr::gfw_auth()
+
+
+

Fishing effort visualization

+

A region_id is necessary to use the get_raster +function.

+
region_id <- gfwr::get_region_id(region_name = "Australia", 
+                                 region_source = "EEZ",
+                                 key = gfwr::gfw_auth())$id
+

The get_raster function gets a raster of fishing effort +from the API and converts the response to a data frame which contains +occurrences for each vessel and for each grid cell (data is binned into +grid cells of different resolution), the Vessel IDs, +Flag, Geartype and +Apparent fishing Hours which are basically the amount of +fishing hours of each vessel per grid cell (geometry).

+

Data can be provided through :
- DAILY, +MONTHLY and YEARLY temporal resolutions.
+- LOW (0.1 deg) and HIGH (0.01 deg) spatial +resolutions.
- VESSEL_ID, FLAG, +GEARTYPE, FLAGANDGEARTYPE.

+
gfwr::get_raster(
+  spatial_resolution = "LOW",
+  temporal_resolution = "MONTHLY",
+  group_by = "FLAGANDGEARTYPE",
+  start_date = "2022-01-01",
+  end_date = "2023-01-01",
+  region = region_id,
+  region_source = "EEZ",
+  key = gfwr::gfw_auth()
+)
+

(You can remove the option message = FALSE +to see the columns types.)

+
+

get_raster caveats and limitations.

+

Date range is limited to 1-year. Nevertheless, with some +modifications, we can get round these problems through +splnr_get_gfw.

+
data_sf_combined <- splnr_get_gfw(region = "Australia", 
+                                  start_date = "2019-01-01",
+                                  end_date =  "2023-12-31",
+                                  temp_res = "YEARLY",
+                                  spat_res = "LOW",
+                                  compress = FALSE)
+
+
+
+

Visualization

+

To display the data, we load :
- The coastline from +rnaturalearth package and modify it to get an sf object, +and we constrain it to the boundaries of the given data.
- EEZ +Polygons from oceandatr package

+
# Check and modify if necessary the spatial reference of data_sf_combined
+data_sf_combined <- sf::st_set_crs(data_sf_combined, 
+                                   sf::st_crs(rnaturalearth::ne_coastline(scale = "large")))
+
+coast_clipped <- rnaturalearth::ne_coastline(scale = "large") %>%
+  sf::st_as_sf() %>%
+  sf::st_intersection(sf::st_as_sfc(sf::st_bbox(data_sf_combined)))
+
+# Load EEZ polygons
+eezs <- spatialgridr::get_boundary(name = "Australia", type = "eez", country_type = "country") %>%
+  sf::st_transform(crs = sf::st_crs(data_sf_combined)) %>%
+  sf::st_make_valid() %>%
+  sf::st_intersection(sf::st_as_sfc(sf::st_bbox(data_sf_combined)))
+
+
+

Here we display the Fishing Effort in Australia from 2019 to +2023.

+
+

Raw Fishing Effort

+

+
+
+

By years

+

+
+
+

Year-on-year comparison

+

We may need to compare different timeframes, such as seasons, to see +if there are any patterns.
Note : As more vessels +have adopted AIS (mainly in economically developed countries) since the +deployment of these technologies, the rise in activities must be seen in +the context of this increase and not necessarily of more intense fishing +activity.

+
# We need to change the temporal range according to our need group by it to display the total fishing hours. <br>
+data_sf_combined <- splnr_get_gfw(region = "Australia", 
+                                  start_date = "2019-01-01", 
+                                  end_date = "2023-12-31", 
+                                  temp_res = "MONTHLY", 
+                                  key = gfwr::gfw_auth()) %>%
+  dplyr::group_by(Year, Month) %>%
+  dplyr::summarize(Total_Fishing_Hours = sum(ApparentFishingHrs))
+

+
+
+

Fishing gear type

+

Here we display the Vessel activity in ‘Micronesia’ in 2020 according +to the fishing gear type.

+
data_sf_combined <- splnr_get_gfw(region = "Micronesia", 
+                                  start_date = "2019-12-31", 
+                                  end_date = "2021-01-01", 
+                                  temp_res = "MONTHLY")
+

+
+
+

Flags

+

Here we display the Vessel activity in Papua New Guinea according to +Vessels flags.

+

+
+
+

Supplementary materials.

+

The fishing detection model was trained on AIS data from 503 vessels +and identified fishing activity with over 90% accuracy, which means that +it can identify a fishing and non-fishing activity with high accuracy. +More details on AIS operation and limitations here.

+
+
+

Hierarchy of vessels gear types :

+

Fishing Classification Hierarchy +

+

Source : https://globalfishingwatch.org/datasets-and-code-vessel-identity/ +

+
+
+
+ + + + + + + + + + + diff --git a/vignettes/MultipleUse.R b/vignettes/MultipleUse.R new file mode 100644 index 00000000..ce774d84 --- /dev/null +++ b/vignettes/MultipleUse.R @@ -0,0 +1,301 @@ +## ----include = FALSE---------------------------------------------------------- +knitr::opts_chunk$set( +collapse = TRUE, +comment = "#>", +warning = FALSE, +cache = FALSE, +message = FALSE, +eval = TRUE +) + +## ----setup-------------------------------------------------------------------- +library(spatialplanr) +set.seed(100) + +## ----------------------------------------------------------------------------- +Region <- "Coral Sea" # "Australia" +Type <- "Oceans" # "EEZ" + +## ----------------------------------------------------------------------------- +PU_size <- 107460 # m + +## ----------------------------------------------------------------------------- +cCRS <- "ESRI:54009" + +## ----------------------------------------------------------------------------- +Bndry <- splnr_get_boundary(Limits = Region, Type = Type, cCRS = cCRS) + +landmass <- rnaturalearth::ne_countries( + scale = "medium", + returnclass = "sf" +) %>% + sf::st_transform(cCRS) + +## ----------------------------------------------------------------------------- +PUs <- spatialgridr::get_grid(boundary = Bndry, + crs = cCRS, + output = "sf_hex", + resolution = PU_size) + + +## ----------------------------------------------------------------------------- +splnr_theme <- list( + ggplot2::theme_bw(), + ggplot2::theme( + legend.position = "right", + legend.direction = "vertical", + text = ggplot2::element_text(size = 9, colour = "black"), + axis.text = ggplot2::element_text(size = 9, colour = "black"), + plot.title = ggplot2::element_text(size = 9), + axis.title = ggplot2::element_blank() + ) +) + +## ----------------------------------------------------------------------------- +Dict <- tibble::tribble( + ~nameCommon, ~nameVariable, ~category, + "Green sea turtle", "Chelonia_mydas", "Reptiles", + "Loggerhead sea turtle", "Caretta_caretta", "Reptiles", + "Hawksbill sea turtle", "Eretmochelys_imbricata", "Reptiles", + "Olive ridley sea turtle", "Lepidochelys_olivacea", "Reptiles", + "Saltwater crocodile", "Crocodylus_porosus", "Reptiles", + "Humpback whale", "Megaptera_novaeangliae", "Mammals", + "Common Minke whale", "Balaenoptera_acutorostrata", + "Mammals", + "Dugong", "Dugong_dugon", "Mammals", + "Grey nurse shark", "Carcharias_taurus", "Sharks and rays", + "Tiger shark", "Galeocerdo_cuvier", "Sharks and rays", + "Great hammerhead shark", "Sphyrna_mokarran", + "Sharks and rays", + "Giant oceanic manta ray", "Mobula_birostris", "Sharks and rays", + "Reef manta ray", "Mobula_alfredi", "Sharks and rays", + "Whitetip reef shark", "Triaenodon_obesus", "Sharks and rays", + "Red-footed booby", "Sula_sula", "Birds" +) + +## ----------------------------------------------------------------------------- +datEx_species_bin <- spDataFiltered %>% + splnr_apply_cutoffs(Cutoffs = 0.5) + +col_name <- spDataFiltered %>% + sf::st_drop_geometry() %>% + colnames() + +## ----------------------------------------------------------------------------- +target <- rep(0.3, nrow(Dict)) + +p1 <- prioritizr::problem( + datEx_species_bin %>% dplyr::mutate(Cost1 = rep(1, 397)), + col_name, + "Cost1" +) %>% + prioritizr::add_min_set_objective() %>% + prioritizr::add_relative_targets(target) %>% + prioritizr::add_binary_decisions() %>% + prioritizr::add_default_solver(verbose = FALSE) + +## ----fig.width=9-------------------------------------------------------------- +s1 <- p1 %>% + prioritizr::solve.ConservationProblem() + +(ggSoln <- splnr_plot_solution(s1) + + splnr_gg_add(PUs = PUs, Bndry = Bndry, overlay = landmass, cropOverlay = PUs, ggtheme = splnr_theme)) + + +## ----------------------------------------------------------------------------- +s1T <- s1 %>% + dplyr::select(tidyselect::starts_with(c("solution"))) %>% + sf::st_drop_geometry() %>% + tibble::as_tibble() + +r1 <- prioritizr::eval_feature_representation_summary(p1, s1T) +print(r1) + +## ----------------------------------------------------------------------------- +target2 <- matrix(NA, ncol = 2, nrow = nrow(Dict)) +target2[, 1] <- 0.2 +target2[, 2] <- 0.05 + +## ----------------------------------------------------------------------------- +z2 <- prioritizr::zones("zone 1" = col_name, "zone 2" = col_name) + +## ----------------------------------------------------------------------------- +p2 <- prioritizr::problem( + datEx_species_bin %>% dplyr::mutate( + Cost1 = rep(1, 397), # when giving sf input, we need as many cost columns as we have zones + Cost2 = runif(n = dim(.)[[1]]) + ), + z2, + cost_column = c("Cost1", "Cost2") +) %>% + prioritizr::add_min_set_objective() %>% + prioritizr::add_relative_targets(target2) %>% + prioritizr::add_binary_decisions() %>% + prioritizr::add_default_solver(verbose = FALSE) + +s2 <- p2 %>% + prioritizr::solve.ConservationProblem() + +## ----fig.width = 9------------------------------------------------------------ +(gg_s2 <- splnr_plot_solution( + s2, + zones = TRUE, + colorVals = c("#c6dbef", "#3182bd", "black"), + legendLabels = c("Not selected", "Zone 1", "Zone 2") +) + + splnr_gg_add( + PUs = PUs, Bndry = Bndry, overlay = landmass, + cropOverlay = PUs, ggtheme = splnr_theme + )) + +## ----------------------------------------------------------------------------- +targets2b <- Dict %>% + dplyr::mutate( + targetZ1 = dplyr::if_else(category == "Reptiles", 30 / 100, 0), + targetZ2 = dplyr::if_else(category != "Reptiles", 10 / 100, 0) + ) %>% + dplyr::select("targetZ1", "targetZ2") %>% + as.matrix() + +## ----------------------------------------------------------------------------- +# NOTE: when using sf input, we need as many cost columns as we have zones +p2b <- prioritizr::problem( + datEx_species_bin %>% dplyr::mutate( + Cost1 = rep(1, 397), + Cost2 = runif(n = dim(.)[[1]]) + ), + z2, + cost_column = c("Cost1", "Cost2") +) %>% + prioritizr::add_min_set_objective() %>% + prioritizr::add_relative_targets(targets2b) %>% + prioritizr::add_binary_decisions() %>% + prioritizr::add_default_solver(verbose = FALSE) + +s2b <- p2b %>% + prioritizr::solve.ConservationProblem() + +## ----------------------------------------------------------------------------- +r2b <- s2b %>% + dplyr::select(tidyselect::starts_with(c("solution"))) %>% + sf::st_drop_geometry() %>% + tibble::as_tibble() %>% + prioritizr::eval_feature_representation_summary(p2b, .) +print(r2b, n = 45) + +## ----------------------------------------------------------------------------- +Dict[[1]][6] +Dict[[1]][7] + +## ----fig.width = 9------------------------------------------------------------ +(gg_s2b <- splnr_plot_solution( + s2b, + zones = TRUE, + colorVals = c("#c6dbef", "#3182bd", "black"), + legendLabels = c("Not selected", "Zone 1", "Zone 2") +) + + splnr_gg_add( + PUs = PUs, Bndry = Bndry, overlay = landmass, + cropOverlay = PUs, ggtheme = splnr_theme + )) + +## ----------------------------------------------------------------------------- +zm1 <- diag(2) +print(zm1) + +## ----------------------------------------------------------------------------- +p3 <- prioritizr::problem( + datEx_species_bin %>% dplyr::mutate( + Cost1 = rep(1, 397), # when giving sf input, we need as many cost columns as we have zones + Cost2 = runif(n = dim(.)[[1]]) + ), + z2, + cost_column = c("Cost1", "Cost2") +) %>% + prioritizr::add_min_set_objective() %>% + prioritizr::add_boundary_penalties(0.5, zone = zm1) %>% + prioritizr::add_relative_targets(target2) %>% + prioritizr::add_binary_decisions() %>% + prioritizr::add_default_solver(time_limit = 10, verbose = FALSE) + +s3 <- p3 %>% + prioritizr::solve.ConservationProblem() + +## ----fig.width=9-------------------------------------------------------------- +(gg_s3 <- splnr_plot_solution( + s3, + zones = TRUE, + colorVals = c("#c6dbef", "#3182bd", "black"), + legendLabels = c("Not selected", "Zone 1", "Zone 2") +) + + splnr_gg_add( + PUs = PUs, Bndry = Bndry, overlay = landmass, + cropOverlay = PUs, ggtheme = splnr_theme + )) + +## ----fig.width=9-------------------------------------------------------------- +zm2 <- zm1 +zm2[2, 2] <- 0 + +# NOTE: When using sf input, we need as many cost columns as we have zones +p4 <- prioritizr::problem( + datEx_species_bin %>% dplyr::mutate( + Cost1 = rep(1, 397), + Cost2 = runif(n = dim(.)[[1]]) + ), + z2, + cost_column = c("Cost1", "Cost2") +) %>% + prioritizr::add_min_set_objective() %>% + prioritizr::add_boundary_penalties(0.5, zone = zm2) %>% + prioritizr::add_relative_targets(target2) %>% + prioritizr::add_binary_decisions() %>% + prioritizr::add_default_solver(time_limit = 10, verbose = FALSE) + +s4 <- p4 %>% + prioritizr::solve.ConservationProblem() + +(gg_s4 <- splnr_plot_solution( + s4, + zones = TRUE, + colorVals = c("#c6dbef", "#3182bd", "black"), + legendLabels = c("Not selected", "Zone 1", "Zone 2") +) + + splnr_gg_add( + PUs = PUs, Bndry = Bndry, overlay = landmass, + cropOverlay = PUs, ggtheme = splnr_theme + )) + +## ----------------------------------------------------------------------------- +zm3 <- matrix(1, ncol = 2, nrow = 2) +print(zm3) + +## ----fig.width=9-------------------------------------------------------------- +p5 <- prioritizr::problem( + datEx_species_bin %>% dplyr::mutate( + Cost1 = rep(1, 397), # when giving sf input, we need as many cost columns as we have zones + Cost2 = runif(n = dim(.)[[1]]) + ), + z2, + cost_column = c("Cost1", "Cost2") +) %>% + prioritizr::add_min_set_objective() %>% + prioritizr::add_boundary_penalties(0.5, zone = zm3) %>% + prioritizr::add_relative_targets(target2) %>% + prioritizr::add_binary_decisions() %>% + prioritizr::add_default_solver(time_limit = 10, verbose = FALSE) + +s5 <- p5 %>% + prioritizr::solve.ConservationProblem() + +(gg_s5 <- splnr_plot_solution( + s5, + zones = TRUE, + colorVals = c("#c6dbef", "#3182bd", "black"), + legendLabels = c("Not selected", "Zone 1", "Zone 2") +) + + splnr_gg_add( + PUs = PUs, Bndry = Bndry, overlay = landmass, + cropOverlay = PUs, ggtheme = splnr_theme + )) + diff --git a/vignettes/MultipleUse.Rmd b/vignettes/MultipleUse.Rmd index 75387e47..fcee848b 100644 --- a/vignettes/MultipleUse.Rmd +++ b/vignettes/MultipleUse.Rmd @@ -123,7 +123,6 @@ datEx_species_bin <- spDataFiltered %>% col_name <- spDataFiltered %>% sf::st_drop_geometry() %>% - dplyr::select(-"cellID") %>% colnames() ``` @@ -425,10 +424,8 @@ When using zones with constraints, we use the `prioritizr` function `add_manual_ ```{r} mpas <- MPAsCoralSea %>% dplyr::mutate(zone = "zone 1") %>% - dplyr::rename( - pu = cellID, - status = wdpa - ) %>% + dplyr::rename(status = wdpa) %>% + tibble::rowid_to_column("pu") %>% sf::st_drop_geometry() %>% tibble::tibble() %>% dplyr::filter(status == 1) @@ -580,19 +577,17 @@ We then need to bring our data in a specific format that requires us to have an ```{r} datSpecZone1 <- datEx_species_bin %>% - sf::st_drop_geometry() %>% - dplyr::rename_at(dplyr::vars(-cellID), ~ paste0(.x, "_zone1")) + dplyr::rename_at(dplyr::vars(-geometry), ~ paste0(.x, "_zone1")) featuresZone1 <- datSpecZone1 %>% - dplyr::select(-"cellID") %>% + sf::st_drop_geometry() %>% colnames() datSpecZone2 <- datEx_species_bin %>% - sf::st_drop_geometry() %>% - dplyr::rename_at(dplyr::vars(-cellID), ~ paste0(.x, "_zone2")) + dplyr::rename_at(dplyr::vars(-geometry), ~ paste0(.x, "_zone2")) featuresZone2 <- datSpecZone2 %>% - dplyr::select(-"cellID") %>% + sf::st_drop_geometry() %>% colnames() ``` @@ -607,9 +602,7 @@ z10 <- prioritizr::zones( ) out_sf <- datSpecZone1 %>% - dplyr::left_join(datSpecZone2, by = "cellID") %>% - dplyr::mutate(geometry = datEx_species_bin$geometry) %>% - sf::st_as_sf() %>% + sf::st_join(datSpecZone2, join = sf::st_equals) %>% dplyr::mutate( Cost1 = runif(n = dim(.)[[1]]) * 100, Cost2 = runif(n = dim(.)[[1]]) * 300 @@ -751,27 +744,24 @@ We then create a zones object for three different zones: ```{r} datSpecZone1 <- datEx_species_bin %>% - sf::st_drop_geometry() %>% - dplyr::rename_at(dplyr::vars(-cellID), ~ paste0(.x, "_zone1")) + dplyr::rename_at(dplyr::vars(-geometry), ~ paste0(.x, "_zone1")) featuresZone1 <- datSpecZone1 %>% - dplyr::select(-"cellID") %>% + sf::st_drop_geometry() %>% colnames() datSpecZone2 <- datEx_species_bin %>% - sf::st_drop_geometry() %>% - dplyr::rename_at(dplyr::vars(-cellID), ~ paste0(.x, "_zone2")) + dplyr::rename_at(dplyr::vars(-geometry), ~ paste0(.x, "_zone2")) featuresZone2 <- datSpecZone2 %>% - dplyr::select(-"cellID") %>% + sf::st_drop_geometry() %>% colnames() datSpecZone3 <- datEx_species_bin %>% - sf::st_drop_geometry() %>% - dplyr::rename_at(dplyr::vars(-cellID), ~ paste0(.x, "_zone3")) + dplyr::rename_at(dplyr::vars(-geometry), ~ paste0(.x, "_zone3")) featuresZone3 <- datSpecZone3 %>% - dplyr::select(-"cellID") %>% + sf::st_drop_geometry() %>% colnames() z12 <- prioritizr::zones( @@ -788,8 +778,8 @@ We then create a joint `sf` object of all zones and their respective costs. ```{r} # NOTE: When using sf input, we need as many cost columns as we have zones out_sf <- datSpecZone1 %>% - dplyr::left_join(datSpecZone2, by = "cellID") %>% - dplyr::left_join(datSpecZone3, by = "cellID") %>% + sf::st_join(datSpecZone2, join = sf::st_equals) %>% + sf::st_join(datSpecZone3, join = sf::st_equals) %>% dplyr::mutate(geometry = datEx_species_bin$geometry) %>% sf::st_as_sf() %>% dplyr::mutate( diff --git a/vignettes/spatialplanr.R b/vignettes/spatialplanr.R new file mode 100644 index 00000000..10467e0c --- /dev/null +++ b/vignettes/spatialplanr.R @@ -0,0 +1,99 @@ +## ----include = FALSE---------------------------------------------------------- +knitr::opts_chunk$set( +collapse = TRUE, +comment = "#>", +warning = FALSE, +cache = FALSE, +message = FALSE, +eval = TRUE, +fig.width = 9 +) + +## ----setup-------------------------------------------------------------------- +# library(spatialplanr) +devtools::load_all() + +## ----------------------------------------------------------------------------- +Region <- "Coral Sea" # "Australia" +Type <- "Oceans" # "EEZ" + +## ----eval=FALSE--------------------------------------------------------------- +# Region <- c(xmin = 150, xmax = 160, ymin = -40, ymax = -30) + +## ----------------------------------------------------------------------------- +cCRS <- "ESRI:54009" + +## ----------------------------------------------------------------------------- +PU_size <- 107460 # m + +## ----------------------------------------------------------------------------- +Bndry <- splnr_get_boundary(Limits = Region, Type = Type, cCRS = cCRS) + +## ----------------------------------------------------------------------------- +landmass <- rnaturalearth::ne_countries( + scale = "medium", + returnclass = "sf" +) %>% + sf::st_transform(cCRS) + +## ----------------------------------------------------------------------------- +PUs <- spatialgridr::get_grid(boundary = Bndry, + crs = cCRS, + output = "sf_hex", + resolution = PU_size) + + +## ----------------------------------------------------------------------------- +(ggPU <- splnr_plot(df = PUs) + + ggplot2::theme_bw()) # Plot Planning Units + +## ----------------------------------------------------------------------------- +(ggPU <- splnr_plot(df = PUs) + + splnr_gg_add( + Bndry = Bndry, overlay = landmass, + cropOverlay = PUs, ggtheme = "Default" + )) + +## ----------------------------------------------------------------------------- +splnr_theme <- list( + ggplot2::theme_bw(), + ggplot2::theme( + legend.position = "right", + legend.direction = "vertical", + text = ggplot2::element_text(size = 9, colour = "black"), + axis.text = ggplot2::element_text(size = 9, colour = "black"), + plot.title = ggplot2::element_text(size = 9), + axis.title = ggplot2::element_blank() + ) +) + +(ggPU <- splnr_plot(PUs) + + splnr_gg_add( + Bndry = Bndry, overlay = landmass, + cropOverlay = PUs, ggtheme = splnr_theme + )) + +## ----------------------------------------------------------------------------- +Dict <- tibble::tribble( + ~nameCommon, ~nameVariable, ~category, + "Green sea turtle", "Chelonia_mydas", "Reptiles", + "Loggerhead sea turtle", "Caretta_caretta", "Reptiles", + "Hawksbill sea turtle", "Eretmochelys_imbricata", "Reptiles", + "Olive ridley sea turtle", "Lepidochelys_olivacea", "Reptiles", + "Saltwater crocodile", "Crocodylus_porosus", "Reptiles", + "Humpback whale", "Megaptera_novaeangliae", "Mammals", + "Common Minke whale", "Balaenoptera_acutorostrata", "Mammals", + "Dugong", "Dugong_dugon", "Mammals", + "Grey nurse shark", "Carcharias_taurus", "Sharks and rays", + "Tiger shark", "Galeocerdo_cuvier", "Sharks and rays", + "Great hammerhead shark", "Sphyrna_mokarran", "Sharks and rays", + "Giant oceanic manta ray", "Mobula_birostris", "Sharks and rays", + "Reef manta ray", "Mobula_alfredi", "Sharks and rays", + "Whitetip reef shark", "Triaenodon_obesus", "Sharks and rays", + "Red-footed booby", "Sula_sula", "Birds" +) + +## ----------------------------------------------------------------------------- +datEx_species_bin <- dat_species_prob %>% + splnr_apply_cutoffs(Cutoffs = 0.5) + diff --git a/vignettes/spatialplanr.Rmd b/vignettes/spatialplanr.Rmd index 21ee3b87..dd190c8a 100644 --- a/vignettes/spatialplanr.Rmd +++ b/vignettes/spatialplanr.Rmd @@ -98,7 +98,6 @@ We can check what the PUs look like ggplot2::theme_bw()) # Plot Planning Units ``` - If we want to add additional properties to our map, for example landmass or the boundary, we can use `splnr_gg_add()`. @@ -226,8 +225,7 @@ planning unit of the study region. ```{r} (ggFeatNo <- splnr_plot(df = datEx_species_bin, col_names = colnames(datEx_species_bin %>% - sf::st_drop_geometry() %>% - dplyr::select(-"cellID")), + sf::st_drop_geometry()), plot_title = "", legend_title = "Number of features") + splnr_gg_add( @@ -236,7 +234,7 @@ planning unit of the study region. )) ``` -### Prepare Data for prioritisation +## Prepare Data for prioritisation For the spatial prioritization we also need to extract the names of our features to pass into `prioritizr`. @@ -327,7 +325,7 @@ splnr_plot(df = bathymetry, col_names = "bathymetry", plot_title = "") + -#### Set Targets +## Set Targets As shown previously, we assigned the conservation features a class reflecting their importance in the planning region. Conservation targets @@ -344,7 +342,7 @@ target <- Dict %>% **Note:** The assigned classes and targets were not based on any ecological information and only chosen for visualization purposes. -### Set up conservation problem +## Set up conservation problem ```{r} datEx_problem <- prioritizr::problem(out_sf, feature_names, "Cost_None") %>% @@ -354,21 +352,21 @@ datEx_problem <- prioritizr::problem(out_sf, feature_names, "Cost_None") %>% prioritizr::add_default_solver(verbose = FALSE) ``` -### Solve the conservation problem +## Solve the conservation problem ```{r} datEx_soln <- datEx_problem %>% prioritizr::solve.ConservationProblem() ``` -### Visualize Output +## Visualize Output There are different ways to visualize the output of the prioritization that can be loosely grouped into three categories: *+* Visualization of the solution *+* Visualization of targets *+* Visualization of importance scores -#### Visualization of the solution +### Visualization of the solution ```{r} (ggSoln <- splnr_plot(datEx_soln, @@ -402,7 +400,7 @@ overlay of the cost to show how the solution avoids highly costly areas: **Note:** In our example, cost is equal for all planning units. -#### Visualization of targets +### Visualization of targets To visualize how well the targets are met, we first need to extract how much suitable habitat of each feature are selected in the spatial plan. @@ -430,20 +428,20 @@ For a circular bar plot, one additional step of data preparation needs to be done. ```{r, eval=FALSE} -# dfTargetCirc <- dfTarget %>% -# dplyr::select("feature", "value", "group") %>% -# na.omit() +dfTargetCirc <- dfTarget %>% +dplyr::select("feature", "value", "group") %>% +na.omit() -# colors <- c( -# "important" = "darkgreen", -# "representative" = "darkred" -# ) -# legends <- c("Important", "Representative") +colors <- c( + "important" = "darkgreen", + "representative" = "darkred" +) +legends <- c("Important", "Representative") -# (ggCircTarg <- splnr_plot_circBplot(df = dfTargetCirc, legend_list = legends, legend_color = colors, impTarget = 30, repTarget = 10)) +(ggCircTarg <- splnr_plot_circBplot(df = dfTargetCirc, legend_list = legends, legend_color = colors, impTarget = 30, repTarget = 10)) ``` -#### Visualization of importance scores +### Visualization of importance scores Importance scores can help to assess the relative importance of an individual selected planning unit in the spatial plan (for more @@ -483,7 +481,7 @@ ggRWR <- splnr_plot_importanceScore( In our example, both scores label similar -coastal- planning units as most important for the spatial plan. -### Comparing Spatial Plans +## Comparing Spatial Plans Sometimes it can be useful to have a direct comparison of two spatial plans. To show how to achieve this with this package, we first need a @@ -556,7 +554,7 @@ IUCN_IA_Targets <- IA_Targets %>% `Sys.setenv(IUCN_REDLIST_KEY = "[Your Token]")`. You can start by running `rredlist::rl_use_iucn()`. -#### Set up second conservation problem +### Set up second conservation problem ```{r} datEx_problem2 <- prioritizr::problem(out_sf, feature_names, "Cost_None") %>% @@ -604,7 +602,7 @@ can set `typeLockIn = "Contours"`in `splnr_gg_add()`. )) ``` -#### Visualize comparison +### Visualize comparison ```{r} (ggComp <- splnr_plot_comparison(datEx_soln, datEx_soln2) + @@ -635,7 +633,7 @@ correlation between solution 1 and solution 2. ### Plotting selection frequency -Sometimes when multiple spatial plans are generated, we are interesting +Sometimes when multiple spatial plans are generated, we are interested in how many times a planning unit is selected across the array of solutions. To demonstrate how this can be done using this package, we first create an array (= portfolio) of solutions. One example of this is