pack_minmax: Helper function to define packed data exports by min / max...

Description Usage Arguments Details Note Examples

View source: R/cube.R

Description

This function can be used to define packed exports in write_ncdf and write_tif. It will generate scale and offset values with maximum precision (unless simplify=TRUE).

Usage

1
pack_minmax(type = "int16", min, max, simplify = FALSE)

Arguments

type

target data type of packed values (one of "uint8", "uint16", "uint32", "int16", or "int32")

min

numeric; minimum value(s) of original values, will be packed to the 2nd lowest value of the target data type

max

numeric; maximum value(s) in original scale, will be packed to the highest value of the target data type

simplify

logical; round resulting scale and offset to power of 10 values

Details

Nodata values will be mapped to the lowest value of the target data type.

Arguments min and max must have length 1 or length equal to the number of bands of the data cube to be exported. In the former case, the same values are used for all bands of the exported target cube, whereas the latter case allows to use different ranges for different bands.

Note

Using simplify=TRUE will round scale values to the next smaller power of 10.

Examples

1
2
ndvi_packing = pack_minmax(type="int16", min=-1, max=1)
ndvi_packing

gdalcubes documentation built on Oct. 28, 2021, 5:06 p.m.