Skip to content

Commit

Permalink
list -> dict
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjstewart committed May 27, 2023
1 parent 6415d17 commit 38e64d4
Show file tree
Hide file tree
Showing 3 changed files with 158 additions and 158 deletions.
274 changes: 137 additions & 137 deletions torchgeo/datasets/cdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,142 +66,142 @@ class CDL(RasterDataset):
2008: "0610f2f17ab60a9fbb3baeb7543993a4",
}

cmap = [
(0, 0, 0, 0),
(255, 211, 0, 255),
(255, 38, 38, 255),
(0, 168, 228, 255),
(255, 158, 11, 255),
(38, 112, 0, 255),
(255, 255, 0, 255),
(112, 165, 0, 255),
(0, 175, 75, 255),
(221, 165, 11, 255),
(221, 165, 11, 255),
(126, 211, 255, 255),
(226, 0, 124, 255),
(137, 98, 84, 255),
(216, 181, 107, 255),
(165, 112, 0, 255),
(214, 158, 188, 255),
(112, 112, 0, 255),
(172, 0, 124, 255),
(160, 89, 137, 255),
(112, 0, 73, 255),
(214, 158, 188, 255),
(209, 255, 0, 255),
(126, 153, 255, 255),
(214, 214, 0, 255),
(209, 255, 0, 255),
(0, 175, 75, 255),
(255, 165, 226, 255),
(165, 242, 140, 255),
(0, 175, 75, 255),
(214, 158, 188, 255),
(168, 0, 228, 255),
(165, 0, 0, 255),
(112, 38, 0, 255),
(0, 175, 75, 255),
(177, 126, 255, 255),
(112, 38, 0, 255),
(255, 102, 102, 255),
(255, 102, 102, 255),
(255, 204, 102, 255),
(255, 102, 102, 255),
(0, 175, 75, 255),
(0, 221, 175, 255),
(84, 255, 0, 255),
(242, 163, 119, 255),
(255, 102, 102, 255),
(0, 175, 75, 255),
(126, 211, 255, 255),
(232, 191, 255, 255),
(175, 255, 221, 255),
(0, 175, 75, 255),
(191, 191, 119, 255),
(147, 204, 147, 255),
(198, 214, 158, 255),
(204, 191, 163, 255),
(255, 0, 255, 255),
(255, 142, 170, 255),
(186, 0, 79, 255),
(112, 68, 137, 255),
(0, 119, 119, 255),
(177, 154, 112, 255),
(255, 255, 126, 255),
(181, 112, 91, 255),
(0, 165, 130, 255),
(233, 214, 175, 255),
(177, 154, 112, 255),
(242, 242, 242, 255),
(154, 154, 154, 255),
(75, 112, 163, 255),
(126, 177, 177, 255),
(232, 255, 191, 255),
(0, 255, 255, 255),
(75, 112, 163, 255),
(211, 226, 249, 255),
(154, 154, 154, 255),
(154, 154, 154, 255),
(154, 154, 154, 255),
(154, 154, 154, 255),
(204, 191, 163, 255),
(147, 204, 147, 255),
(147, 204, 147, 255),
(147, 204, 147, 255),
(198, 214, 158, 255),
(232, 255, 191, 255),
(126, 177, 177, 255),
(126, 177, 177, 255),
(0, 255, 140, 255),
(214, 158, 188, 255),
(255, 102, 102, 255),
(255, 102, 102, 255),
(255, 102, 102, 255),
(255, 102, 102, 255),
(255, 142, 170, 255),
(51, 73, 51, 255),
(228, 112, 38, 255),
(255, 102, 102, 255),
(255, 102, 102, 255),
(102, 153, 76, 255),
(255, 102, 102, 255),
(177, 154, 112, 255),
(255, 142, 170, 255),
(255, 102, 102, 255),
(255, 142, 170, 255),
(255, 102, 102, 255),
(255, 102, 102, 255),
(255, 142, 170, 255),
(0, 175, 75, 255),
(255, 211, 0, 255),
(255, 211, 0, 255),
(255, 102, 102, 255),
(255, 210, 0, 255),
(255, 102, 102, 255),
(137, 98, 84, 255),
(255, 102, 102, 255),
(255, 38, 38, 255),
(226, 0, 124, 255),
(255, 158, 11, 255),
(255, 158, 11, 255),
(165, 112, 0, 255),
(255, 211, 0, 255),
(165, 112, 0, 255),
(38, 112, 0, 255),
(38, 112, 0, 255),
(255, 211, 0, 255),
(0, 0, 153, 255),
(255, 102, 102, 255),
(255, 102, 102, 255),
(255, 102, 102, 255),
(255, 102, 102, 255),
(255, 102, 102, 255),
(255, 102, 102, 255),
(255, 102, 102, 255),
(255, 102, 102, 255),
(38, 112, 0, 255),
]
cmap = {
0: (0, 0, 0, 0),
1: (255, 211, 0, 255),
2: (255, 38, 38, 255),
3: (0, 168, 228, 255),
4: (255, 158, 11, 255),
5: (38, 112, 0, 255),
6: (255, 255, 0, 255),
7: (112, 165, 0, 255),
8: (0, 175, 75, 255),
9: (221, 165, 11, 255),
10: (221, 165, 11, 255),
11: (126, 211, 255, 255),
12: (226, 0, 124, 255),
13: (137, 98, 84, 255),
14: (216, 181, 107, 255),
15: (165, 112, 0, 255),
16: (214, 158, 188, 255),
17: (112, 112, 0, 255),
18: (172, 0, 124, 255),
19: (160, 89, 137, 255),
20: (112, 0, 73, 255),
21: (214, 158, 188, 255),
22: (209, 255, 0, 255),
23: (126, 153, 255, 255),
24: (214, 214, 0, 255),
25: (209, 255, 0, 255),
26: (0, 175, 75, 255),
27: (255, 165, 226, 255),
28: (165, 242, 140, 255),
29: (0, 175, 75, 255),
30: (214, 158, 188, 255),
31: (168, 0, 228, 255),
32: (165, 0, 0, 255),
33: (112, 38, 0, 255),
34: (0, 175, 75, 255),
35: (177, 126, 255, 255),
36: (112, 38, 0, 255),
37: (255, 102, 102, 255),
38: (255, 102, 102, 255),
39: (255, 204, 102, 255),
40: (255, 102, 102, 255),
41: (0, 175, 75, 255),
42: (0, 221, 175, 255),
43: (84, 255, 0, 255),
44: (242, 163, 119, 255),
45: (255, 102, 102, 255),
46: (0, 175, 75, 255),
47: (126, 211, 255, 255),
48: (232, 191, 255, 255),
49: (175, 255, 221, 255),
50: (0, 175, 75, 255),
51: (191, 191, 119, 255),
52: (147, 204, 147, 255),
53: (198, 214, 158, 255),
54: (204, 191, 163, 255),
55: (255, 0, 255, 255),
56: (255, 142, 170, 255),
57: (186, 0, 79, 255),
58: (112, 68, 137, 255),
59: (0, 119, 119, 255),
60: (177, 154, 112, 255),
61: (255, 255, 126, 255),
62: (181, 112, 91, 255),
63: (0, 165, 130, 255),
64: (233, 214, 175, 255),
65: (177, 154, 112, 255),
66: (242, 242, 242, 255),
67: (154, 154, 154, 255),
68: (75, 112, 163, 255),
69: (126, 177, 177, 255),
70: (232, 255, 191, 255),
71: (0, 255, 255, 255),
72: (75, 112, 163, 255),
73: (211, 226, 249, 255),
74: (154, 154, 154, 255),
75: (154, 154, 154, 255),
76: (154, 154, 154, 255),
77: (154, 154, 154, 255),
78: (204, 191, 163, 255),
79: (147, 204, 147, 255),
80: (147, 204, 147, 255),
81: (147, 204, 147, 255),
82: (198, 214, 158, 255),
83: (232, 255, 191, 255),
84: (126, 177, 177, 255),
85: (126, 177, 177, 255),
86: (0, 255, 140, 255),
87: (214, 158, 188, 255),
88: (255, 102, 102, 255),
89: (255, 102, 102, 255),
90: (255, 102, 102, 255),
91: (255, 102, 102, 255),
92: (255, 142, 170, 255),
93: (51, 73, 51, 255),
94: (228, 112, 38, 255),
95: (255, 102, 102, 255),
96: (255, 102, 102, 255),
97: (102, 153, 76, 255),
98: (255, 102, 102, 255),
99: (177, 154, 112, 255),
100: (255, 142, 170, 255),
101: (255, 102, 102, 255),
102: (255, 142, 170, 255),
103: (255, 102, 102, 255),
104: (255, 102, 102, 255),
105: (255, 142, 170, 255),
106: (0, 175, 75, 255),
107: (255, 211, 0, 255),
108: (255, 211, 0, 255),
109: (255, 102, 102, 255),
110: (255, 210, 0, 255),
111: (255, 102, 102, 255),
112: (137, 98, 84, 255),
113: (255, 102, 102, 255),
114: (255, 38, 38, 255),
115: (226, 0, 124, 255),
116: (255, 158, 11, 255),
117: (255, 158, 11, 255),
118: (165, 112, 0, 255),
119: (255, 211, 0, 255),
120: (165, 112, 0, 255),
121: (38, 112, 0, 255),
122: (38, 112, 0, 255),
123: (255, 211, 0, 255),
124: (0, 0, 153, 255),
125: (255, 102, 102, 255),
126: (255, 102, 102, 255),
127: (255, 102, 102, 255),
128: (255, 102, 102, 255),
129: (255, 102, 102, 255),
130: (255, 102, 102, 255),
131: (255, 102, 102, 255),
132: (255, 102, 102, 255),
133: (38, 112, 0, 255),
}

ordinal_label_map = {
0: 0,
Expand Down Expand Up @@ -498,7 +498,7 @@ def plot(
ncols = 2

kwargs = {
"cmap": ListedColormap(np.array(self.cmap) / 255),
"cmap": ListedColormap(np.array(list(self.cmap.values())) / 255),
"vmin": 0,
"vmax": len(self.cmap) - 1,
"interpolation": "none",
Expand Down
40 changes: 20 additions & 20 deletions torchgeo/datasets/nlcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,25 +103,25 @@ class NLCD(RasterDataset):
95: 16,
}

cmap = [
(0, 0, 0, 255),
(70, 107, 159, 255),
(209, 222, 248, 255),
(222, 197, 197, 255),
(217, 146, 130, 255),
(235, 0, 0, 255),
(171, 0, 0, 255),
(179, 172, 159, 255),
(104, 171, 95, 255),
(28, 95, 44, 255),
(181, 197, 143, 255),
(204, 184, 121, 255),
(223, 223, 194, 255),
(220, 217, 57, 255),
(171, 108, 40, 255),
(184, 217, 235, 255),
(108, 159, 184, 255),
]
cmap = {
0: (0, 0, 0, 255),
1: (70, 107, 159, 255),
2: (209, 222, 248, 255),
3: (222, 197, 197, 255),
4: (217, 146, 130, 255),
5: (235, 0, 0, 255),
6: (171, 0, 0, 255),
7: (179, 172, 159, 255),
8: (104, 171, 95, 255),
9: (28, 95, 44, 255),
10: (181, 197, 143, 255),
11: (204, 184, 121, 255),
12: (223, 223, 194, 255),
13: (220, 217, 57, 255),
14: (171, 108, 40, 255),
15: (184, 217, 235, 255),
16: (108, 159, 184, 255),
}

def __init__(
self,
Expand Down Expand Up @@ -277,7 +277,7 @@ def plot(
ncols = 2

kwargs = {
"cmap": ListedColormap(np.array(self.cmap) / 255),
"cmap": ListedColormap(np.array(list(self.cmap.values())) / 255),
"vmin": 0,
"vmax": len(self.cmap) - 1,
"interpolation": "none",
Expand Down
2 changes: 1 addition & 1 deletion torchgeo/datasets/ssl4eo_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def plot(
ncols = 3

kwargs = {
"cmap": ListedColormap(np.array(self.cmap) / 255),
"cmap": ListedColormap(np.array(list(self.cmap.values())) / 255),
"vmin": 0,
"vmax": len(self.cmap) - 1,
"interpolation": "none",
Expand Down

0 comments on commit 38e64d4

Please sign in to comment.