Skip to contents

Generates a spatial coral population layout by drawing from a brms-fit model of colony sizes, filtering to match aerial coverage constraints, and laying out colonies with optional circle packing.

Usage

simulate_populations(
  setplot,
  size,
  community,
  posterior = coralsizepredictions,
  return = "df",
  algorithm = "repel",
  ndraws = 20000,
  maxiter = 100,
  seed = NULL,
  quiet = TRUE,
  ...
)

Arguments

setplot

An sf polygon representing the area in which colonies will be positioned.

size

A data frame containing species and size distribution (area or width).

community

A data frame containing species and aerial (m²) coverage values.

posterior

A return from posterior_coral_predict of colony size by species.

return

Character. "df" returns the raw colony list; "sf" returns spatial polygons. Default: "df".

algorithm

Character. "repel" (default) or "progressive" — determines the circle packing layout method.

ndraws

Integer. Number of posterior predictive draws to simulate. Default: 50000.

seed

Optional integer for reproducibility of sampling and layout.

quiet

verbose

Value

Either a data frame of simulated colonies (df) or an sf object of spatial polygons (sf) depending on return.

Details

  • Species names are harmonized using fct_recode.

  • Aerial coverage is enforced using cumulative area filtering.

  • circleRepelLayout() uses an iterative physics-based algorithm, while circleProgressiveLayout() is faster and approximate.

  • Coordinates are assigned using sf::st_sample() and radii are scaled to match overlap assumptions.

Examples

if (FALSE) { # \dontrun{
simulate_populations(setplot = myreef_sf, size = colony_data, community = community_df,
                     brms = size_model, return = "sf", algorithm = "repel", seed = 42, plot = TRUE)
} # }