Skip to content

Commit

Permalink
Adds metadata and fix values ranges for rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
BielStela committed Dec 20, 2023
1 parent c35bfb8 commit e2d24c1
Show file tree
Hide file tree
Showing 7 changed files with 354 additions and 4 deletions.
8 changes: 4 additions & 4 deletions data/h3_data_importer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -314,16 +314,16 @@ convert-deforest-by-human-landuse:
python cog_to_contextual_layer_linker.py --cog deforest_by_human_lu_50km_1000m_cog.tif --name deforest_by_human_lu --category "Environmental datasets" --tiler_param colormap_name=ylorrd --tp rescale=0,0.0025

convert-deforest-carbon-by-human-landuse:
python cog_to_contextual_layer_linker.py --cog deforest_carbon_by_human_lu_50km_1000m_cog.tif --name deforest_carbon_by_human_lu --category "Environmental datasets" --tiler_param colormap_name=bupu --tp rescale=0,0.5
python cog_to_contextual_layer_linker.py --cog deforest_carbon_by_human_lu_50km_1000m_cog.tif --name deforest_carbon_by_human_lu --category "Environmental datasets" --tiler_param colormap_name=gnbu --tp rescale=0,0.5

convert-crop-bii-loss-by-human-landuse:
python cog_to_contextual_layer_linker.py --cog natural_crop_bii_loss_by_human_lu_50km_1000m_cog.tif --name natural_crop_bii_loss_by_human_lu --category "Environmental datasets" --tiler_param colormap_name=purd --tp rescale=0,0.01
python cog_to_contextual_layer_linker.py --cog natural_crop_bii_loss_by_human_lu_50km_1000m_cog.tif --name natural_crop_bii_loss_by_human_lu --category "Environmental datasets" --tiler_param colormap_name=blues --tp rescale=0,0.01

convert-crop-flii-loss-by-human-landuse:
python cog_to_contextual_layer_linker.py --cog natural_crop_flii_loss_by_human_lu_50km_1000m_cog.tif --name natural_crop_flii_loss_by_human_lu --category "Environmental datasets" --tiler_param colormap_name=purples --tp rescale=0,0.01
python cog_to_contextual_layer_linker.py --cog natural_crop_flii_loss_by_human_lu_50km_1000m_cog.tif --name natural_crop_flii_loss_by_human_lu --category "Environmental datasets" --tiler_param colormap_name=rdpu --tp rescale=0,0.01

convert-crop-net-conversion-by-human-landuse:
python cog_to_contextual_layer_linker.py --cog natural_crop_net_conversion_by_human_lu_50km_1000m_cog.tif --name natural_crop_net_conversion_by_human_lu --category "Environmental datasets" --tiler_param colormap_name=oranges --tp rescale=0,0.01
python cog_to_contextual_layer_linker.py --cog natural_crop_net_conversion_by_human_lu_50km_1000m_cog.tif --name natural_crop_net_conversion_by_human_lu --category "Environmental datasets" --tiler_param colormap_name=ylgn --tp rescale=0,0.01


#####################
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"$schema": "./contextual_metadata_schema.json",
"name": "Deforestation by human land use",
"description": "The deforestation indicator estimates the extent of deforestation that can be attributed to\na spatial footprint, such as that required for production of a raw material. It measures the\namount of deforestation that occurs nearby to the areas where raw materials are\nproduced within a supply shed.",
"legend": {
"name": "Deforestation",
"id": "",
"unit": "ha/yr / ha LU",
"min": "0",
"type": "range",
"items": [
{
"color": "#ffffcc",
"value": "0.0"
},
{
"color": "#fed976",
"value": "0.000625"
},
{
"color": "#fd8c3c",
"value": "0.00125"
},
{
"color": "#e2191c",
"value": "0.001875"
},
{
"color": "#800026",
"value": "0.0025"
}
]
},
"aggType": "mean",
"source": "https://www.biorxiv.org/content/10.1101/2023.11.01.565036v1.full.pdf",
"license": "CC BY 4.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"$schema": "./contextual_metadata_schema.json",
"name": "Greenhouse gas emissions from deforestation",
"description": "Deforestation carbon loss is the amount of carbon emissions that can be associated with\na deforestation event. We estimate forest carbon loss due to deforestation by combining\ndeforestation extent with maps of vulnerable carbon (Noon et al. 2021) in those same\nareas. Vulnerable carbon, the amount of biomass and soil carbon that would be lost in a\nland use change event, is reported globally for 2010 at a 300m resolution.",
"legend": {
"name": "Greenhouse gas emissions from deforestation",
"id": "",
"unit": "tCO2/yr / ha LU",
"min": "0",
"type": "range",
"items": [
{
"color": "#f7fcf0",
"value": "0.0"
},
{
"color": "#ccebc5",
"value": "0.0125"
},
{
"color": "#7accc4",
"value": "0.025"
},
{
"color": "#2a8bbe",
"value": "0.037500000000000006"
},
{
"color": "#084081",
"value": "0.05"
}
]
},
"aggType": "mean",
"source": "https://www.biorxiv.org/content/10.1101/2023.11.01.565036v1.full.pdf",
"license": "CC BY 4.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"$schema": "./contextual_metadata_schema.json",
"name": "Loss of biodiversity intactness to cropland expansion",
"description": " The Biodiversity\nIntactness index (BI) is an indicator of loss of species richness and change in species\ncomposition due to human pressures",
"legend": {
"name": "Loss of biodiversity intactness to cropland expansion",
"id": "",
"unit": "bii score / ha LU",
"min": "0",
"type": "range",
"items": [
{
"color": "#f7fbff",
"value": "0.0"
},
{
"color": "#c6dbef",
"value": "0.0025"
},
{
"color": "#6aaed6",
"value": "0.005"
},
{
"color": "#2070b4",
"value": "0.0075"
},
{
"color": "#08306b",
"value": "0.01"
}
]
},
"aggType": "mean",
"source": "https://www.biorxiv.org/content/10.1101/2023.11.01.565036v1.full.pdf",
"license": "CC BY 4.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"$schema": "./contextual_metadata_schema.json",
"name": "Loss of forest integrity to cropland expansion",
"description": "The Forest Landscape Integrity Index (FLII) expresses the\ndegree of intactness of forest ecosystems based on the spatial structure of the forest\nhabitat and on the degree of human modification to the ecosystem",
"legend": {
"name": "Loss of forest integrity to cropland expansion",
"id": "",
"unit": "flii score / ha LU",
"min": "0",
"type": "range",
"items": [
{
"color": "#fff7f3",
"value": "0.0"
},
{
"color": "#fcc5c0",
"value": "0.0025"
},
{
"color": "#f767a1",
"value": "0.005"
},
{
"color": "#ad017e",
"value": "0.0075"
},
{
"color": "#49006a",
"value": "0.01"
}
]
},
"aggType": "mean",
"source": "https://www.biorxiv.org/content/10.1101/2023.11.01.565036v1.full.pdf",
"license": "CC BY 4.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"$schema": "./contextual_metadata_schema.json",
"name": "Net cropland expansion in natural lands",
"description": "Due to limitations in remotely sensed data on sparse human land uses such as logging\nand pasturing, we use a conservative approach evaluating only the conversion of natural\necosystems directly to cropland, using the SBTN Natural Lands dataset (Mazur et al.\n2023).",
"legend": {
"name": "Net cropland expansion in natural lands",
"id": "",
"unit": "ha/yr / ha LU",
"min": "0",
"type": "range",
"items": [
{
"color": "#ffffe5",
"value": "0.0"
},
{
"color": "#d9f0a3",
"value": "0.0025"
},
{
"color": "#77c679",
"value": "0.005"
},
{
"color": "#228343",
"value": "0.0075"
},
{
"color": "#004529",
"value": "0.01"
}
]
},
"aggType": "mean",
"source": "https://www.biorxiv.org/content/10.1101/2023.11.01.565036v1.full.pdf",
"license": "CC BY 4.0"
}
165 changes: 165 additions & 0 deletions data/notebooks/Lab/color_dict.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 8,
"id": "initial_id",
"metadata": {
"collapsed": true,
"ExecuteTime": {
"end_time": "2023-12-20T12:01:24.517389896Z",
"start_time": "2023-12-20T12:01:24.515214956Z"
}
},
"outputs": [],
"source": [
"import json\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"from matplotlib.colors import rgb2hex\n",
"\n",
"\n",
"def generate_colormap_dict(cmap_name, n, vmin, vmax):\n",
" cmap = plt.get_cmap(cmap_name)\n",
" colors = cmap(np.linspace(0, 1, n))\n",
" values = np.linspace(vmin, vmax, n)\n",
" color_dict = [\n",
" {\"color\": rgb2hex(color), \"value\": str(value)} for color, value in zip(colors, values)\n",
" ]\n",
" return json.dumps(color_dict)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"outputs": [
{
"data": {
"text/plain": "'[{\"color\": \"#ffffcc\", \"value\": \"0.0\"}, {\"color\": \"#fed976\", \"value\": \"0.000625\"}, {\"color\": \"#fd8c3c\", \"value\": \"0.00125\"}, {\"color\": \"#e2191c\", \"value\": \"0.001875\"}, {\"color\": \"#800026\", \"value\": \"0.0025\"}]'"
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"generate_colormap_dict(\"YlOrRd\", 5, 0, 0.0025)"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-12-20T12:01:25.158357764Z",
"start_time": "2023-12-20T12:01:25.154326681Z"
}
},
"id": "15ad6dbc99a8ffcc"
},
{
"cell_type": "code",
"execution_count": 14,
"outputs": [
{
"data": {
"text/plain": "'[{\"color\": \"#f7fbff\", \"value\": \"0.0\"}, {\"color\": \"#c6dbef\", \"value\": \"0.0025\"}, {\"color\": \"#6aaed6\", \"value\": \"0.005\"}, {\"color\": \"#2070b4\", \"value\": \"0.0075\"}, {\"color\": \"#08306b\", \"value\": \"0.01\"}]'"
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"generate_colormap_dict(\"Blues\", 5, 0, 0.01)"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-12-20T12:04:21.700652510Z",
"start_time": "2023-12-20T12:04:21.659523456Z"
}
},
"id": "64268fefa8441e98"
},
{
"cell_type": "code",
"execution_count": 12,
"outputs": [
{
"data": {
"text/plain": "'[{\"color\": \"#ffffe5\", \"value\": \"0.0\"}, {\"color\": \"#d9f0a3\", \"value\": \"0.0025\"}, {\"color\": \"#77c679\", \"value\": \"0.005\"}, {\"color\": \"#228343\", \"value\": \"0.0075\"}, {\"color\": \"#004529\", \"value\": \"0.01\"}]'"
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"generate_colormap_dict(\"YlGn\", 5, 0, 0.01)"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-12-20T12:03:20.695073782Z",
"start_time": "2023-12-20T12:03:20.640846083Z"
}
},
"id": "b92d34b1b8a350c9"
},
{
"cell_type": "code",
"execution_count": 13,
"outputs": [
{
"data": {
"text/plain": "'[{\"color\": \"#fff7f3\", \"value\": \"0.0\"}, {\"color\": \"#fcc5c0\", \"value\": \"0.0025\"}, {\"color\": \"#f767a1\", \"value\": \"0.005\"}, {\"color\": \"#ad017e\", \"value\": \"0.0075\"}, {\"color\": \"#49006a\", \"value\": \"0.01\"}]'"
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"generate_colormap_dict(\"RdPu\", 5, 0, 0.01)"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2023-12-20T12:03:52.962917750Z",
"start_time": "2023-12-20T12:03:52.942415581Z"
}
},
"id": "2d7fc6eb3c0d2f2f"
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [],
"metadata": {
"collapsed": false
},
"id": "6bd0f54aefd49f67"
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

0 comments on commit e2d24c1

Please sign in to comment.