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

Fix COG custom colormap bug #868

Merged
merged 2 commits into from
Aug 7, 2024
Merged

Fix COG custom colormap bug #868

merged 2 commits into from
Aug 7, 2024

Conversation

giswqs
Copy link
Member

@giswqs giswqs commented Aug 7, 2024

Fix #867

import leafmap

url = "https://clarkcga-aquaculture.s3.amazonaws.com/data/el_salvador/cover/El_Salvador_Landcover_2022.tif"
custom_cmap = {
    "0": "#000000",
    "1": "#008040",
    "2": "#ff0000",
    "3": "#ffff00",
    "4": "#8000ff",
    "5": "#8080ff",
    "6": "#00ff00",
    "7": "#c0c0c0",
    "8": "#16002d",
    "9": "#ff80ff",
    "10": "#b3ffb3",
    "11": "#ff8080",
    "12": "#ffffbf",
    "13": "#000080",
    "14": "#808000",
    "15": "#00ffff",
}
m = leafmap.Map()
m.add_cog_layer(url, colormap=custom_cmap, name="El_Salvador")
legend_dict = dict(zip([int(key) for key in custom_cmap.keys()], custom_cmap.values()))
m.add_legend(title="Landcover", legend_dict=legend_dict)
m

image

@giswqs giswqs merged commit 2761c59 into master Aug 7, 2024
14 checks passed
@giswqs giswqs deleted the colormap branch August 7, 2024 18:17
Copy link

github-actions bot commented Aug 7, 2024

@github-actions github-actions bot temporarily deployed to pull request August 7, 2024 18:32 Inactive
giswqs added a commit that referenced this pull request Sep 1, 2024
* Fix COG custom colormap bug

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant