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

Updated ChesapeakeCVPR to use NLCD colormap #1690

Merged
merged 10 commits into from
Jan 20, 2024
25 changes: 3 additions & 22 deletions torchgeo/datasets/chesapeake.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from torch import Tensor

from .geo import GeoDataset, RasterDataset
from .nlcd import NLCD
adamjstewart marked this conversation as resolved.
Show resolved Hide resolved
from .utils import BoundingBox, DatasetNotFoundError, download_url, extract_archive


Expand Down Expand Up @@ -439,26 +440,6 @@ class ChesapeakeCVPR(GeoDataset):
15: (0, 0, 0, 0),
}

nlcd_cmap = {
0: (0, 0, 0, 0),
11: (70, 107, 159, 255),
12: (209, 222, 248, 255),
21: (222, 197, 197, 255),
22: (217, 146, 130, 255),
23: (235, 0, 0, 255),
24: (171, 0, 0, 255),
31: (179, 172, 159, 255),
41: (104, 171, 95, 255),
42: (28, 95, 44, 255),
43: (181, 197, 143, 255),
52: (204, 184, 121, 255),
71: (223, 223, 194, 255),
81: (220, 217, 57, 255),
82: (171, 108, 40, 255),
90: (184, 217, 235, 255),
95: (108, 159, 184, 255),
}

prior_color_matrix = np.array(
[
[0.0, 0.77254902, 1.0, 1.0],
Expand Down Expand Up @@ -574,8 +555,8 @@ def __init__(
lc_colors = lc_colors[:, :3] / 255
self._lc_cmap = ListedColormap(lc_colors)

nlcd_colors = np.zeros((max(self.nlcd_cmap.keys()) + 1, 4))
nlcd_colors[list(self.nlcd_cmap.keys())] = list(self.nlcd_cmap.values())
adamjstewart marked this conversation as resolved.
Show resolved Hide resolved
nlcd_colors = np.zeros((max(NLCD.cmap.keys()) + 1, 4))
nlcd_colors[list(NLCD.cmap.keys())] = list(NLCD.cmap.values())
nlcd_colors = nlcd_colors[:, :3] / 255
self._nlcd_cmap = ListedColormap(nlcd_colors)

Expand Down