Learn R Programming

RStoolbox (version 1.0.0)

getMeta: Extract bandwise information from ImageMetaData

Description

This is an accessor function to quickly access information stored in ImageMetaData, e.g. scale factor per band. Intended for use with imagery which was imported using stackMeta. Will return parameters using the actual band order in img.

Usage

getMeta(img, metaData, what)

Value

If what is one of c('CALRAD', 'CALBT', 'CALREF') a data.frame is returned with bands in rows (order corresponding to img band order). Otherwise a named numeric vector with the corresponding parameter is returned (layernames as names).

Arguments

img

SpatRaster or character vector with band names.

metaData

ImageMetaData or path to meta data file.

what

Character. Parameter to extract. Either data descriptors, or conversion parameters (see Details for options)

Details

Possible metadata parameters (what argument):

Data descriptors

'FILES'
'QUANTITY'
'CATEGORY'
'NA_VALUE'
'SATURATE_VALUE'
'SCALE_FACTOR'
'DATA_TYPE'
'SPATIAL_RESOLUTION'

Conversion parameters

'CALRAD'Conversion parameters from DN to radiance
'CALBT'Conversion parameters from radiance to brightness temperature
'CALREF'Conversion parameters from DN to reflectance (Landsat 8 only)

Examples

Run this code
## Import example data
mtlFile  <- system.file("external/landsat/LT52240631988227CUB02_MTL.txt", package="RStoolbox")
meta <- readMeta(mtlFile)
lsat_t <- stackMeta(mtlFile)

## Get integer scale factors
getMeta(lsat_t, metaData = meta, what = "SCALE_FACTOR")

## Conversion factors for brightness temperature
getMeta("B6_dn", metaData = meta, what = "CALBT")

## Conversion factors to top-of-atmosphere radiance
## Band order not corresponding to metaData order
getMeta(lsat_t[[5:1]], metaData = meta, what = "CALRAD")

## Get integer scale factors
getMeta(lsat_t, metaData = meta, what = "SCALE_FACTOR")

## Get file basenames
getMeta(lsat_t, metaData = meta, what = "FILES")

Run the code above in your browser using DataLab