Metadata-Structure .xml
Krisselack opened this issue · 3 comments
Apparently, with Landsat8-Data a new metadata file structure emerged. Data is provided with an xml file (xml is not supported with github, so i zipped it).
LC08_L1TP_094073_20160219_20170329_01_T1.zip
Is there a way to make the addon work with the new metadata-structure? I found no possibility to back-convert the xml-file.
Thank you!
Yes. Something like the following interactive examples (and a bit of work to integrate such a 'mechanism' in https://github.com/NikosAlexandris/i.landsat8.swlst/blob/master/landsat8_mtl.py):
import xmltodict
with open('LC08_L1TP_094073_20160219_20170329_01_T1.xml') as file_descriptor:
xml = xmltodict.parse(file_descriptor.read())
then
In [59]: for key in xml['espa_metadata'].keys():
...: print(key)
...:
@version
@xmlns
@xmlns:xsi
@xsi:schemaLocation
global_metadata
bands
and, for example
bands = xml['espa_metadata']['bands']
In [72]: bands['band'][2]
Out[72]:
OrderedDict([('@product', 'sr_refl'),
('@name', 'sr_band1'),
('@category', 'image'),
('@data_type', 'INT16'),
('@nlines', '7781'),
('@nsamps', '7661'),
('@fill_value', '-9999'),
('@scale_factor', '0.000100'),
('short_name', 'LC08SR'),
('long_name', 'band 1 surface reflectance'),
('file_name',
'LC08_L1TP_094073_20160219_20170329_01_T1_sr_band1.tif'),
('pixel_size',
OrderedDict([('@x', '30'), ('@y', '30'), ('@units', 'meters')])),
('resample_method', 'none'),
('data_units', 'reflectance'),
('valid_range',
OrderedDict([('@min', '-2000.000000'),
('@max', '16000.000000')])),
('app_version', 'LaSRC_2.1.0 (Collection 1)'),
('production_date', '2021-01-13T20:08:05Z')])
Thank you, that was fast! But I realized, I picked the wrong product anyway (no Bands 10 and 11 available).
And I didn't bother to read if the xml applied to TIRS bands :-)