Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support recent (2022) format .SAFE #15

Closed
marujore opened this issue Oct 6, 2022 · 4 comments
Closed

Support recent (2022) format .SAFE #15

marujore opened this issue Oct 6, 2022 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@marujore
Copy link
Collaborator

marujore commented Oct 6, 2022

Similar to Issue #9
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 1, column 0

@marujore marujore added the bug Something isn't working label Oct 6, 2022
@marujore marujore self-assigned this Oct 6, 2022
@TomKenda
Copy link
Contributor

TomKenda commented Feb 7, 2024

The error come from the get_detfootprint(XML_File) in the s2_sensor_angs.py file.

In this function, the qifname is extracted from the metadata and then parsed ( tree2 = ET.parse(foot[1])).

In the former version of the L1C MTD_TL.xml file, the qifname was similar to this :

type="MSK_DETFOO">GRANULE/L1C_T31UFS_A028891_20210102T104435/QI_DATA/MSK_DETFOO_B01.gml</MASK_FILENAME>

In the new version, this qi file is now in a .jp2 file :

type="MSK_DETFOO">GRANULE/L1C_T31UFS_A032495_20230527T103641/QI_DATA/MSK_DETFOO_B01.jp2</MASK_FILENAME>

This difference in the metadata is causing the error.

Does someone have an idea on how to fix this ? How to get the band footprints with the new version of metadata files ? Or is there a way to bypass this step to get the view and sun angle rasters ? Or another library doing the job for more recent images ?

Thanks in advance.

@TomKenda
Copy link
Contributor

TomKenda commented Feb 7, 2024

I gess that somehow we could modify the code in the following way :

    bandfoot = []
    for foot in footprints:
        bandId = int(foot[0])
        if foot[0].endswith('.gml'):
            tree2 = ET.parse(foot[1])
            root2 = tree2.getroot()
            for child in root2:

                  ... [ reste of the code to parse the gml] ...

        elif foot[0].endswith('.jp2'):
                with rasterio.open(qifname) as src:
                    mask = src.read(1)
                    transform = src.transform
                detfootprint = mask_to_poly(mask, transform)
                ?...?

but I am not sur how to handle it afterwards

@marujore
Copy link
Collaborator Author

Hi @TomKenda , sorry for the late response.
Thank you for the PR, I will verify it in the next days.

@marujore
Copy link
Collaborator Author

Close on #16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants