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: fix band indexing bug #1135

Merged
merged 9 commits into from
Feb 23, 2023
Merged

RasterDataset: fix band indexing bug #1135

merged 9 commits into from
Feb 23, 2023

Conversation

adamjstewart
Copy link
Collaborator

@adamjstewart adamjstewart commented Feb 22, 2023

This PR fixes multiple bugs related to band indexing in RasterDataset:

  • Fix support for datasets where all_bands does not actually contain all bands (e.g., Landsat)
  • Fix support for datasets where all_bands is not defined and separate_files is True

The fix was simple. We don't need to compute band_indexes unless separate_files is False.

Confirmed that the tests I added fail without this fix, so this bug shouldn't pop back up in the next release.

Should we rename Landsat's all_bands to default_bands? In #504 we added support for all Level-1 and Level-2 products and decided not to list every possible band name because there are way too many and I can't easily confirm what they were all the way back to Landsat 1.

This bug was introduced in #687, apologies for not catching this during review.

Fixes #1134 @TolgaAktas

@adamjstewart adamjstewart added this to the 0.4.1 milestone Feb 22, 2023
@github-actions github-actions bot added datasets Geospatial or benchmark datasets testing Continuous integration testing labels Feb 22, 2023
@adamjstewart adamjstewart changed the title Fix Landsat non-SR band specification Fix RasterDataset band indexing bug Feb 22, 2023
@adamjstewart adamjstewart changed the title Fix RasterDataset band indexing bug RasterDataset: fix band indexing bug Feb 22, 2023
@ashnair1
Copy link
Collaborator

Nice catch! I think default_bands might be the better name to avoid confusion.

@adamjstewart adamjstewart merged commit 1155eae into main Feb 23, 2023
@adamjstewart adamjstewart deleted the fixes/raster-bands branch February 23, 2023 20:39
calebrob6 pushed a commit that referenced this pull request Apr 10, 2023
* Fix Landsat non-SR band specification

* Fix variable reference

* Fix test when no all_bands

* Fail during init instead

* Store variable

* all_bands -> default_bands

* Simplify logic

* fix mypy

* Make default_bands required
yichiac pushed a commit to yichiac/torchgeo that referenced this pull request Apr 29, 2023
* Fix Landsat non-SR band specification

* Fix variable reference

* Fix test when no all_bands

* Fail during init instead

* Store variable

* all_bands -> default_bands

* Simplify logic

* fix mypy

* Make default_bands required
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datasets Geospatial or benchmark datasets testing Continuous integration testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Getting "B1" is not in list error with 0.4.0 release for Landsat8 dataset
2 participants