knitr::opts_chunk$set(echo=T, message=F)
library(prioritizr) # devtools::load_all("~/github/prioritizr") library(bbnj) # devtools::load_all() # devtools::install_local(force=T) library(raster) library(sf) library(dplyr) library(stringr) library(glue) library(here) library(fs) library(knitr) library(formattable) area = raster::area select = dplyr::select rmd <- knitr::current_input(dir = T) #rmd <- file.path(getwd(), "s01a.bio.10pct.gl.now.Rmd") pfx <- rmd %>% path_ext_remove()
r basename(pfx)Obtain 30% for each future (2100) biodiversity and habitat target in the high seas with regional representation of the Seven Seas.
# variables: target 30% ---- rel_target <- 0.3 redo <- T # planning unit: cost by area ---- r_pu <- area(r_pu_id) %>% mask(r_pu_id) # plot(r_pu) # biodiversity: 2100 ---- lyrs_bio_future <- str_subset(names(s_bio_gmbi), "2100$") %>% setdiff(c("nspp_all_2100", "nspp_na_2100", "rls_all_2100", "rls_na_2100")) s_bio_future <- subset(s_bio_gmbi, lyrs_bio_future) # features ---- s_features <- stack( r_vgpm, s_bio_future, #raster(s_fish_gfw, "mean_scaled_profits_with_subsidies") %>% # gap_fill_raster() %>% # rescale_raster(inverse=T), #raster(s_fish_ubc, "mcp_2004"), r_phys_seamounts, r_phys_vents, s_phys_scapes, s_ihor) names(s_features) <- c( "bio_vgpm", names(s_bio_future), #"fish_profit.subs" #"fish_mcp.2004", "phys_seamounts", "phys_vents", glue("phys_scape.{1:11}"), glue("sea_{names(s_ihor)}")) # problem ---- p <- problem(r_pu, s_features) %>% add_min_set_objective() %>% add_relative_targets(rel_target) # solve ---- s <- solve_log(p, pfx, redo=redo) # plot tbl_target_representation(glue("{pfx}_rep.csv"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.