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

RasterDataset: better error message when no data found #1193

Merged
merged 1 commit into from
Mar 29, 2023

Conversation

adamjstewart
Copy link
Collaborator

Datasets like Landsat have different band names for TOA and SR products. Although we default to SR, many users use TOA data and are confused when no data is found because they didn't change the default bands. This PR adds bands to the error message, which should hopefully make it easier to realize that bands needs to be changed. To test, run this script:

from torchgeo.datasets import Landsat8

Landsat8("data/landsat8/toa")

Before

Doesn't give any reason why no data was found:

Traceback (most recent call last):
  File "/Users/Adam/torchgeo/test.py", line 3, in <module>
    Landsat8("data/landsat8/toa")
  File "/Users/Adam/torchgeo/torchgeo/datasets/landsat.py", line 85, in __init__
    super().__init__(root, crs, res, bands, transforms, cache)
  File "/Users/Adam/torchgeo/torchgeo/datasets/geo.py", line 367, in __init__
    raise FileNotFoundError(
FileNotFoundError: No Landsat8 data was found in 'data/landsat8/toa'

After

Tells you both the root directory and band selection used, hinting that changing the bands may help:

Traceback (most recent call last):
  File "/Users/Adam/torchgeo/test.py", line 3, in <module>
    Landsat8("data/landsat8/toa")
  File "/Users/Adam/torchgeo/torchgeo/datasets/landsat.py", line 85, in __init__
    super().__init__(root, crs, res, bands, transforms, cache)
  File "/Users/Adam/torchgeo/torchgeo/datasets/geo.py", line 370, in __init__
    raise FileNotFoundError(msg)
FileNotFoundError: No Landsat8 data was found in `root='data/landsat8/toa'` with `bands=['SR_B1', 'SR_B2', 'SR_B3', 'SR_B4', 'SR_B5', 'SR_B6', 'SR_B7']`

Thanks @TolgaAktas for reporting this!

Closes #1055

@adamjstewart adamjstewart added this to the 0.4.1 milestone Mar 23, 2023
@github-actions github-actions bot added the datasets Geospatial or benchmark datasets label Mar 23, 2023
@adamjstewart adamjstewart changed the title GeoDataset: better error message when no data found RasterDataset: better error message when no data found Mar 23, 2023
@adamjstewart adamjstewart merged commit e60c1c4 into main Mar 29, 2023
@adamjstewart adamjstewart deleted the datasets/better-no-data-error branch March 29, 2023 01:27
yichiac pushed a commit to yichiac/torchgeo that referenced this pull request Apr 29, 2023
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 this pull request may close these issues.

Missing documentation about expected filesystems for Datasets
2 participants