Reputation: 71
I am very much new to R programming kindly someone tell how can i read the MTL file which is archived with landsat satellite data.
Upvotes: 3
Views: 1685
Reputation: 303
for reading Mtl file along with your images (stack image) you can do the following:
Give the directory of you Mtl file. For example
mtlFile<- "\\LE07_L1TP_165035_20090803_20161220_01_T1_MTL.txt"
Read metadata
metaData <- readMeta(mtlFile)
metaData
Load rasters based on the metadata file
lsat <- (stackMeta(mtlFile, quantity = "all", category = "image",
+ allResolutions = FALSE))
lsat
plot(lsat)
Upvotes: 0
Reputation: 5856
For standard MTL file provided with Landsat scenes obtained from EarthExplorer or Glovis sevices, you could simply do:
mtl <- read.delim('L71181068_06820100518_MTL.txt', sep = '=', stringsAsFactors = F)
So, for something starting like this:
GROUP = L1_METADATA_FILE GROUP = METADATA_FILE_INFO...
You may use this:
> mtl[grep("LMAX",mtl$GROUP),]
GROUP L1_METADATA_FILE
64 LMAX_BAND1 293.700
66 LMAX_BAND2 300.900
68 LMAX_BAND3 234.400
70 LMAX_BAND4 241.100
72 LMAX_BAND5 47.570
74 LMAX_BAND61 17.040
76 LMAX_BAND62 12.650
78 LMAX_BAND7 16.540
80 LMAX_BAND8 243.100
84 QCALMAX_BAND1 255.0
86 QCALMAX_BAND2 255.0
88 QCALMAX_BAND3 255.0
90 QCALMAX_BAND4 255.0
92 QCALMAX_BAND5 255.0
94 QCALMAX_BAND61 255.0
96 QCALMAX_BAND62 255.0
98 QCALMAX_BAND7 255.0
100 QCALMAX_BAND8 255.0
There are dictionaries provided by each service, found here and here.
Information from MTL may be critical for applying atmospheric and radiometric correction. By the way, landsat package allows you to run some of more typical correction using DOS()
and radiocorr()
functions.
You will also need standard calibration values provided by Chander et al. (2009).
For more complex approaches this may be a good start.
Upvotes: 3
Reputation: 21502
The MTL file contains only metadata (I hope you knew that :-)) and is a plain text file, so you could just read it in and parse as desired. If you are reasonably familiar with Matlab, you could port this tool http://www.mathworks.com/matlabcentral/fileexchange/39073 , converting it into R
code.
EDIT: I can't tell from your comments what you actually need. Here's an example MTL.txt file I pulled off the net: http://landsat.usgs.gov/images/squares/processing_level_of_the_Landsat_scene_I_have_downloaded1.jpg
If you look at it, you can see the names and values of the data items. If those are what you want, perhaps the easiest way to get them would be to run the command
mtl.values <- read.table('filename.txt' , sep='=')
Which will give you a 2-column dataframe, with names in first column and values in the second.
Upvotes: 1