stackMeta { RStoolbox}R Documentation

Import separate Landsat files into single stack

R: Import separate Landsat files into single stack


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.


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



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


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


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.


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


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.


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.


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

## Read metadata
metaData <- readMeta(mtlFile)
#> Scene:      LT52240631988227CUB02 
#> Satellite:  LANDSAT5 
#> Sensor:     TM 
#> Date:       1988-08-14 
#> Path/Row:   224/63 
#> Projection: +proj=utm +zone=22 +units=m +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
#> Data:
#>                              FILES QUANTITY CATEGORY
#> B1_dn LT52240631988227CUB02_B1.TIF       dn    image
#> B2_dn LT52240631988227CUB02_B2.TIF       dn    image
#> B3_dn LT52240631988227CUB02_B3.TIF       dn    image
#> B4_dn LT52240631988227CUB02_B4.TIF       dn    image
#> B5_dn LT52240631988227CUB02_B5.TIF       dn    image
#> B6_dn LT52240631988227CUB02_B6.TIF       dn    image
#> B7_dn LT52240631988227CUB02_B7.TIF       dn    image
#> Available calibration parameters (gain and offset):
#>  dn -> radiance (toa)
#>  dn -> brightness temperature (toa)
## Load rasters based on metadata file
lsat     <- stackMeta(mtlFile)
#> class      : RasterStack 
#> dimensions : 310, 287, 88970, 7  (nrow, ncol, ncell, nlayers)
#> resolution : 30, 30  (x, y)
#> extent     : 619395, 628005, -419505, -410205  (xmin, xmax, ymin, ymax)
#> crs        : +proj=utm +zone=22 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0 
#> names      : B1_dn, B2_dn, B3_dn, B4_dn, B5_dn, B6_dn, B7_dn 
#> min values :    54,    18,    11,     4,     2,   131,     1 
#> max values :   185,    87,    92,   127,   148,   146,    79

[Package RStoolbox version 0.2.6 Index]