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

Landsat datasets don't support Level-1 products #492

Closed
landscapelc opened this issue Apr 1, 2022 · 10 comments · Fixed by #504
Closed

Landsat datasets don't support Level-1 products #492

landscapelc opened this issue Apr 1, 2022 · 10 comments · Fixed by #504
Labels
datasets Geospatial or benchmark datasets
Milestone

Comments

@landscapelc
Copy link

The part of Geospatial datasets tells me that if I have downloaded Landsat8 images,I can use the code :
landsat8 = Landsat8(root="...", bands=["B2", "B3", "B4", "B5", "B6", "B7", "B8", "B9"]).
But when I run the code, the warning will appear:
FileNotFoundError: No Landsat data was found in ...
I make sure that my root is correct and I have downloaded Landsat8 image from USGS, but the warning also exist.

@adamjstewart
Copy link
Collaborator

It could be that the filename format of the files you downloaded is different than what the dataset class expects. What do the filenames look like?

@landscapelc
Copy link
Author

I have downloaded Landsat8 images from USGS, including Landsat 8OLI/TIRS C1 Level-1 products and Landsat 8-9 OLI/TIRS C2 L1 products. I don't know wheather they are suitable for torchgeo.
Sincerely for your answer!

@adamjstewart
Copy link
Collaborator

Can you share one of the filenames?

@landscapelc
Copy link
Author

LC08_L1TP_020038_20211023_20211103_02_T1

@adamjstewart
Copy link
Collaborator

Is there no file extension or spectral band in the filename? Are all bands in a single file?

It looks like our Landsat dataset is only designed to handle level 2 surface reflectance products, it doesn't know how to handle level 1 products. For now, a quick workaround would be:

from torchgeo.datasets import Landsat8

Landsat8.filename_regex = r"""
    ^L                                                                               
    (?P<sensor>[COTEM])                                                              
    (?P<satellite>\d{2})                                                             
    _(?P<processing_correction_level>[A-Z0-9]{4})                                    
    _(?P<wrs_path>\d{3})                                                             
    (?P<wrs_row>\d{3})                                                               
    _(?P<date>\d{8})                                                                 
    _(?P<processing_date>\d{8})                                                      
    _(?P<collection_number>\d{2})                                                    
    _(?P<collection_category>[A-Z0-9]{2})                                                                                                            
"""
Landsat8.separate_files = False

landsat8 = Landsat8(root="...")

Let me know if the above code works. I'll need to think about how to handle both level 1 and 2 products. We may need separate datasets for both.

@adamjstewart adamjstewart changed the title About landsat8 dataset Landsat datasets don't support Level-1 products Apr 2, 2022
@adamjstewart adamjstewart added this to the 0.2.2 milestone Apr 2, 2022
@landscapelc
Copy link
Author

LC08_L1TP_020038_20211023_20211103_02_T1 is the name of folder and all relative files exist. All bands files in the folder. I don't change the format which is provided by USGS.

@adamjstewart
Copy link
Collaborator

What are the names of the files in this folder? TorchGeo doesn't look at folder names at all.

@landscapelc
Copy link
Author

Including LC08_L1TP_020038_20211023_20211103_02_T1_B1.TIF ,LC08_L1TP_020038_20211023_20211103_02_T1_B2.TIF and so on. And I try to fuse all bands to get a new tif file, but also can't be recognized. Therefore, I can make a concise conclusion that TorchGeo is only designed to handle level 2 surface reflectance products which need to include all bands?

@adamjstewart
Copy link
Collaborator

Ah thanks, this is much simpler to handle than I expected. At some point in the near future I'll submit a PR to fix this. In the meantime, the following should work:

from torchgeo.datasets import Landsat8

Landsat8.filename_regex = Landsat8.filename_regex.replace("_SR", "")

landsat8 = Landsat8(root="...")

@adamjstewart
Copy link
Collaborator

Can you check to see if this is fixed by #504? With this PR, you should be able to simply say:

Landsat8(root="...", bands=["B1", ..., "B11"])

and TorchGeo will pick up all Level-1 data for you.

@adamjstewart adamjstewart modified the milestones: 0.2.2, 0.3.0 Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datasets Geospatial or benchmark datasets
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants