R has some dedicated packages for working with raster data. We can use raster, RStoolbox, and more to analyze raster data in R. We can use the readMeta() function of RStoolbox in R to read the metadata of raster data. Let's read the metadata of some Landsat data now:
library(RStoolbox)
# Set the working directory
setwd("F:/Hands-on-Geospatial-Analysis-Using-R-and-QGIS/Chapter05/Data")
# Read metadata
meta_data = readMeta("Mosaic/LC08_L1TP_137043_20180410_20180417_01_T1/LC08_L1TP_137043_20180410_20180417_01_T1_MTL.txt")
summary(meta_data)
This will give us the metadata of this Landsat image, where we can see that it has 11 bands, UTM projection, and WGS84 as datum: