Skip to contents

Regrids polygon attributes onto grid cells by overlap area, using the table from poly_cell_overlap(). For each attribute v and cell c: $$v_c = \sum_p v_p A(p \cap c) / \sum_p A(p \cap c)$$ over the polygons p overlapping c; a polygon whose v is NA drops out of that attribute's weights only. Also returns the covered area of each cell, area_km2 \(= \sum_p A(p \cap c)\), and its covered fraction frac = area_km2 / cell area.

Usage

cells_area_mean(overlap, values)

Arguments

overlap

tibble from poly_cell_overlap() (poly_i, cell_id, area_km2, cell_km2)

values

data frame of numeric attributes, one row per polygon of the x given to poly_cell_overlap() (row i is poly_i == i)

Value

a tibble (cell_id, <one column per attribute of values>, area_km2, frac) sorted by cell_id; an attribute is NA in a cell where every overlapping polygon has it NA

Details

For an intensive quantity such as a density (animals km^-2) the mean conserves the total: sum(v * area_km2) over cells equals sum(v_p * A_p) over polygons, which is how an ingest checks a regridded abundance against the source. Weighting a CV the same way is only an approximation (CVs of overlapping parts do not average linearly).