# Example 1 with current suitabilities
data(Species)
data(Current)
library(terra)
Test <- Species[[1]] |>
terra::unwrap()
Current <- terra::unwrap(Current)
# Generate the "Problem.dat" file
TroublemakeR::troublemaker(Rasterdomain =Test[[1]],
Rastercurrent = Current,
species_names = c("Spp1", "Spp2", "Spp3", "Spp4"),
name = "Problem")
# delete the file so the test on cran can pass this
file.remove("Problem.dat")
# Example 2 with landuse suitabilities
data(Species)
data("Species_Landuse")
library(terra)
Test <- Species[[1]] |>
terra::unwrap()
Species_Landuse <- Species_Landuse |> purrr::map(terra::unwrap)
# Generate the "Problem2.dat" file
TroublemakeR::troublemaker(Rasterdomain =Test[[1]],
Rasterspecieslanduse = Species_Landuse,
species_names = c("Spp1", "Spp2", "Spp3", "Spp4"),
landuses = c("Agriculture", "Forest", "Urban"),
name = "Problem2")
# delete the file so the test on cran can pass this
file.remove("Problem2.dat")
# Example 3 with budget and transition cost
data("CurrentLanduse")
CurrentLU <- terra::unwrap(CurrentLanduse)
TroublemakeR::troublemaker(Rasterdomain =Test[[1]],
Rasterspecieslanduse = Species_Landuse,
species_names = c("Spp1", "Spp2", "Spp3", "Spp4"),
landuses = c("Agriculture", "Forest", "Urban"),
Rastercurrentlanduse = CurrentLU,
budget = 2,
name = "Problem3",
verbose = FALSE)
file.remove("Problem3.dat")
Run the code above in your browser using DataLab