2

Given a raster timeseries (satellite images within the same spatial extent each taken on a different date), how can I add the date as name for each layer/band in a (Geo)Tiff? Is it probably underspecified?

Using R as an example:

library(rgdal)
library(raster)

## example data (taken from https://rspatial.org/raster/rs/1-introduction.html#data)
dir.create('/tmp/data', showWarnings = FALSE)
if (!file.exists('/tmp/data/rs/samples.rds')) {
  download.file('https://biogeo.ucdavis.edu/data/rspatial/rsdata.zip', dest = '/tmp/data/rsdata.zip')
  unzip('/tmp/data/rsdata.zip', exdir='/tmp/data')
}

## just two raster layers
layers <- c("/tmp/data/rs/LC08_044034_20170614_B1.tif", "/tmp/data/rs/LC08_044034_20170614_B2.tif")
lc_stack <- raster::stack(layers)

## set arbitrary timestamps
lc_stack_z <- setZ(lc_stack,c("2019-09-20", "2019-09-21"))

timeseries_rs <- writeRaster(lc_stack_z, "/tmp/data/rs/timeseries-raster.tiff", "GTiff")

The gdalinfo output is as follows (no band name information):

[...]
Band 1 Block=1497x1 Type=Float32, ColorInterp=Gray
  Min=0.096 Max=0.735 
  Minimum=0.096, Maximum=0.735, Mean=nan, StdDev=nan
  NoData Value=-3.39999999999999996e+38
  Metadata:
    STATISTICS_MAXIMUM=0.73462820053101
    STATISTICS_MEAN=nan
    STATISTICS_MINIMUM=0.096417911350727
    STATISTICS_STDDEV=nan
Band 2 Block=1497x1 Type=Float32, ColorInterp=Undefined
  Min=0.075 Max=0.718 
  Minimum=0.075, Maximum=0.718, Mean=nan, StdDev=nan
  NoData Value=-3.39999999999999996e+38
  Metadata:
    STATISTICS_MAXIMUM=0.71775615215302
    STATISTICS_MEAN=nan
    STATISTICS_MINIMUM=0.074839904904366
    STATISTICS_STDDEV=nan

There is a Tiff Tag Library but there I can't find any (semantically appropriate) tag which would serve my need.

Is there a good practice how to add layer/band names to a (Geo)Tiff -- optimally which can be interpreted/read by other Software like QGis.

0 Answers0