Skip to contents

Runs ss_kl_optimize() starting from predictor rasters (a file path, a directory of .tif files, or an already-loaded SpatRaster) or directly from a population data frame. Optionally writes results and plots to disk.

Usage

ss_kl_size(
  x,
  output_dir = NULL,
  max_population = 1e+05,
  min_samples = 10,
  max_samples = 500,
  step_size = 10,
  n_replicates = 10,
  n_bins = 25,
  probability_threshold = 0.95
)

Arguments

x

One of: a character path to a .tif file or a directory of .tif files, a SpatRaster stack, or a data frame of population ancillary data (used as-is, skipping raster extraction).

output_dir

Character, directory to write CSV/PNG outputs to. If NULL (default), nothing is written to disk.

max_population

Integer, if the population has more rows than this, a random subsample of this size is used to keep runtime reasonable. Default 100000.

min_samples, max_samples, step_size, n_replicates, n_bins, probability_threshold

Passed to ss_kl_optimize().

Value

The list returned by ss_kl_optimize(), plus a file_paths element (only when output_dir is supplied) listing the files written.

Examples

if (FALSE) { # \dontrun{
res <- ss_kl_size("predictors.tif", output_dir = file.path(tempdir(), "kl"))
res$optimal_sample_size
} # }