Skip to contents

This function computes area, perimeter, and perimeter-to-area ratio for a set of spatial solutions. It processes solution data in parallel for improved performance when dealing with large datasets.

Usage

spatial_stats(
  data = NULL,
  spatial = NULL,
  cores = NULL,
  batch_size = NULL,
  max_batch_size = 1000
)

Arguments

data

A data frame of solutions or a path to a CSV file. Must include a 'units' column containing JSON strings representing the selected planning units for each solution.

spatial

An sf object or path to spatial data file containing polygons of planning units. Defaults to the example spatial dataset included with optimTFE.

cores

Number of CPU cores to use for parallel processing. If NULL, uses one less than the available cores.

batch_size

Number of solutions to process in each batch. If NULL, automatically calculated based on cores and data size.

max_batch_size

Maximum allowed batch size for processing.

Value

A data frame with the original solution data plus three new columns:

area

Total area of the selected planning units

perimeter

Total perimeter of the selected planning units, accounting for shared boundaries

pa_ratio

Perimeter-to-area ratio, a measure of compactness