Skip to content

Commit

Permalink
fix: user notebooks fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Ram Sharan Rimal committed Sep 18, 2024
1 parent 53f739c commit 1e0e4dd
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 44 deletions.
2 changes: 1 addition & 1 deletion styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

/* Adjust height of the cell output in user notebooks*/
.cell-output {
max-height: 500px;
max-height: 600px;
overflow-y: auto;
overflow-x: auto;
background-color:#fefdfe;
Expand Down
93 changes: 50 additions & 43 deletions user_data_notebooks/gra2pes-ghg-monthgrid-v1_User_Notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"## Approach\n",
"\n",
"1. Identify available dates and temporal frequency of observations for the given collection using the GHGC API `/stac` endpoint. The collection processed in this notebook is the Vulcan Fossil Fuel CO₂ Emissions Data product.\n",
"2. Pass the STAC item into the raster API `/stac/tilejson.json `endpoint.\n",
"2. Pass the STAC item into the raster API `/collections/{collection_id}/items/{item_id}/tilejson.json `endpoint.\n",
"3. Using `folium.plugins.DualMap`, we will visualize two tiles (side-by-side), allowing us to compare time points. \n",
"4. After the visualization, we will perform zonal statistics for a given polygon.\n",
"\n",
Expand Down Expand Up @@ -75,7 +75,16 @@
"execution_count": 1,
"id": "503e5661-b99b-421b-b4ba-361bb531e5fa",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/rrimal/Library/Python/3.9/lib/python/site-packages/urllib3/__init__.py:35: NotOpenSSLWarning: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020\n",
" warnings.warn(\n"
]
}
],
"source": [
"import requests\n",
"import folium\n",
Expand Down Expand Up @@ -114,7 +123,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 3,
"id": "941eae92-6ec0-46a4-ab8f-739973b59e6f",
"metadata": {},
"outputs": [],
Expand All @@ -134,7 +143,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 4,
"id": "b56d6c87-11b9-48ca-9723-8304984a644b",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -164,7 +173,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 5,
"id": "eaaf1487-2e71-490b-a968-e57ee332a919",
"metadata": {},
"outputs": [
Expand All @@ -180,12 +189,12 @@
"# Apply the above function and check the total number of items available within the collection\n",
"number_of_items = get_item_count(collection_name)\n",
"items_graapes = requests.get(f\"{STAC_API_URL}/collections/{collection_name}/items?limit={number_of_items}\").json()[\"features\"]\n",
"print(f\"Found {len(items_vulcan)} items\")"
"print(f\"Found {len(items_graapes)} items\")"
]
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 6,
"id": "01619ee2-728c-4abc-9edf-a2c85d87128d",
"metadata": {},
"outputs": [],
Expand All @@ -198,7 +207,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 7,
"id": "f9deb11d-4c33-4f59-8532-7829602e3113",
"metadata": {},
"outputs": [],
Expand All @@ -216,7 +225,7 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": 8,
"id": "27b31984-ac8e-473f-ba2d-eb309c9708c1",
"metadata": {},
"outputs": [
Expand All @@ -226,14 +235,14 @@
"{'tilejson': '2.2.0',\n",
" 'version': '1.0.0',\n",
" 'scheme': 'xyz',\n",
" 'tiles': ['https://dev.ghg.center/api/raster/collections/gra2pes-co2-monthgrid-v1/items/gra2pes-co2-monthgrid-v1-202101/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?collection=gra2pes-co2-monthgrid-v1&item=gra2pes-co2-monthgrid-v1-202101&assets=co2&color_formula=gamma+r+1.05&colormap_name=spectral_r&rescale=0%2C150'],\n",
" 'tiles': ['https://earth.gov/ghgcenter/api/raster/collections/gra2pes-ghg-monthgrid-v1/items/gra2pes-ghg-monthgrid-v1-202101/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?assets=co2&color_formula=gamma+r+1.05&colormap_name=spectral_r&rescale=0%2C150'],\n",
" 'minzoom': 0,\n",
" 'maxzoom': 24,\n",
" 'bounds': [-137.3143, 18.173376, -58.58229999999702, 52.229376000001295],\n",
" 'center': [-97.94829999999851, 35.20137600000065, 0]}"
]
},
"execution_count": 30,
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -245,8 +254,7 @@
"# To change the year and month of the observed parameter, you can modify the \"items['YYYY-MM']\" statement\n",
"# For example, you can change the current statement \"items['2003-12']\" to \"items['2016-10']\" \n",
"_202101_tile = requests.get(\n",
" f\"{RASTER_API_URL}/collections/{items['2021-01']['collection']}/items/{items['2021-01']['id']}/tilejson.json?collection={items['2021-01']['collection']}&item={items['2021-01']['id']}\"\n",
"\n",
" f\"{RASTER_API_URL}/collections/{items['2021-01']['collection']}/items/{items['2021-01']['id']}/tilejson.json?\"\n",
" f\"&assets={asset_name}\"\n",
" f\"&color_formula=gamma+r+1.05&colormap_name={color_map}\"\n",
" f\"&rescale=0,150\", \n",
Expand All @@ -256,7 +264,7 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 9,
"id": "80f5933d",
"metadata": {},
"outputs": [
Expand All @@ -266,22 +274,21 @@
"{'tilejson': '2.2.0',\n",
" 'version': '1.0.0',\n",
" 'scheme': 'xyz',\n",
" 'tiles': ['https://dev.ghg.center/api/raster/collections/gra2pes-co2-monthgrid-v1/items/gra2pes-co2-monthgrid-v1-202105/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?collection=gra2pes-co2-monthgrid-v1&item=gra2pes-co2-monthgrid-v1-202105&assets=co2&color_formula=gamma+r+1.05&colormap_name=spectral_r&rescale=0%2C150'],\n",
" 'tiles': ['https://earth.gov/ghgcenter/api/raster/collections/gra2pes-ghg-monthgrid-v1/items/gra2pes-ghg-monthgrid-v1-202105/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?assets=co2&color_formula=gamma+r+1.05&colormap_name=spectral_r&rescale=0%2C150'],\n",
" 'minzoom': 0,\n",
" 'maxzoom': 24,\n",
" 'bounds': [-137.3143, 18.173376, -58.58229999999702, 52.229376000001295],\n",
" 'center': [-97.94829999999851, 35.20137600000065, 0]}"
]
},
"execution_count": 31,
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"_202105_tile = requests.get(\n",
" f\"{RASTER_API_URL}/collections/{items['2021-05']['collection']}/items/{items['2021-05']['id']}/tilejson.json?collection={items['2021-05']['collection']}&item={items['2021-05']['id']}\"\n",
"\n",
" f\"{RASTER_API_URL}/collections/{items['2021-05']['collection']}/items/{items['2021-05']['id']}/tilejson.json?\"\n",
" f\"&assets={asset_name}\"\n",
" f\"&color_formula=gamma+r+1.05&colormap_name={color_map}\"\n",
" f\"&rescale=0,150\", \n",
Expand All @@ -299,7 +306,7 @@
},
{
"cell_type": "code",
"execution_count": 32,
"execution_count": 10,
"id": "6cf3c0f1-8d39-4cdd-96c7-96e6229c1584",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -333,7 +340,7 @@
" <meta name="viewport" content="width=device-width,\n",
" initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />\n",
" <style>\n",
" #map_edd0ff00f280162cb37a88438dfad200 {\n",
" #map_c94eb2f13aea2887cac7c51b8a32f842 {\n",
" position: absolute;\n",
" width: 50.0%;\n",
" height: 100.0%;\n",
Expand All @@ -347,7 +354,7 @@
" <meta name="viewport" content="width=device-width,\n",
" initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />\n",
" <style>\n",
" #map_ddd6319ec882adf311b2309c43b9d2d5 {\n",
" #map_376345819bea8f69b487f97f7713ee12 {\n",
" position: absolute;\n",
" width: 50.0%;\n",
" height: 100.0%;\n",
Expand All @@ -362,17 +369,17 @@
"<body>\n",
" \n",
" \n",
" <div class="folium-map" id="map_edd0ff00f280162cb37a88438dfad200" ></div>\n",
" <div class="folium-map" id="map_c94eb2f13aea2887cac7c51b8a32f842" ></div>\n",
" \n",
" \n",
" <div class="folium-map" id="map_ddd6319ec882adf311b2309c43b9d2d5" ></div>\n",
" <div class="folium-map" id="map_376345819bea8f69b487f97f7713ee12" ></div>\n",
" \n",
"</body>\n",
"<script>\n",
" \n",
" \n",
" var map_edd0ff00f280162cb37a88438dfad200 = L.map(\n",
" "map_edd0ff00f280162cb37a88438dfad200",\n",
" var map_c94eb2f13aea2887cac7c51b8a32f842 = L.map(\n",
" "map_c94eb2f13aea2887cac7c51b8a32f842",\n",
" {\n",
" center: [34.0, -118.0],\n",
" crs: L.CRS.EPSG3857,\n",
Expand All @@ -386,26 +393,26 @@
"\n",
" \n",
" \n",
" var tile_layer_83789f115bdff9a1c771b85325da703c = L.tileLayer(\n",
" var tile_layer_2bdef7a16107516d1d61f49db46d3801 = L.tileLayer(\n",
" "https://tile.openstreetmap.org/{z}/{x}/{y}.png",\n",
" {"attribution": "\\u0026copy; \\u003ca href=\\"https://www.openstreetmap.org/copyright\\"\\u003eOpenStreetMap\\u003c/a\\u003e contributors", "detectRetina": false, "maxNativeZoom": 19, "maxZoom": 19, "minZoom": 0, "noWrap": false, "opacity": 1, "subdomains": "abc", "tms": false}\n",
" );\n",
" \n",
" \n",
" tile_layer_83789f115bdff9a1c771b85325da703c.addTo(map_edd0ff00f280162cb37a88438dfad200);\n",
" tile_layer_2bdef7a16107516d1d61f49db46d3801.addTo(map_c94eb2f13aea2887cac7c51b8a32f842);\n",
" \n",
" \n",
" var tile_layer_d8c169ddc474a63922e903ed89d2e517 = L.tileLayer(\n",
" "https://dev.ghg.center/api/raster/collections/gra2pes-co2-monthgrid-v1/items/gra2pes-co2-monthgrid-v1-202101/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?collection=gra2pes-co2-monthgrid-v1\\u0026item=gra2pes-co2-monthgrid-v1-202101\\u0026assets=co2\\u0026color_formula=gamma+r+1.05\\u0026colormap_name=spectral_r\\u0026rescale=0%2C150",\n",
" var tile_layer_148570fa458d9cc7e824e1e5f1d985af = L.tileLayer(\n",
" "https://earth.gov/ghgcenter/api/raster/collections/gra2pes-ghg-monthgrid-v1/items/gra2pes-ghg-monthgrid-v1-202101/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?assets=co2\\u0026color_formula=gamma+r+1.05\\u0026colormap_name=spectral_r\\u0026rescale=0%2C150",\n",
" {"attribution": "GHG", "detectRetina": false, "maxZoom": 18, "minZoom": 0, "noWrap": false, "opacity": 0.8, "subdomains": "abc", "tms": false}\n",
" );\n",
" \n",
" \n",
" tile_layer_d8c169ddc474a63922e903ed89d2e517.addTo(map_edd0ff00f280162cb37a88438dfad200);\n",
" tile_layer_148570fa458d9cc7e824e1e5f1d985af.addTo(map_c94eb2f13aea2887cac7c51b8a32f842);\n",
" \n",
" \n",
" var map_ddd6319ec882adf311b2309c43b9d2d5 = L.map(\n",
" "map_ddd6319ec882adf311b2309c43b9d2d5",\n",
" var map_376345819bea8f69b487f97f7713ee12 = L.map(\n",
" "map_376345819bea8f69b487f97f7713ee12",\n",
" {\n",
" center: [34.0, -118.0],\n",
" crs: L.CRS.EPSG3857,\n",
Expand All @@ -419,35 +426,35 @@
"\n",
" \n",
" \n",
" var tile_layer_1e14ca0dd8c2166f0d902100d5d29e6a = L.tileLayer(\n",
" var tile_layer_c0d1b6c8928c57c2e7df1ed3718f3bab = L.tileLayer(\n",
" "https://tile.openstreetmap.org/{z}/{x}/{y}.png",\n",
" {"attribution": "\\u0026copy; \\u003ca href=\\"https://www.openstreetmap.org/copyright\\"\\u003eOpenStreetMap\\u003c/a\\u003e contributors", "detectRetina": false, "maxNativeZoom": 19, "maxZoom": 19, "minZoom": 0, "noWrap": false, "opacity": 1, "subdomains": "abc", "tms": false}\n",
" );\n",
" \n",
" \n",
" tile_layer_1e14ca0dd8c2166f0d902100d5d29e6a.addTo(map_ddd6319ec882adf311b2309c43b9d2d5);\n",
" tile_layer_c0d1b6c8928c57c2e7df1ed3718f3bab.addTo(map_376345819bea8f69b487f97f7713ee12);\n",
" \n",
" \n",
" var tile_layer_2793f20a58a552418ec77f4c8722f5ef = L.tileLayer(\n",
" "https://dev.ghg.center/api/raster/collections/gra2pes-co2-monthgrid-v1/items/gra2pes-co2-monthgrid-v1-202105/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?collection=gra2pes-co2-monthgrid-v1\\u0026item=gra2pes-co2-monthgrid-v1-202105\\u0026assets=co2\\u0026color_formula=gamma+r+1.05\\u0026colormap_name=spectral_r\\u0026rescale=0%2C150",\n",
" var tile_layer_1830c9e673ed70c6a6e2d7c0b8891aad = L.tileLayer(\n",
" "https://earth.gov/ghgcenter/api/raster/collections/gra2pes-ghg-monthgrid-v1/items/gra2pes-ghg-monthgrid-v1-202105/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?assets=co2\\u0026color_formula=gamma+r+1.05\\u0026colormap_name=spectral_r\\u0026rescale=0%2C150",\n",
" {"attribution": "GHG", "detectRetina": false, "maxZoom": 18, "minZoom": 0, "noWrap": false, "opacity": 0.8, "subdomains": "abc", "tms": false}\n",
" );\n",
" \n",
" \n",
" tile_layer_2793f20a58a552418ec77f4c8722f5ef.addTo(map_ddd6319ec882adf311b2309c43b9d2d5);\n",
" tile_layer_1830c9e673ed70c6a6e2d7c0b8891aad.addTo(map_376345819bea8f69b487f97f7713ee12);\n",
" \n",
" \n",
" map_edd0ff00f280162cb37a88438dfad200.sync(map_ddd6319ec882adf311b2309c43b9d2d5);\n",
" map_ddd6319ec882adf311b2309c43b9d2d5.sync(map_edd0ff00f280162cb37a88438dfad200);\n",
" map_c94eb2f13aea2887cac7c51b8a32f842.sync(map_376345819bea8f69b487f97f7713ee12);\n",
" map_376345819bea8f69b487f97f7713ee12.sync(map_c94eb2f13aea2887cac7c51b8a32f842);\n",
" \n",
"</script>\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.plugins.dual_map.DualMap at 0x10bd6ec00>"
"<folium.plugins.dual_map.DualMap at 0x104db5580>"
]
},
"execution_count": 32,
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -475,7 +482,7 @@
" opacity=0.8, # Adjust the transparency of the layer\n",
")\n",
"# Add the first layer to the Dual Map \n",
"map_layer_2021.add_to(map_.m2)\n",
"map_layer_202105.add_to(map_.m2)\n",
"\n",
"map_"
]
Expand Down Expand Up @@ -523,7 +530,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.3"
"version": "3.9.6"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 1e0e4dd

Please sign in to comment.