I am following a tutorial on remote sensing using R. The tutorial is available from here. pg 44.
I would like to read the metadata for a Landsat 5 image, specifically for 1984-06-22
path/row 170/072
. The Landsat Product ID is LT05_L2SP_170072_19840622_20200918_02_T1
. Here is the L5 metadata.
I am using the readMeta
function from the RSToolbox
package. The work should be pretty straightforward in that I put in the path to my metadata file and specify raw = F
so that the metadata can be put in a format for further analyses.
mtl <- readMeta(file = ".", raw = F)
After doing this (reading the L5 using readMeta
) I get this error.
Error in `.rowNamesDF<-`(x, value = value) : invalid 'row.names' length
Now of course there are many ways of killing a rat, so I used this method here - whereby read.delim
function is used to read the metadata file. This brings in a dataframe with all the metadata values alright. However, when this dataframe is put into the radCor
function in order to convert the L5 DNs to Top-of-Atmosphere radiance, the following error appears:
Error in radCor(june_landsat2, metaData = metadata_june, method = "rad") :
metaData must be a path to the MTL file or an ImageMetaData object (see readMeta)
Seems like radCor
will accept nothing else apart from what is read by readMeta
or the path to the MTL file itself. Not even the result from read.delim
will do. Because the first error readMeta mentioned row.names
length issue, I thought deleting the last row without a value in the metadata file would solve the issue, but this brings more complicated errors.
In short, I would like to find a way to make readMeta
read my L5 metadata file, since the result from readMeta is being used in other places of the tutorial.