Download map.py from boettiger-lab/carbon: direct link, hf CLI and curl.
- Browser
- Download file 1.77 kB
-
https://huggingface.co/datasets/boettiger-lab/carbon/resolve/main/map.py
- Command line
-
hf download hf://datasets/boettiger-lab/carbon/map.py
-
curl -L -o map.py https://huggingface.co/datasets/boettiger-lab/carbon/resolve/main/map.py
1.77 kB
| # -*- coding: utf-8 -*- | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| import leafmap.foliumap as leafmap | |
| # + | |
| from pathlib import Path | |
| files = [path for path in Path('.').glob('**/*.tif')] | |
| done = [path for path in Path('.').glob('cogs/*.tif')] | |
| # - | |
| B = [x.name for x in done] | |
| A = [x.name.lower() for x in files] | |
| C=[i for i in A if i not in B] | |
| C | |
| # + | |
| for x in inputs: | |
| dest = "cogs/" + x.name.lower() | |
| leafmap.image_to_cog(str(x), dest) | |
| # + | |
| m = leafmap.Map(center=[35, -100], zoom=3) | |
| #m.add_basemap("Esri.WorldGrayCanvas") | |
| #m.add_cog_layer("https://data.source.coop/cboettig/mobi/species-richness-all/SpeciesRichness_All.tif", palette="Reds", name="Richness", nodata=0, transparent_bg=True, opacity = 0.9) | |
| m.add_cog_layer("https://data.source.coop/cboettig/carbon/cogs/irrecoverable_c_total_2018.tif", palette="reds", name="irrecoverable carbon", transparent_bg=True, opacity = 0.8) | |
| m.add_cog_layer("https://data.source.coop/cboettig/carbon/cogs/vulnerable_c_total_2018.tif", palette="purples", name="vulnerable carbon", transparent_bg=True, opacity = 0.8) | |
| m.add_cog_layer("https://data.source.coop/cboettig/carbon/cogs/manageable_c_total_2018.tif", palette="greens", name="manageable carbon", transparent_bg=True, opacity = 0.8) | |
| m.to_html("map.html") | |
| m | |