Mapbox terrain-rgb stores global elevation packed into Byte integers.
unpack_rgb(x, filename = "")
three layer raster object
optional, filename to store the output
terra rast object with one numeric layer
This function unpacks the three layers of a raster to give floating point elevation data.
if (interactive() && !is.null(get_api_key())) {
unpack_rgb(read_tiles(type = "mapbox.terrain-rgb"))
}