The one scoring method (master-plan decisions D7 and D7b). Returns a
flower-plot-ready tibble: metric_key, score, component, even, plus
coverage and mean_where_present, which are what make a sliver readable as a
sliver instead of as a high score.
Usage
scores_for_cells(
con,
cells,
metric_pattern = "_ecoregion_rescaled$",
blend = TRUE,
denominator = c("study_area", "all")
)Arguments
- con
a DBI connection (e.g. from
sdm_db_con())- cells
a tibble from
cells_in_polygon()orcells_in_pra(), with columnscell_idandpct_covered- metric_pattern
regex to filter
metric.metric_key(default:"_ecoregion_rescaled$"; the$is what excludes the_prepctareaweightingrows)- blend
use the published coverage blend (
TRUE, default) or the old present-cells-only mean (FALSE)- denominator
"study_area"(default, D7b) or"all"(exact zone parity)
The coverage blend (blend = TRUE, the default)
A published zone_metric is, exactly,
$$\sum(\mathrm{coalesce}(val, 0) \cdot pct) / \sum(pct)$$
over every cell of the zone — verified to reproduce all 795 v9 rows. The old
scores_for_cells() computed \(\sum(val \cdot pct) / \sum(pct)\) over only the
cells that HAVE the metric, which is the _prepctareaweighting intermediate, not
the published number. A drawn polygon exactly tracing a Program Area therefore
reported a different, systematically HIGHER score than the same area picked from
the list: up to 49.1 points on turtle (St George Basin, 1.4 % coverage), 20.3 on
primary producer, 9.6 on coral, and up to 6.28 on the composite.
blend = TRUE computes the published method. blend = FALSE reproduces the old
reports and is kept only for that.
The denominator (denominator)
"study_area" (default) first clips the supplied cells to the release's study
area with cells_in_study_area() — the cells present in cell with
coalesce(in_usa, TRUE). "Absent means zero" is only sound where a value could
have existed, so land and foreign waters must not enter as zeros; a place half
over land would otherwise score half of what it is.
"all" skips the clip and is exact zone parity (what zone_cell does, including
its non-in_usa rows). Measured on the 20 Program Areas the two differ by at most
0.08 composite points, median 0.03.
Reading the result
coverage is the share of the denominator weight held by cells that carry the
component, and mean_where_present is the mean over just those cells. The
identity score = coverage * mean_where_present holds when blend = TRUE, so a
panel can say "17.7, over 1.4 % of the place" rather than implying 17.7 everywhere.
A component with no covered cell at all yields no row — never a zero — so it
is excluded from mean_score() exactly as an unreportable component is.