Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

stackMeta

Import separate Landsat files into single stack


Description

Reads Landsat MTL or XML metadata files and loads single Landsat Tiffs into a rasterStack. Be aware that by default stackMeta() does NOT import panchromatic bands nor thermal bands with resolutions != 30m.

Usage

stackMeta(file, quantity = "all", category = "image",
  allResolutions = FALSE)

Arguments

file

Character. Path to Landsat MTL metadata (*_MTL.txt) file or an Landsat CDR xml metadata file (*.xml).

quantity

Character vector. Which quantity should be returned. Options: digital numbers ('dn'), top of atmosphere reflectance ('tre'), at surface reflectance ('sre'), brightness temperature ('bt'), spectral index ('index'), all quantities ('all').

category

Character vector. Which category of data to return. Options 'image': image data, 'pan': panchromatic image, 'index': multiband indices, 'qa' quality flag bands, 'all': all categories.

allResolutions

Logical. if TRUE a list will be returned with length = unique spatial resolutions.

Value

Returns one single RasterStack comprising all requested bands. If allResolutions = TRUE *and* there are different resolution layers (e.g. a 15m panchromatic band along wit 30m imagery) a list of RasterStacks will be returned.

Note

Be aware that by default stackMeta() does NOT import panchromatic bands nor thermal bands with resolutions != 30m. Use the allResolutions argument to import all layers. Note that nowadays the USGS uses cubic convolution to resample the TIR bands to 30m resolution.

Examples

library(rgdal)
## Example metadata file (MTL)
mtlFile  <- system.file("external/landsat/LT52240631988227CUB02_MTL.txt", package="RStoolbox")

## Read metadata
metaData <- readMeta(mtlFile)
summary(metaData)

## Load rasters based on metadata file
lsat     <- stackMeta(mtlFile)
lsat

RStoolbox

Tools for Remote Sensing Data Analysis

v0.2.6
GPL (>= 3)
Authors
Benjamin Leutner [cre, aut], Ned Horning [aut], Jakob Schwalb-Willmann [aut], Robert J. Hijmans [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.