Skip to contents

One row per species within a named zone (subregion_key, programarea_key or ecoregion_key), aggregated with pct_covered weighting.

Usage

species_for_zone(con, zone_fld, zone_val, use_precomputed = TRUE)

Arguments

con

a DBI connection to an sdm.duckdb

zone_fld

zone field, e.g. "programarea_key"

zone_val

zone value, e.g. "GAA"

use_precomputed

read an existing zone_taxon table when present. FALSE forces the live aggregation — which is what build_zone_taxon() needs, since it must not rebuild the table out of its own previous output.

Value

tibble, same shape as species_for_cells(), whichever release's schema the connection holds

Details

Computed live from zone_cell + model_cell + taxon rather than read from a precomputed table: v7 shipped a zone_taxon table, but v8 does not build one, which left the app's species table broken. Measured on the v8 database, the largest zone (subregion_key = "USA", ~349k cells, ~10k species) takes ~5 s, so precomputation is not required.