Skip to contents

The v8+ global05 grid was anchored to the shared 0.05° -180,180 topology of Bio-Oracle and AquaX so that such a raster maps to cell_id by position: pixel i of the source is pixel i of the cell-id COG. This reads the cell ids at the source's non-NA pixels rather than assuming cell_id == i — on global05 the two coincide (and the AquaX ingest asserts it), while a lookup-image grid (usa05's r_cellid.tif) carries ids that are not positions. Land pixels (NA in the cell-id raster) are dropped.

Usage

cells_from_aligned_raster(
  x,
  cellid_tif,
  band = 1,
  scale = 1,
  min_value = 1,
  digits = 2,
  tol = 1e-04
)

Arguments

x

a SpatRaster (one layer) or a path; band selects the layer from a path

cellid_tif

path to the grid's cell-id COG, OR an integer vector of cell ids read from it once (terra::values(rast(cellid_tif), mat = FALSE)) — pass the vector when calling in a loop, so the 100 MB id raster is read once per worker, not once per model

band

layer index when x is a path (default 1)

scale

multiply source values by this (AquaX 0–1000 → 0.1 gives the 0,100 scale)

min_value

drop scaled values below this (default 1, like AquaMaps)

digits

rounding of val (default 2)

tol

extent tolerance in degrees (default 1e-4; the cell-id COG carries ~6e-6 of float drift against the nominal grid)

Value

a tibble (cell_id integer, val double)

Details

No resample, no zero-fill, no land mask: the source's own values define coverage.