Choosing a PRIO-GRID conversion workflow
Source:vignettes/conversion-workflows.Rmd
conversion-workflows.RmdpriogridR provides one conversion function for each
common source-data format. All converters use a
priogrid::pg_config() object as the source of truth for the
target grid and temporal resolution.
Choose a converter
| Source data | Function | Typical task |
|---|---|---|
| Point events or coordinate columns | pg_from_points() |
Count events or summarize their values by cell and period |
| Raster layers | pg_from_raster() |
Align continuous or categorical raster values to PRIO-GRID |
| Point, line, or polygon geometry | pg_from_vector() |
Calculate counts, lengths, areas, coverage, or weighted values |
| NetCDF variables | pg_from_netcdf() |
Select variables and layers before raster conversion |
| Values indexed by geographic units | pg_from_table() |
Join a table to polygons and transfer the values to cells |
The detailed guides are available through:
A shared configuration
A small configuration is useful for examples and exploratory work:
config <- priogrid::pg_config(
nrow = 18,
ncol = 36,
temporal_resolution = "1 year",
start_date = as.Date("2020-12-31"),
end_date = as.Date("2022-12-31"),
verbose = FALSE
)Use the default priogrid::pg_current_config() when the
official global half-degree grid is required.
Common return types
Every converter accepts a return argument:
-
return = "data"returns a cell-level data frame; -
return = "raster"returns aterra::SpatRaster; and -
return = "result"returns apg_resultcontaining data, raster, and conversion metadata.
The default is "data". Use
pg_write_result() to save tabular or raster outputs, or
pass filename directly to a converter.
General advice
Check the coordinate reference system before conversion, distinguish missing values from meaningful zeros, and choose an aggregation rule that matches the meaning of the source variable. In particular, totals generally require a different transfer rule from rates, proportions, or categories.