Saves a terra SpatRaster as a Cloud-Optimized GeoTIFF (COG) under the
cog/ sub-directory of the dataset root. The variable must be listed
in pgvariables. Layer names, time(), and units() are
preserved natively inside the .tif. Plot metadata from pgvariables
(label, unit, transform, plot_type) is stamped as
pg_* GDAL metatags so the COG is self-describing. In addition,
pg_colormap (derived from plot_type), pg_value_min,
pg_value_max, pg_value_mean, pg_value_std (computed
from the raster at save time), and — for discrete variables —
pg_nunique and pg_class_values are also stamped.
value_*, nunique, and class_values are computed from
the raster at save time; colormap is derived from plot_type.
These map directly onto rio-tiler/TiTiler rescale and
colormap_name.
Usage
save_pgvariable(rast, varname, save_to = pgout_path())Examples
if (FALSE) { # \dontrun{
r <- gen_ne_disputed_area_share()
save_pgvariable(r, "ne_disputed_area_share")
} # }