Skip to content

Commit 5474d20

Browse files
Merge pull request #118 from NASA-IMPACT/ab/fix-no2-rescale
Ab/fix no2 rescale
2 parents 735f4d7 + d6ae285 commit 5474d20

File tree

1 file changed

+60
-60
lines changed

1 file changed

+60
-60
lines changed

notebooks/quickstarts/no2-map-plot.ipynb

+60-60
Original file line numberDiff line numberDiff line change
@@ -115,19 +115,21 @@
115115
" 'type': 'application/json',\n",
116116
" 'href': 'https://staging-stac.delta-backend.com/collections/no2-monthly'}],\n",
117117
" 'title': 'NO₂',\n",
118+
" 'assets': None,\n",
118119
" 'extent': {'spatial': {'bbox': [[-180, -90, 180, 90]]},\n",
119-
" 'temporal': {'interval': [['2015-12-31 17:00:00-07',\n",
120-
" '2022-04-30 18:00:00-06']]}},\n",
120+
" 'temporal': {'interval': [['2016-01-01 00:00:00+00',\n",
121+
" '2023-09-30 00:00:00+00']]}},\n",
121122
" 'license': 'MIT',\n",
122-
" 'summaries': {'datetime': ['2016-01-01T00:00:00Z', '2022-05-01T00:00:00Z'],\n",
123-
" 'cog_default': {'max': 50064805976866816, 'min': -6618294421291008}},\n",
123+
" 'keywords': None,\n",
124+
" 'providers': None,\n",
125+
" 'summaries': {'datetime': ['2016-01-01T00:00:00Z', '2023-09-30T00:00:00Z']},\n",
124126
" '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",
125127
" 'item_assets': {'cog_default': {'type': 'image/tiff; application=geotiff; profile=cloud-optimized',\n",
126128
" 'roles': ['data', 'layer'],\n",
127129
" 'title': 'Default COG Layer',\n",
128130
" 'description': 'Cloud optimized default layer to display on map'}},\n",
129131
" 'stac_version': '1.0.0',\n",
130-
" 'stac_extensions': ['https://stac-extensions.github.io/item-assets/v1.0.0/schema.json'],\n",
132+
" 'stac_extensions': None,\n",
131133
" 'dashboard:is_periodic': True,\n",
132134
" 'dashboard:time_density': 'month'}"
133135
]
@@ -142,28 +144,6 @@
142144
"collection"
143145
]
144146
},
145-
{
146-
"cell_type": "code",
147-
"execution_count": 4,
148-
"id": "7bc42fff",
149-
"metadata": {},
150-
"outputs": [
151-
{
152-
"data": {
153-
"text/plain": [
154-
"{'max': 50064805976866816, 'min': -6618294421291008}"
155-
]
156-
},
157-
"execution_count": 4,
158-
"metadata": {},
159-
"output_type": "execute_result"
160-
}
161-
],
162-
"source": [
163-
"rescale_values = collection[\"summaries\"][\"cog_default\"]\n",
164-
"rescale_values"
165-
]
166-
},
167147
{
168148
"cell_type": "markdown",
169149
"id": "aea3352d-6a38-41c7-9dc9-f2c010b3a85b",
@@ -176,7 +156,7 @@
176156
},
177157
{
178158
"cell_type": "code",
179-
"execution_count": 5,
159+
"execution_count": 6,
180160
"id": "b5eb7467",
181161
"metadata": {},
182162
"outputs": [
@@ -186,7 +166,7 @@
186166
"1"
187167
]
188168
},
189-
"execution_count": 5,
169+
"execution_count": 6,
190170
"metadata": {},
191171
"output_type": "execute_result"
192172
}
@@ -214,7 +194,7 @@
214194
},
215195
{
216196
"cell_type": "code",
217-
"execution_count": 6,
197+
"execution_count": 7,
218198
"id": "79a63492-b9be-4278-85f8-5464fcd9d142",
219199
"metadata": {
220200
"tags": []
@@ -290,7 +270,7 @@
290270
" 'https://stac-extensions.github.io/raster/v1.1.0/schema.json']}"
291271
]
292272
},
293-
"execution_count": 6,
273+
"execution_count": 7,
294274
"metadata": {},
295275
"output_type": "execute_result"
296276
}
@@ -300,6 +280,17 @@
300280
"item"
301281
]
302282
},
283+
{
284+
"cell_type": "code",
285+
"execution_count": 8,
286+
"id": "7bc42fff",
287+
"metadata": {},
288+
"outputs": [],
289+
"source": [
290+
"item_stats = item['assets']['cog_default']['raster:bands'][0]['statistics']\n",
291+
"rescale_values = item_stats['minimum'], item_stats['maximum']"
292+
]
293+
},
303294
{
304295
"cell_type": "markdown",
305296
"id": "c9b60ad7-ed96-42b2-9263-f7ddaa6ea7fe",
@@ -312,7 +303,7 @@
312303
},
313304
{
314305
"cell_type": "code",
315-
"execution_count": 7,
306+
"execution_count": 10,
316307
"id": "71acb916",
317308
"metadata": {},
318309
"outputs": [
@@ -322,14 +313,14 @@
322313
"{'tilejson': '2.2.0',\n",
323314
" 'version': '1.0.0',\n",
324315
" 'scheme': 'xyz',\n",
325-
" '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",
316+
" '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",
326317
" 'minzoom': 0,\n",
327318
" 'maxzoom': 24,\n",
328319
" 'bounds': [-180.0, -90.0, 180.0, 90.0],\n",
329320
" 'center': [0.0, 0.0, 0]}"
330321
]
331322
},
332-
"execution_count": 7,
323+
"execution_count": 10,
333324
"metadata": {},
334325
"output_type": "execute_result"
335326
}
@@ -339,7 +330,7 @@
339330
" f\"{RASTER_API_URL}/stac/tilejson.json?collection={item['collection']}&item={item['id']}\"\n",
340331
" \"&assets=cog_default\"\n",
341332
" \"&color_formula=gamma+r+1.05&colormap_name=rdbu_r\"\n",
342-
" f\"&rescale={rescale_values['min']},{rescale_values['max']}\",\n",
333+
" f\"&rescale={rescale_values[0]},{rescale_values[1]}\",\n",
343334
").json()\n",
344335
"tiles"
345336
]
@@ -354,15 +345,17 @@
354345
},
355346
{
356347
"cell_type": "code",
357-
"execution_count": 8,
348+
"execution_count": 11,
358349
"id": "b4792eed",
359350
"metadata": {},
360351
"outputs": [
361352
{
362353
"data": {
363354
"text/html": [
364355
"<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",
365-
"&lt;head&gt; \n",
356+
"&lt;html&gt;\n",
357+
"&lt;head&gt;\n",
358+
" \n",
366359
" &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;\n",
367360
" \n",
368361
" &lt;script&gt;\n",
@@ -372,41 +365,44 @@
372365
" \n",
373366
" &lt;style&gt;html, body {width: 100%;height: 100%;margin: 0;padding: 0;}&lt;/style&gt;\n",
374367
" &lt;style&gt;#map {position:absolute;top:0;bottom:0;right:0;left:0;}&lt;/style&gt;\n",
375-
" &lt;script src=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.6.0/dist/leaflet.js&quot;&gt;&lt;/script&gt;\n",
376-
" &lt;script src=&quot;https://code.jquery.com/jquery-1.12.4.min.js&quot;&gt;&lt;/script&gt;\n",
377-
" &lt;script src=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js&quot;&gt;&lt;/script&gt;\n",
368+
" &lt;script src=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.9.3/dist/leaflet.js&quot;&gt;&lt;/script&gt;\n",
369+
" &lt;script src=&quot;https://code.jquery.com/jquery-3.7.1.min.js&quot;&gt;&lt;/script&gt;\n",
370+
" &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",
378371
" &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",
379-
" &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.6.0/dist/leaflet.css&quot;/&gt;\n",
380-
" &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css&quot;/&gt;\n",
381-
" &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css&quot;/&gt;\n",
382-
" &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",
372+
" &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/leaflet@1.9.3/dist/leaflet.css&quot;/&gt;\n",
373+
" &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",
374+
" &lt;link rel=&quot;stylesheet&quot; href=&quot;https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css&quot;/&gt;\n",
375+
" &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/@fortawesome/[email protected]/css/all.min.css&quot;/&gt;\n",
383376
" &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",
384377
" &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",
385378
" \n",
386379
" &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width,\n",
387380
" initial-scale=1.0, maximum-scale=1.0, user-scalable=no&quot; /&gt;\n",
388381
" &lt;style&gt;\n",
389-
" #map_53c3ccf28112c91094ab0e61813af94b {\n",
382+
" #map_b760f5d56c6e116deffd4c09b180e7c2 {\n",
390383
" position: relative;\n",
391384
" width: 100.0%;\n",
392385
" height: 100.0%;\n",
393386
" left: 0.0%;\n",
394387
" top: 0.0%;\n",
395388
" }\n",
389+
" .leaflet-container { font-size: 1rem; }\n",
396390
" &lt;/style&gt;\n",
397391
" \n",
398392
"&lt;/head&gt;\n",
399-
"&lt;body&gt; \n",
393+
"&lt;body&gt;\n",
400394
" \n",
401-
" &lt;div class=&quot;folium-map&quot; id=&quot;map_53c3ccf28112c91094ab0e61813af94b&quot; &gt;&lt;/div&gt;\n",
395+
" \n",
396+
" &lt;div class=&quot;folium-map&quot; id=&quot;map_b760f5d56c6e116deffd4c09b180e7c2&quot; &gt;&lt;/div&gt;\n",
402397
" \n",
403398
"&lt;/body&gt;\n",
404-
"&lt;script&gt; \n",
399+
"&lt;script&gt;\n",
400+
" \n",
405401
" \n",
406-
" var map_53c3ccf28112c91094ab0e61813af94b = L.map(\n",
407-
" &quot;map_53c3ccf28112c91094ab0e61813af94b&quot;,\n",
402+
" var map_b760f5d56c6e116deffd4c09b180e7c2 = L.map(\n",
403+
" &quot;map_b760f5d56c6e116deffd4c09b180e7c2&quot;,\n",
408404
" {\n",
409-
" center: [0, 0],\n",
405+
" center: [0.0, 0.0],\n",
410406
" crs: L.CRS.EPSG3857,\n",
411407
" zoom: 1,\n",
412408
" zoomControl: true,\n",
@@ -418,18 +414,22 @@
418414
"\n",
419415
" \n",
420416
" \n",
421-
" var tile_layer_b857ce32e1cc437e1998c6d0926b2f21 = L.tileLayer(\n",
422-
" &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",
417+
" var tile_layer_8bcaf12e8a9ebcbfd6f653010cb98f18 = L.tileLayer(\n",
418+
" &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",
423419
" {&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",
424-
" ).addTo(map_53c3ccf28112c91094ab0e61813af94b);\n",
420+
" );\n",
421+
" \n",
422+
" \n",
423+
" tile_layer_8bcaf12e8a9ebcbfd6f653010cb98f18.addTo(map_b760f5d56c6e116deffd4c09b180e7c2);\n",
425424
" \n",
426-
"&lt;/script&gt;\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe></div></div>"
425+
"&lt;/script&gt;\n",
426+
"&lt;/html&gt;\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe></div></div>"
427427
],
428428
"text/plain": [
429-
"<folium.folium.Map at 0x7f63906c6af0>"
429+
"<folium.folium.Map at 0x7fcac62cb650>"
430430
]
431431
},
432-
"execution_count": 8,
432+
"execution_count": 11,
433433
"metadata": {},
434434
"output_type": "execute_result"
435435
}
@@ -444,9 +444,9 @@
444444
],
445445
"metadata": {
446446
"kernelspec": {
447-
"display_name": "Python [conda env:notebook] *",
447+
"display_name": "Python 3 (ipykernel)",
448448
"language": "python",
449-
"name": "conda-env-notebook-py"
449+
"name": "python3"
450450
},
451451
"language_info": {
452452
"codemirror_mode": {
@@ -458,7 +458,7 @@
458458
"name": "python",
459459
"nbconvert_exporter": "python",
460460
"pygments_lexer": "ipython3",
461-
"version": "3.9.13"
461+
"version": "3.11.7"
462462
}
463463
},
464464
"nbformat": 4,

0 commit comments

Comments
 (0)