# \donttest{
library(terra)
n1_small <- rast(system.file("input_maps/n1_small.tif", package = "rangr"))
K_small <- rast(system.file("input_maps/K_small.tif", package = "rangr"))
# prepare data
sim_data <- initialise(
n1_map = n1_small,
K_map = K_small,
r = log(2),
rate = 1 / 1e3
)
sim_1 <- sim(obj = sim_data, time = 110, burn = 10)
# 1. random_one_layer
sample1 <- get_observations(
sim_data,
sim_1,
type = "random_one_layer",
prop = 0.1
)
# 2. random_all_layers
sample2 <- get_observations(
sim_data,
sim_1,
type = "random_all_layers",
prop = 0.15
)
# 3. from_data
sample3 <- get_observations(
sim_data,
sim_1,
type = "from_data",
points = observations_points
)
# 4. monitoring_based
# define observations sites
all_points <- xyFromCell(unwrap(sim_data$id), cells(unwrap(sim_data$K_map)))
sample_idx <- sample(1:nrow(all_points), size = 20)
sample_points <- all_points[sample_idx, ]
sample4 <- get_observations(
sim_data,
sim_1,
type = "monitoring_based",
cells_coords = sample_points,
prob = 0.3,
progress_bar = TRUE
)
# 5. noise "rlnorm"
sample5 <- get_observations(sim_data,
sim_1,
type = "random_one_layer",
obs_error = "rlnorm",
obs_error_param = log(1.2)
)
# 6. noise "rbinom"
sample6 <- get_observations(sim_data,
sim_1,
type = "random_one_layer",
obs_error = "rbinom",
obs_error_param = 0.8
)
# }
Run the code above in your browser using DataLab