KeyError: 'L1_METADATA_FILE'
Hi guys,
I am getting this error from a couple of 2014 Landsat8 images. I installed rio-toa using pip and github but nothing works. Any advice?
Thanks in advance, JL
KeyError Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/rio_toa/reflectance.py in calculate_landsat_reflectance(src_paths, src_mtl, dst_path, rescale_factor, creation_options, bands, dst_dtype, processes, pixel_sunangle, clip) 152 """ 153 mtl = toa_utils._load_mtl(src_mtl) --> 154 metadata = mtl['L1_METADATA_FILE'] 155 156 M = [metadata['RADIOMETRIC_RESCALING']
KeyError: 'L1_METADATA_FILE'
Hi,
I don't know if you still need a help with this issue @jaimebayes but I had the same problem and I've pushed pull request with a solution: https://github.com/mapbox/rio-toa/pull/36
Hi Simon
Thanks for the advice, I run it again without the same error , but it throws a related error this time:
E = metadata['IMAGE_ATTRIBUTES']['SUN_ELEVATION'] --> 164 date_collected = metadata['PRODUCT_METADATA']['DATE_ACQUIRED'] 165 time_collected_utc = metadata['PRODUCT_METADATA']['SCENE_CENTER_TIME'] 166
KeyError: 'PRODUCT_METADATA'
Any advice will be welcome, Thanks, JL
Hi @jaimebayes ,
I'll continue our conversation here -> from here.
I've asked for MTL files and a code snippet. You may attach a file into an issue if you drag & drop it into a text area or by clicking on the small area below a text area (there is a text Attach files by...).
You may paste code here. You can insert it within code brackets (three single apostrophes or toolbar above text area with <> characters).
sample code
Hi @jaimebayes ,
I've made a PR with the correct algorithm to retrieve metadata values. Could you please check how it works within your environment? PR is here: https://github.com/mapbox/rio-toa/pull/36 Should be ok, even if metadata structure changes again... (btw, it was a surprise for me that the meta structure has been changed so many times in such a short time).
I'll run some calculations within my env today and update info for the package maintainers if everything will run smoothly.