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

Add National Land Cover Database (NLCD) dataset #1244

Merged
merged 14 commits into from
Apr 18, 2023

Conversation

nilsleh
Copy link
Collaborator

@nilsleh nilsleh commented Apr 14, 2023

This PR adds the NLCD dataset, with selective download and using masks for desired years.

Dataset format:

  • single channel .img file

Dataset features:

  • 16 classes for US
  • remapped the class labels to ordinal labels

Example:

Note:
If the year selection scheme is approved, I would open another PR to change CDL accordingly, so that users don't have to download data for all years.

@github-actions github-actions bot added datasets Geospatial or benchmark datasets testing Continuous integration testing labels Apr 14, 2023
Copy link
Collaborator

@adamjstewart adamjstewart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plot looks great! Also need to add to docs.

tests/data/nlcd/data.py Outdated Show resolved Hide resolved
tests/data/nlcd/data.py Outdated Show resolved Hide resolved
tests/data/nlcd/nlcd_2019_land_cover_l48_20210604.zip Outdated Show resolved Hide resolved
torchgeo/datasets/nlcd.py Outdated Show resolved Hide resolved
torchgeo/datasets/nlcd.py Outdated Show resolved Hide resolved
torchgeo/datasets/nlcd.py Outdated Show resolved Hide resolved
torchgeo/datasets/nlcd.py Outdated Show resolved Hide resolved
torchgeo/datasets/nlcd.py Outdated Show resolved Hide resolved
torchgeo/datasets/nlcd.py Show resolved Hide resolved
torchgeo/datasets/nlcd.py Outdated Show resolved Hide resolved
@adamjstewart adamjstewart added this to the 0.5.0 milestone Apr 14, 2023
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Apr 14, 2023
docs/api/datasets.rst Outdated Show resolved Hide resolved
torchgeo/datasets/nlcd.py Outdated Show resolved Hide resolved
torchgeo/datasets/nlcd.py Outdated Show resolved Hide resolved
torchgeo/datasets/nlcd.py Outdated Show resolved Hide resolved
torchgeo/datasets/nlcd.py Show resolved Hide resolved
torchgeo/datasets/nlcd.py Outdated Show resolved Hide resolved
@adamjstewart
Copy link
Collaborator

@nilsleh
Copy link
Collaborator Author

nilsleh commented Apr 18, 2023

Missing test coverage for some lines: https://app.codecov.io/gh/microsoft/torchgeo/pull/1244/blob/torchgeo/datasets/nlcd.py

not sure why it is not working, I thought the following test would cover it but doesn't:

    def test_already_downloaded(self, tmp_path: Path) -> None:
        pathname = os.path.join(
            "tests", "data", "nlcd", "nlcd_2019_land_cover_l48_20210604.zip"
        )
        root = str(tmp_path)
        shutil.copy(pathname, root)
        NLCD(root, years=[2019])

@adamjstewart
Copy link
Collaborator

What if you add an additional test that includes years that don't exist locally and need to be "downloaded"?

@nilsleh
Copy link
Collaborator Author

nilsleh commented Apr 18, 2023

found my mistake, and tested again with downloading the real data from scratch and retrieving samples.

@adamjstewart adamjstewart merged commit 53b953b into microsoft:main Apr 18, 2023
yichiac pushed a commit to yichiac/torchgeo that referenced this pull request Apr 29, 2023
* working nlcd dataset version

* citation and correct ordinal color map

* add unit tests

* requested changes

* fix docs

* unnecessary space

* typos and for loop label conversion

* suggested plot changes

* use ListedColormap

* return fig statement

* docs about background class

* forgot print

* run pyupgrade

* found my bug
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.

2 participants