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

Ab/fix no2 rescale #118

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 60 additions & 60 deletions notebooks/quickstarts/no2-map-plot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -115,19 +115,21 @@
" 'type': 'application/json',\n",
" 'href': 'https://staging-stac.delta-backend.com/collections/no2-monthly'}],\n",
" 'title': 'NO₂',\n",
" 'assets': None,\n",
" 'extent': {'spatial': {'bbox': [[-180, -90, 180, 90]]},\n",
" 'temporal': {'interval': [['2015-12-31 17:00:00-07',\n",
" '2022-04-30 18:00:00-06']]}},\n",
" 'temporal': {'interval': [['2016-01-01 00:00:00+00',\n",
" '2023-09-30 00:00:00+00']]}},\n",
" 'license': 'MIT',\n",
" 'summaries': {'datetime': ['2016-01-01T00:00:00Z', '2022-05-01T00:00:00Z'],\n",
" 'cog_default': {'max': 50064805976866816, 'min': -6618294421291008}},\n",
" 'keywords': None,\n",
" 'providers': None,\n",
" 'summaries': {'datetime': ['2016-01-01T00:00:00Z', '2023-09-30T00:00:00Z']},\n",
" 'description': 'Darker colors indicate higher nitrogen dioxide (NO₂) levels and more activity. Lighter colors indicate lower levels of NO₂ and less activity. Missing pixels indicate areas of no data most likely associated with cloud cover or snow.',\n",
" 'item_assets': {'cog_default': {'type': 'image/tiff; application=geotiff; profile=cloud-optimized',\n",
" 'roles': ['data', 'layer'],\n",
" 'title': 'Default COG Layer',\n",
" 'description': 'Cloud optimized default layer to display on map'}},\n",
" 'stac_version': '1.0.0',\n",
" 'stac_extensions': ['https://stac-extensions.github.io/item-assets/v1.0.0/schema.json'],\n",
" 'stac_extensions': None,\n",
" 'dashboard:is_periodic': True,\n",
" 'dashboard:time_density': 'month'}"
]
Expand All @@ -142,28 +144,6 @@
"collection"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "7bc42fff",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'max': 50064805976866816, 'min': -6618294421291008}"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rescale_values = collection[\"summaries\"][\"cog_default\"]\n",
"rescale_values"
]
},
{
"cell_type": "markdown",
"id": "aea3352d-6a38-41c7-9dc9-f2c010b3a85b",
Expand All @@ -176,7 +156,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 6,
"id": "b5eb7467",
"metadata": {},
"outputs": [
Expand All @@ -186,7 +166,7 @@
"1"
]
},
"execution_count": 5,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -214,7 +194,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 7,
"id": "79a63492-b9be-4278-85f8-5464fcd9d142",
"metadata": {
"tags": []
Expand Down Expand Up @@ -290,7 +270,7 @@
" 'https://stac-extensions.github.io/raster/v1.1.0/schema.json']}"
]
},
"execution_count": 6,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -300,6 +280,17 @@
"item"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "7bc42fff",
"metadata": {},
"outputs": [],
"source": [
"item_stats = item['assets']['cog_default']['raster:bands'][0]['statistics']\n",
"rescale_values = item_stats['minimum'], item_stats['maximum']"
]
},
{
"cell_type": "markdown",
"id": "c9b60ad7-ed96-42b2-9263-f7ddaa6ea7fe",
Expand All @@ -312,7 +303,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 10,
"id": "71acb916",
"metadata": {},
"outputs": [
Expand All @@ -322,14 +313,14 @@
"{'tilejson': '2.2.0',\n",
" 'version': '1.0.0',\n",
" 'scheme': 'xyz',\n",
" 'tiles': ['https://staging-raster.delta-backend.com/stac/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?collection=no2-monthly&item=OMI_trno2_0.10x0.10_202101_Col3_V4.nc&assets=cog_default&color_formula=gamma+r+1.05&colormap_name=rdbu_r&rescale=-6618294421291008%2C50064805976866816'],\n",
" 'tiles': ['https://staging-raster.delta-backend.com/stac/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?collection=no2-monthly&item=OMI_trno2_0.10x0.10_202101_Col3_V4.nc&assets=cog_default&color_formula=gamma+r+1.05&colormap_name=rdbu_r&rescale=-4107596126486528.0%2C35781585143857150'],\n",
" 'minzoom': 0,\n",
" 'maxzoom': 24,\n",
" 'bounds': [-180.0, -90.0, 180.0, 90.0],\n",
" 'center': [0.0, 0.0, 0]}"
]
},
"execution_count": 7,
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -339,7 +330,7 @@
" f\"{RASTER_API_URL}/stac/tilejson.json?collection={item['collection']}&item={item['id']}\"\n",
" \"&assets=cog_default\"\n",
" \"&color_formula=gamma+r+1.05&colormap_name=rdbu_r\"\n",
" f\"&rescale={rescale_values['min']},{rescale_values['max']}\",\n",
" f\"&rescale={rescale_values[0]},{rescale_values[1]}\",\n",
").json()\n",
"tiles"
]
Expand All @@ -354,15 +345,17 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 11,
"id": "b4792eed",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div style=\"width:100%;\"><div style=\"position:relative;width:100%;height:0;padding-bottom:60%;\"><span style=\"color:#565656\">Make this Notebook Trusted to load map: File -> Trust Notebook</span><iframe srcdoc=\"&lt;!DOCTYPE html&gt;\n",
"&lt;head&gt; \n",
"&lt;html&gt;\n",
"&lt;head&gt;\n",
" \n",
" &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;\n",
" \n",
" &lt;script&gt;\n",
Expand All @@ -372,41 +365,44 @@
" \n",
" &lt;style&gt;html, body {width: 100%;height: 100%;margin: 0;padding: 0;}&lt;/style&gt;\n",
" &lt;style&gt;#map {position:absolute;top:0;bottom:0;right:0;left:0;}&lt;/style&gt;\n",
" &lt;script src=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.6.0/dist/leaflet.js&quot;&gt;&lt;/script&gt;\n",
" &lt;script src=&quot;https://code.jquery.com/jquery-1.12.4.min.js&quot;&gt;&lt;/script&gt;\n",
" &lt;script src=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js&quot;&gt;&lt;/script&gt;\n",
" &lt;script src=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.9.3/dist/leaflet.js&quot;&gt;&lt;/script&gt;\n",
" &lt;script src=&quot;https://code.jquery.com/jquery-3.7.1.min.js&quot;&gt;&lt;/script&gt;\n",
" &lt;script src=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.bundle.min.js&quot;&gt;&lt;/script&gt;\n",
" &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.js&quot;&gt;&lt;/script&gt;\n",
" &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.6.0/dist/leaflet.css&quot;/&gt;\n",
" &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css&quot;/&gt;\n",
" &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css&quot;/&gt;\n",
" &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css&quot;/&gt;\n",
" &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.9.3/dist/leaflet.css&quot;/&gt;\n",
" &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css&quot;/&gt;\n",
" &lt;link rel=&quot;stylesheet&quot; href=&quot;https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css&quot;/&gt;\n",
" &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/@fortawesome/[email protected]/css/all.min.css&quot;/&gt;\n",
" &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css&quot;/&gt;\n",
" &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/gh/python-visualization/folium/folium/templates/leaflet.awesome.rotate.min.css&quot;/&gt;\n",
" \n",
" &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width,\n",
" initial-scale=1.0, maximum-scale=1.0, user-scalable=no&quot; /&gt;\n",
" &lt;style&gt;\n",
" #map_53c3ccf28112c91094ab0e61813af94b {\n",
" #map_b760f5d56c6e116deffd4c09b180e7c2 {\n",
" position: relative;\n",
" width: 100.0%;\n",
" height: 100.0%;\n",
" left: 0.0%;\n",
" top: 0.0%;\n",
" }\n",
" .leaflet-container { font-size: 1rem; }\n",
" &lt;/style&gt;\n",
" \n",
"&lt;/head&gt;\n",
"&lt;body&gt; \n",
"&lt;body&gt;\n",
" \n",
" &lt;div class=&quot;folium-map&quot; id=&quot;map_53c3ccf28112c91094ab0e61813af94b&quot; &gt;&lt;/div&gt;\n",
" \n",
" &lt;div class=&quot;folium-map&quot; id=&quot;map_b760f5d56c6e116deffd4c09b180e7c2&quot; &gt;&lt;/div&gt;\n",
" \n",
"&lt;/body&gt;\n",
"&lt;script&gt; \n",
"&lt;script&gt;\n",
" \n",
" \n",
" var map_53c3ccf28112c91094ab0e61813af94b = L.map(\n",
" &quot;map_53c3ccf28112c91094ab0e61813af94b&quot;,\n",
" var map_b760f5d56c6e116deffd4c09b180e7c2 = L.map(\n",
" &quot;map_b760f5d56c6e116deffd4c09b180e7c2&quot;,\n",
" {\n",
" center: [0, 0],\n",
" center: [0.0, 0.0],\n",
" crs: L.CRS.EPSG3857,\n",
" zoom: 1,\n",
" zoomControl: true,\n",
Expand All @@ -418,18 +414,22 @@
"\n",
" \n",
" \n",
" var tile_layer_b857ce32e1cc437e1998c6d0926b2f21 = L.tileLayer(\n",
" &quot;https://staging-raster.delta-backend.com/stac/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?collection=no2-monthly\\u0026item=OMI_trno2_0.10x0.10_202101_Col3_V4.nc\\u0026assets=cog_default\\u0026color_formula=gamma+r+1.05\\u0026colormap_name=rdbu_r\\u0026rescale=-6618294421291008%2C50064805976866816&quot;,\n",
" var tile_layer_8bcaf12e8a9ebcbfd6f653010cb98f18 = L.tileLayer(\n",
" &quot;https://staging-raster.delta-backend.com/stac/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?collection=no2-monthly\\u0026item=OMI_trno2_0.10x0.10_202101_Col3_V4.nc\\u0026assets=cog_default\\u0026color_formula=gamma+r+1.05\\u0026colormap_name=rdbu_r\\u0026rescale=-4107596126486528.0%2C35781585143857150&quot;,\n",
" {&quot;attribution&quot;: &quot;VEDA&quot;, &quot;detectRetina&quot;: false, &quot;maxNativeZoom&quot;: 18, &quot;maxZoom&quot;: 18, &quot;minZoom&quot;: 0, &quot;noWrap&quot;: false, &quot;opacity&quot;: 1, &quot;subdomains&quot;: &quot;abc&quot;, &quot;tms&quot;: false}\n",
" ).addTo(map_53c3ccf28112c91094ab0e61813af94b);\n",
" );\n",
" \n",
" \n",
" tile_layer_8bcaf12e8a9ebcbfd6f653010cb98f18.addTo(map_b760f5d56c6e116deffd4c09b180e7c2);\n",
" \n",
"&lt;/script&gt;\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe></div></div>"
"&lt;/script&gt;\n",
"&lt;/html&gt;\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe></div></div>"
],
"text/plain": [
"<folium.folium.Map at 0x7f63906c6af0>"
"<folium.folium.Map at 0x7fcac62cb650>"
]
},
"execution_count": 8,
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -444,9 +444,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python [conda env:notebook] *",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "conda-env-notebook-py"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -458,7 +458,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.11.7"
}
},
"nbformat": 4,
Expand Down
Loading