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: add plot method #661

Merged
merged 3 commits into from
Jul 10, 2022
Merged

Landsat: add plot method #661

merged 3 commits into from
Jul 10, 2022

Conversation

adamjstewart
Copy link
Collaborator

@adamjstewart adamjstewart commented Jul 10, 2022

We removed the RasterDataset.plot method in #476. Landsat was the only remaining RasterDataset that didn't have a replacement plot method. Added it so we don't have to explain why Landsat used to have a plot method but no longer does.

Also cleaned up some typing and documentation mistakes. RasterDataset.__getitem__ returns Dict[str, Any], not Dict[str, Tensor]. Plot methods weren't added in 0.3 since they existed (albeit in the base class) in 0.2. They were changed because they now have completely different inputs.

Example image from Novaya Zemlya, Russia:
landsat

@adamjstewart adamjstewart added this to the 0.3.0 milestone Jul 10, 2022
@github-actions github-actions bot added datasets Geospatial or benchmark datasets testing Continuous integration testing labels Jul 10, 2022
@adamjstewart adamjstewart mentioned this pull request Jul 10, 2022
19 tasks
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Jul 10, 2022
@adamjstewart adamjstewart marked this pull request as ready for review July 10, 2022 01:20
@calebrob6
Copy link
Member

How are you generating that actually? I'm getting problems:

from torchgeo.datasets import Landsat8
from torchgeo.samplers import RandomGeoSampler
import numpy as np
import matplotlib.pyplot as plt

ds = Landsat8(root="tmp/", bands=Landsat8.all_bands)
sampler = RandomGeoSampler(ds, size=50, length=1)
bb = next(iter(sampler))
ds[bb]

Is giving me the following error:

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
/tmp/ipykernel_32350/2392223127.py in <module>
----> 1 ds[bb]

~/code/torchgeo/torchgeo/datasets/geo.py in __getitem__(self, query)
    417                             end = match.end("resolution")
    418                             filename = filename[:start] + "*" + filename[end:]
--> 419                     filepath = glob.glob(os.path.join(directory, filename))[0]
    420                     band_filepaths.append(filepath)
    421                 data_list.append(self._merge_files(band_filepaths, query))

IndexError: list index out of range

Where:

> ls tmp
LC08_L2SP_013033_20190830_20200826_02_T1_SR_B1.TIF
LC08_L2SP_013033_20190830_20200826_02_T1_SR_B2.TIF
LC08_L2SP_013033_20190830_20200826_02_T1_SR_B3.TIF
LC08_L2SP_013033_20190830_20200826_02_T1_SR_B4.TIF
LC08_L2SP_013033_20190830_20200826_02_T1_SR_B5.TIF
LC08_L2SP_013033_20190830_20200826_02_T1_SR_B6.TIF
LC08_L2SP_013033_20190830_20200826_02_T1_SR_B7.TIF

@calebrob6
Copy link
Member

Ahhh nvrmnd I didn't have all the bands downloaded but it was defaulting to all bands.

@calebrob6
Copy link
Member

Stretching to full range is okay. When the image patch doesn't have a wide range it looks overexposed, but for most cases it will be fine!

E.g. water only patch
image

What happens when you divide by constant and clip:
image

@adamjstewart adamjstewart merged commit 7e7443a into main Jul 10, 2022
@adamjstewart adamjstewart deleted the datasets/landsat branch July 10, 2022 05:22
@adamjstewart adamjstewart mentioned this pull request Jul 11, 2022
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 documentation Improvements or additions to documentation testing Continuous integration testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants