Learn R Programming

RStoolbox (version 0.2.4)

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)

Arguments

img

Raster* 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)

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).

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
# NOT RUN {
## Import example data
mtlFile  <- system.file("external/landsat/LT52240631988227CUB02_MTL.txt", package="RStoolbox")
meta <- readMeta(mtlFile)
lsat <- stackMeta(mtlFile)

## Get integer scale factors
getMeta(lsat, 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[[5:1]], metaData = meta, what = "CALRAD")

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

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

# }

Run the code above in your browser using DataLab