
Simulate Coral Population Layout from Posterior Predictions
simulate_populations.RdGenerates 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
sfpolygon representing the area in which colonies will be positioned.- size
A data frame containing
speciesand size distribution (areaorwidth).- community
A data frame containing
speciesandaerial(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, whilecircleProgressiveLayout()is faster and approximate.Coordinates are assigned using
sf::st_sample()and radii are scaled to match overlap assumptions.