Skip to content

Commit

Permalink
Include land cover colormaps of ESAWC and ECOSG
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasRieutord committed Sep 4, 2023
1 parent cfbd05a commit 3e0711e
Showing 1 changed file with 175 additions and 4 deletions.
179 changes: 175 additions & 4 deletions mmt/datasets/landcover_to_landcover.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,91 @@
(0, 50, 200),
(0, 0, 128),
],
"ecosg.hdf5": [
(0, 0, 0),
(0, 0, 128),
(0, 0, 205),
(0, 0, 255),
(211, 211, 211),
(169, 169, 169),
(255, 250, 250),
(240, 255, 240),
(85, 107, 47),
(154, 205, 50),
(0, 128, 0),
(255, 127, 80),
(160, 82, 45),
(34, 139, 34),
(188, 143, 143),
(205, 133, 63),
(222, 184, 135),
(50, 205, 50),
(255, 215, 0),
(32, 178, 170),
(173, 255, 47),
(189, 183, 107),
(102, 102, 0),
(46, 139, 87),
(138, 2, 0),
(206, 0, 0),
(252, 1, 1),
(255, 90, 0),
(255, 120, 0),
(255, 150, 0),
(255, 180, 0),
(255, 210, 0),
(255, 240, 0),
(128, 128, 128),
],
"esgp.hdf5": [
(0, 0, 0),
(0, 0, 128),
(0, 0, 205),
(0, 0, 255),
(211, 211, 211),
(169, 169, 169),
(255, 250, 250),
(240, 255, 240),
(85, 107, 47),
(154, 205, 50),
(0, 128, 0),
(255, 127, 80),
(160, 82, 45),
(34, 139, 34),
(188, 143, 143),
(205, 133, 63),
(222, 184, 135),
(50, 205, 50),
(255, 215, 0),
(32, 178, 170),
(173, 255, 47),
(189, 183, 107),
(102, 102, 0),
(46, 139, 87),
(138, 2, 0),
(206, 0, 0),
(252, 1, 1),
(255, 90, 0),
(255, 120, 0),
(255, 150, 0),
(255, 180, 0),
(255, 210, 0),
(255, 240, 0),
(128, 128, 128),
],
"esawc.hdf5": [
(0, 100, 0),
(255, 187, 34),
(255, 255, 76),
(240, 150, 255),
(250, 0, 0),
(180, 180, 180),
(240, 240, 240),
(0, 100, 200),
(0, 150, 160),
(0, 207, 117),
(250, 230, 160),
],
}
label_dict = {
"clc.hdf5": [
Expand Down Expand Up @@ -289,6 +374,91 @@
"water",
"ocean",
],
"ecosg.hdf5": [
"0. no data",
"1. sea and oceans",
"2. lakes",
"3. rivers",
"4. bare land",
"5. bare rock",
"6. permanent snow",
"7. boreal broadleaf deciduous",
"8. temperate broadleaf deciduous",
"9. tropical broadleaf deciduous",
"10. temperate broadleaf evergreen",
"11. tropical broadleaf evergreen",
"12. boreal needleleaf evergreen",
"13. temperate needleleaf evergreen",
"14. boreal needleleaf deciduous",
"15. shrubs",
"16. boreal grassland",
"17. temperate grassland",
"18. tropical grassland",
"19. winter C3 crops",
"20. summer C3 crops",
"21. C4 crops",
"22. flooded trees",
"23. flooded grassland",
"24. LCZ1: compact high-rise",
"25. LCZ2: compact midrise",
"26. LCZ3: compact low-rise",
"27. LCZ4: open high-rise",
"28. LCZ5: open midrise",
"29: LCZ6: open low-rise",
"30: LCZ7: lightweight low-rise",
"31: LCZ8: large low-rise",
"32: LCZ9: sparsely built",
"33: LCZ10: heavy industry",
],
"esgp.hdf5": [
"0. no data",
"1. sea and oceans",
"2. lakes",
"3. rivers",
"4. bare land",
"5. bare rock",
"6. permanent snow",
"7. boreal broadleaf deciduous",
"8. temperate broadleaf deciduous",
"9. tropical broadleaf deciduous",
"10. temperate broadleaf evergreen",
"11. tropical broadleaf evergreen",
"12. boreal needleleaf evergreen",
"13. temperate needleleaf evergreen",
"14. boreal needleleaf deciduous",
"15. shrubs",
"16. boreal grassland",
"17. temperate grassland",
"18. tropical grassland",
"19. winter C3 crops",
"20. summer C3 crops",
"21. C4 crops",
"22. flooded trees",
"23. flooded grassland",
"24. LCZ1: compact high-rise",
"25. LCZ2: compact midrise",
"26. LCZ3: compact low-rise",
"27. LCZ4: open high-rise",
"28. LCZ5: open midrise",
"29: LCZ6: open low-rise",
"30: LCZ7: lightweight low-rise",
"31: LCZ8: large low-rise",
"32: LCZ9: sparsely built",
"33: LCZ10: heavy industry",
],
"esawc.hdf5": [
"Tree cover",
"Shrubland",
"Grassland",
"Cropland",
"Built-up",
"Bare/sparse veg.",
"Snow and ice",
"Permanent water bodies",
"Herbaceous wetland",
"Mangroves",
"Moss and lichen",
],
}


Expand Down Expand Up @@ -625,7 +795,7 @@ def plot_samples_per_epoch(
vmin=0 - 0.5,
vmax=self.n_classes[dataset_tgt] + 0.5,
)
ax[0][1].set_title("target")
ax[0][1].set_title("Target")
m3 = ax[1][0].imshow(
outputs.cpu().long().numpy(),
cmap=cmap_tgt,
Expand Down Expand Up @@ -660,8 +830,8 @@ def plot_samples_per_epoch(
emb = color_vector.reshape((n_pix, n_pix, 3), order="F").transpose(1, 0, 2)
# emb = np.mean(embedding[0].cpu().numpy(), axis=0)
# m4= ax[1][1].imshow(emb/np.max(emb),vmin=np.percentile(emb,5),vmax=np.percentile(emb,95),cmap="jet")
m4 = ax[1][1].imshow(emb)
ax[1][1].set_title("embedding")
m4 = ax[1][1].imshow((emb * 255).astype(np.uint8))
ax[1][1].set_title("Embedding")
# tell the colorbar to tick at integers
f.colorbar(
m1, ticks=np.arange(0, self.n_classes[dataset_src] + 1), ax=ax[0][0]
Expand All @@ -673,8 +843,9 @@ def plot_samples_per_epoch(
m3, ticks=np.arange(0, self.n_classes[dataset_tgt] + 1), ax=ax[1][0]
)
# f.colorbar(m4,ax=ax[1][1])
acc = np.round((outputs == targets).sum().item()/targets.numel(), 3)
f.suptitle(
"x={},y={}".format(coordinate[0][0].item(), coordinate[1][0].item())
f"x={coordinate[0][0].item()}, y={coordinate[1][0].item()}, accuracy={acc}"
)
f.savefig(title)
plt.close(f)
Expand Down

0 comments on commit 3e0711e

Please sign in to comment.