Skip to content

Commit 2600caa

Browse files
committed
Added links to TomTom notebooks, run the pre-commit hooks and fixed some typos.
1 parent 3f2bae0 commit 2600caa

File tree

3 files changed

+72
-50
lines changed

3 files changed

+72
-50
lines changed

GEM-data/gem-datasets.ipynb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
" * Results of LightGBM categorical built-up model\n",
2222
" * Results of several TFCN regression and classification built-up models\n",
2323
"\n",
24-
"- [Map making use-case](GEM-map-making-usecase.ipynb)\n",
24+
"- [Map making use-case](gem-map-making-usecase.ipynb)\n",
25+
"\n",
26+
"- [LC-CMS use-case](gem-lc-cms-usecase.ipynb)\n",
2527
"\n",
2628
"- [Continuous monitoring service](gem-NDWI-anomalies.ipynb)\n",
2729
"\n",

GEM-data/gem-lc-cms-usecase.ipynb

Lines changed: 50 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"source": [
1515
"This notebook contains information about accessing the data for LC-CMS use case.\n",
1616
"\n",
17-
"The tutorial focusses on the accessing and visualizing the prediction results derived from the LC-CMS use case.\n",
17+
"The tutorial focuses on the accessing and visualizing the prediction results derived from the LC-CMS use case.\n",
1818
"The results are also available on the Map Viewer which can be accessed using this **[link](https://www.globalearthmonitor.eu/sites/default/files/LC_CMS/index.html)**.\n",
1919
"\n",
2020
"The predictions are stored in _[BYOC SentinelHub layers](https://docs.sentinel-hub.com/api/latest/data/byoc/)_. \n",
@@ -58,14 +58,14 @@
5858
"cell_type": "markdown",
5959
"metadata": {},
6060
"source": [
61-
"# Predicitons over pilot Africa AOI\n",
61+
"# Predictions over pilot Africa AOI\n",
6262
"Following code snippets show how to access and visualize the predictions generated using LC-CMS pipeline. </br>\n",
6363
"</br>\n",
6464
"The predictions were generated using following input data and modelling technique : </br>\n",
6565
"\n",
6666
"**Input Data**\n",
6767
"- Sentinel-2 L2A : Bands B1 to B12\n",
68-
"- 120m with bilinear resampling\n",
68+
"- 120m with bi-linear resampling\n",
6969
"- Sub-regions (AOIs) with different biomes and geographies \n",
7070
"- Yearly data aggregated every two months\n",
7171
"- Predictions generated yearly\n",
@@ -74,7 +74,7 @@
7474
"- Pixel Based Classification using Random Forest Classifier\n",
7575
"- 9 Classes\n",
7676
"\n",
77-
"Additionaly, LC-Classes are represented by following values in the prediction array: \n",
77+
"Additionally, LC-Classes are represented by following values in the prediction array: \n",
7878
"\n",
7979
"| **Land Cover Class** | **Value** |\n",
8080
"| -------------------- | --------- |\n",
@@ -138,7 +138,7 @@
138138
],
139139
"source": [
140140
"nigeria_bbox = BBox((643000.0, 1105000.0, 715000.0, 1175000.0), CRS.UTM_31N)\n",
141-
"eopatch = predictions_download_task.execute(bbox=nigeria_bbox) #, time_interval=[\"2019-01-01\", \"2023-01-01\"]"
141+
"eopatch = predictions_download_task.execute(bbox=nigeria_bbox) # , time_interval=[\"2019-01-01\", \"2023-01-01\"]"
142142
]
143143
},
144144
{
@@ -162,11 +162,22 @@
162162
" \"\"\"\n",
163163
" Function to transform the predictions to RGB for visualization\n",
164164
" \"\"\"\n",
165-
" ids_to_rgb = {0: [0, 0, 0], 1: [23, 91, 55], 3: [178, 223, 186], 4: [72, 234, 37], 6: [243, 245, 234], 7: [254, 247, 180], 8: [245, 42, 5], 9: [50, 74, 221], 10: [140, 203, 255], 11: [111, 124, 128]}\n",
166-
" resulr_arr = np.zeros((preds.shape[0], preds.shape[1], 3), dtype=np.uint8)\n",
167-
" for id, mapping in ids_to_rgb.items():\n",
168-
" resulr_arr[np.where(preds == id)] = np.array(mapping)\n",
169-
" return resulr_arr"
165+
" ids_to_rgb = {\n",
166+
" 0: [0, 0, 0],\n",
167+
" 1: [23, 91, 55],\n",
168+
" 3: [178, 223, 186],\n",
169+
" 4: [72, 234, 37],\n",
170+
" 6: [243, 245, 234],\n",
171+
" 7: [254, 247, 180],\n",
172+
" 8: [245, 42, 5],\n",
173+
" 9: [50, 74, 221],\n",
174+
" 10: [140, 203, 255],\n",
175+
" 11: [111, 124, 128],\n",
176+
" }\n",
177+
" result_arr = np.zeros((preds.shape[0], preds.shape[1], 3), dtype=np.uint8)\n",
178+
" for idx, mapping in ids_to_rgb.items():\n",
179+
" result_arr[np.where(preds == idx)] = np.array(mapping)\n",
180+
" return result_arr"
170181
]
171182
},
172183
{
@@ -196,7 +207,7 @@
196207
}
197208
],
198209
"source": [
199-
"# Generate a plot for each year \n",
210+
"# Generate a plot for each year\n",
200211
"# we visualize the predictions using transform_to_rgb function\n",
201212
"preds_data = eopatch.data[\"lcms_pred\"].astype(int).squeeze(axis=0)\n",
202213
"y2019_preds = preds_data[:, :, 0]\n",
@@ -206,11 +217,11 @@
206217
"fig, axes = plt.subplots(1, 3, figsize=(30, 10))\n",
207218
"ax1, ax2, ax3 = axes\n",
208219
"ax1.set_title(\"For year 2019\", fontweight=\"bold\")\n",
209-
"ax1.imshow(transform_to_rgb(y2019_preds),interpolation=\"nearest\")\n",
220+
"ax1.imshow(transform_to_rgb(y2019_preds), interpolation=\"nearest\")\n",
210221
"ax2.set_title(\"For year 2020\", fontweight=\"bold\")\n",
211-
"ax2.imshow(transform_to_rgb(y2020_preds),interpolation=\"nearest\")\n",
222+
"ax2.imshow(transform_to_rgb(y2020_preds), interpolation=\"nearest\")\n",
212223
"ax3.set_title(\"For year 2021\", fontweight=\"bold\")\n",
213-
"ax3.imshow(transform_to_rgb(y2021_preds),interpolation=\"nearest\")\n",
224+
"ax3.imshow(transform_to_rgb(y2021_preds), interpolation=\"nearest\")\n",
214225
"plt.suptitle(\"LCMS Predictions for Kainji Lake, Nigeria in the pilot AOI Africa\", y=0.9, fontweight=\"bold\", fontsize=15)"
215226
]
216227
},
@@ -232,7 +243,7 @@
232243
"# Similarly, we can visualize the data mask\n",
233244
"def get_pred_diff(preds_from, preds_to):\n",
234245
" \"\"\"\n",
235-
" This function generates the diff between the the LC-CMS predictions taken over two different time periods.\n",
246+
" This function generates the diff between the LC-CMS predictions taken over two different time periods.\n",
236247
" \"\"\"\n",
237248
" return np.where(preds_from != preds_to, preds_to, 0)"
238249
]
@@ -277,13 +288,21 @@
277288
"fig, axes = plt.subplots(1, 3, figsize=(30, 10))\n",
278289
"ax1, ax2, ax3 = axes\n",
279290
"ax1.set_title(\"Between 2019 to 2020\", fontweight=\"bold\")\n",
280-
"ax1.imshow(transform_to_rgb(diff_2019_2020),interpolation=\"nearest\")\n",
291+
"ax1.imshow(transform_to_rgb(diff_2019_2020), interpolation=\"nearest\")\n",
281292
"ax2.set_title(\"Between 2020 to 2021\", fontweight=\"bold\")\n",
282-
"ax2.imshow(transform_to_rgb(diff_2020_2021),interpolation=\"nearest\")\n",
293+
"ax2.imshow(transform_to_rgb(diff_2020_2021), interpolation=\"nearest\")\n",
283294
"ax3.set_title(\"Between 2019 to 2021\", fontweight=\"bold\")\n",
284-
"ax3.imshow(transform_to_rgb(diff_2019_2021),interpolation=\"nearest\")\n",
285-
"# plt.suptitle('LC-CMS Predictions for Nigeration in the pilot AOI Africa for years 2019, 2020, 2021')\n",
286-
"plt.suptitle(\"LCMS Predictions Delta (1 and 2-year change) for the Kainji Lake, Nigeria from 2019 to 2021 with various combinations\", y=0.9, fontweight=\"bold\", fontsize=15)"
295+
"ax3.imshow(transform_to_rgb(diff_2019_2021), interpolation=\"nearest\")\n",
296+
"\n",
297+
"plt.suptitle(\n",
298+
" (\n",
299+
" \"LCMS Predictions Delta (1 and 2-year change) for the Kainji Lake, Nigeria from 2019 to 2021 with various\"\n",
300+
" \" combinations\"\n",
301+
" ),\n",
302+
" y=0.9,\n",
303+
" fontweight=\"bold\",\n",
304+
" fontsize=15,\n",
305+
")"
287306
]
288307
},
289308
{
@@ -302,12 +321,12 @@
302321
"source": [
303322
"# Predictions over experiment AOI of France\n",
304323
"In the following code snippets, we will see how we can access the data for the France AOI. </br>\n",
305-
"France AOI was primariliy used for experimentation and model tuning. </br>\n",
324+
"France AOI was primarily used for experimentation and model tuning. </br>\n",
306325
"\n",
307326
"The final predictions that we will see were generated using following input data and modelling technique : </br>\n",
308327
"**Input Data**\n",
309328
"- Sentinel-2 L2A : Bands B1 to B12\n",
310-
"- 120m with bilinear resampling\n",
329+
"- 120m with bi-linear resampling\n",
311330
"- Sub-regions (AOIs) with different biomes and geographies \n",
312331
"- Yearly data aggregated every two months\n",
313332
"- Predictions generated yearly\n",
@@ -365,7 +384,7 @@
365384
" max_threads=3,\n",
366385
")\n",
367386
"\n",
368-
"eopatch_paris = predictions_download_task.execute(bbox=paris_bbox) #, time_interval=[\"2019-01-01\", \"2023-01-01\"]\n",
387+
"eopatch_paris = predictions_download_task.execute(bbox=paris_bbox) # , time_interval=[\"2019-01-01\", \"2023-01-01\"]\n",
369388
"paris_120m = eopatch_paris.data[\"lcms_pred\"].astype(int).squeeze(axis=0)"
370389
]
371390
},
@@ -404,7 +423,7 @@
404423
" max_threads=3,\n",
405424
")\n",
406425
"\n",
407-
"eopatch_paris = predictions_download_task.execute(bbox=paris_bbox) #, time_interval=[\"2019-01-01\", \"2023-01-01\"]\n",
426+
"eopatch_paris = predictions_download_task.execute(bbox=paris_bbox) # , time_interval=[\"2019-01-01\", \"2023-01-01\"]\n",
408427
"paris_60m = eopatch_paris.data[\"lcms_pred\"].astype(int).squeeze(axis=0)"
409428
]
410429
},
@@ -443,7 +462,7 @@
443462
" max_threads=3,\n",
444463
")\n",
445464
"\n",
446-
"eopatch_paris = predictions_download_task.execute(bbox=paris_bbox) #, time_interval=[\"2019-01-01\", \"2023-01-01\"]\n",
465+
"eopatch_paris = predictions_download_task.execute(bbox=paris_bbox) # , time_interval=[\"2019-01-01\", \"2023-01-01\"]\n",
447466
"paris_20m = eopatch_paris.data[\"lcms_pred\"].astype(int).squeeze(axis=0)"
448467
]
449468
},
@@ -486,12 +505,14 @@
486505
"fig, axes = plt.subplots(1, 3, figsize=(30, 10))\n",
487506
"ax1, ax2, ax3 = axes\n",
488507
"ax1.set_title(\"120m resolution\", fontweight=\"bold\")\n",
489-
"ax1.imshow(transform_to_rgb(paris_120m.squeeze(-1)),interpolation=\"nearest\")\n",
508+
"ax1.imshow(transform_to_rgb(paris_120m.squeeze(-1)), interpolation=\"nearest\")\n",
490509
"ax2.set_title(\"60m resolution\", fontweight=\"bold\")\n",
491-
"ax2.imshow(transform_to_rgb(paris_60m.squeeze(-1)),interpolation=\"nearest\")\n",
510+
"ax2.imshow(transform_to_rgb(paris_60m.squeeze(-1)), interpolation=\"nearest\")\n",
492511
"ax3.set_title(\"20m resolution\", fontweight=\"bold\")\n",
493-
"ax3.imshow(transform_to_rgb(paris_20m.squeeze(-1)),interpolation=\"nearest\")\n",
494-
"plt.suptitle(\"LCMS Predictions for Paris region in France AOI for different resolutions\", y=0.8, fontweight=\"bold\", fontsize=15)"
512+
"ax3.imshow(transform_to_rgb(paris_20m.squeeze(-1)), interpolation=\"nearest\")\n",
513+
"plt.suptitle(\n",
514+
" \"LCMS Predictions for Paris region in France AOI for different resolutions\", y=0.8, fontweight=\"bold\", fontsize=15\n",
515+
")"
495516
]
496517
}
497518
],

GEM-data/gem-map-making-usecase.ipynb

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
"metadata": {},
66
"source": [
77
"# Map Making use case - Data Access\n",
8-
"<!-- <img src=\"./figs/lccms_pipeline.png\" height=\"400\"/> -->\n",
98
"\n",
10-
"The tutorial focusses on the accessing and visualizing the prediction results derived from the **Map Making** use case. </br>\n",
9+
"The tutorial focuses on the accessing and visualizing the prediction results derived from the **Map Making** use case. </br>\n",
1110
"The results are also available on the Map Viewer which can be accessed using this **[link](https://www.globalearthmonitor.eu/sites/default/files/water/index.html)**.\n",
1211
"\n",
1312
"The predictions are stored in _[BYOC SentinelHub layers](https://docs.sentinel-hub.com/api/latest/data/byoc/)_. \n",
@@ -30,13 +29,13 @@
3029
"source": [
3130
"# imports\n",
3231
"%matplotlib inline\n",
32+
"import matplotlib\n",
3333
"import matplotlib.pyplot as plt\n",
3434
"import numpy as np\n",
3535
"\n",
3636
"from eolearn.core import FeatureType\n",
3737
"from eolearn.io import SentinelHubInputTask\n",
38-
"from sentinelhub import CRS, Band, BBox, DataCollection, Unit\n",
39-
"import matplotlib"
38+
"from sentinelhub import CRS, Band, BBox, DataCollection, Unit"
4039
]
4140
},
4241
{
@@ -115,7 +114,7 @@
115114
"source": [
116115
"# we choose a bounding box that covers a small area in Uruguay\n",
117116
"uruguay_bbox = BBox((452100.0, 6328700.0, 474000.0, 6350700.0), CRS.UTM_21S)\n",
118-
"eopatch = predictions_download_task.execute(bbox=uruguay_bbox) #, time_interval=[\"2019-01-01\", \"2023-01-01\"]"
117+
"eopatch = predictions_download_task.execute(bbox=uruguay_bbox) # , time_interval=[\"2019-01-01\", \"2023-01-01\"]"
119118
]
120119
},
121120
{
@@ -163,13 +162,13 @@
163162
}
164163
],
165164
"source": [
166-
"# Generate a plot for each year \n",
165+
"# Generate a plot for each year\n",
167166
"# we visualize the predictions using transform_to_rgb function\n",
168167
"preds_data = eopatch.data[\"pred\"].astype(int).squeeze()\n",
169168
"\n",
170169
"fig, ax1 = plt.subplots(figsize=(10, 10))\n",
171170
"ax1.set_title(\"Water Predictions for a lake in Uruguay AOI for year 2019\", fontweight=\"bold\")\n",
172-
"ax1.imshow(transform_to_rgb(preds_data),interpolation=\"nearest\")"
171+
"ax1.imshow(transform_to_rgb(preds_data), interpolation=\"nearest\")"
173172
]
174173
},
175174
{
@@ -195,9 +194,9 @@
195194
}
196195
],
197196
"source": [
198-
"# Probabilities are stored in a separate collection with bands named 'PW' and 'IW' \n",
197+
"# Probabilities are stored in a separate collection with bands named 'PW' and 'IW'\n",
199198
"bands = [\"PW\", \"IW\"]\n",
200-
"pred_collection_id = '6da384a4-1ea1-40a6-b855-0b4ad954671f'\n",
199+
"pred_collection_id = \"6da384a4-1ea1-40a6-b855-0b4ad954671f\"\n",
201200
"\n",
202201
"byoc_collection = DataCollection.define_byoc(\n",
203202
" pred_collection_id,\n",
@@ -230,10 +229,10 @@
230229
"fig, axes = plt.subplots(1, 2, figsize=(14, 7))\n",
231230
"ax1, ax2 = axes\n",
232231
"# get colormap for reds\n",
233-
"reds_cmap = matplotlib.cm.get_cmap('Reds')\n",
234-
"ax1.imshow(proba_data[:, :, 0],interpolation=\"nearest\", cmap=reds_cmap)\n",
232+
"reds_cmap = matplotlib.cm.get_cmap(\"Reds\")\n",
233+
"ax1.imshow(proba_data[:, :, 0], interpolation=\"nearest\", cmap=reds_cmap)\n",
235234
"ax1.set_title(\"Permanent Water probabilities\", fontweight=\"bold\")\n",
236-
"ax2.imshow(proba_data[:, :, 1],interpolation=\"nearest\", cmap=reds_cmap)\n",
235+
"ax2.imshow(proba_data[:, :, 1], interpolation=\"nearest\", cmap=reds_cmap)\n",
237236
"ax2.set_title(\"Intermittent Water probabilities\", fontweight=\"bold\")\n",
238237
"plt.suptitle(\"Water Predictions for a lake in Urugway AOI\", y=0.95, fontweight=\"bold\", fontsize=15)"
239238
]
@@ -243,8 +242,8 @@
243242
"metadata": {},
244243
"source": [
245244
"## Myanmar AOI experiments\n",
246-
"We also performed various experiments in Maynmar for fine tuning and evaluating the Classifier performance. </br>\n",
247-
"Following code snippets show how can we access and visualize the data.\n",
245+
"We also performed various experiments in Maynmar for fine-tuning and evaluating the Classifier performance. </br>\n",
246+
"Following code snippets show how the data can be accessed and visualized.\n",
248247
"\n",
249248
"### Gap Filling Model\n",
250249
"In addition to Tuning the model, we also experimented with a Gap Filling model, which can be used to fill gaps after classification using a CNN Image Segmentation model. </br>"
@@ -278,7 +277,7 @@
278277
"# The data for three years are stored as separate bands with following band names\n",
279278
"bands = [\"PRED\"]\n",
280279
"\n",
281-
"pred_collection_id = 'b31d5c95-ddb6-440f-b732-5827f5f64fb7'\n",
280+
"pred_collection_id = \"b31d5c95-ddb6-440f-b732-5827f5f64fb7\"\n",
282281
"byoc_collection = DataCollection.define_byoc(\n",
283282
" pred_collection_id,\n",
284283
" service_url=\"https://services.sentinel-hub.com\",\n",
@@ -314,7 +313,7 @@
314313
],
315314
"source": [
316315
"bands = [\"PRED\"]\n",
317-
"pred_collection_id = '742682e8-ab52-46b6-bfa8-6fc068cb60cf'\n",
316+
"pred_collection_id = \"742682e8-ab52-46b6-bfa8-6fc068cb60cf\"\n",
318317
"byoc_collection = DataCollection.define_byoc(\n",
319318
" pred_collection_id,\n",
320319
" service_url=\"https://services.sentinel-hub.com\",\n",
@@ -369,16 +368,16 @@
369368
}
370369
],
371370
"source": [
372-
"# Generate a plot for each year \n",
371+
"# Generate a plot for each year\n",
373372
"# we visualize the predictions using transform_to_rgb function\n",
374373
"preds_data = eopatch.data[\"pred\"].astype(int).squeeze()\n",
375374
"\n",
376375
"fig, axes = plt.subplots(1, 2, figsize=(14, 7))\n",
377-
"ax1, ax2= axes\n",
376+
"ax1, ax2 = axes\n",
378377
"ax1.set_title(\"With LGBM\", fontweight=\"bold\")\n",
379-
"ax1.imshow(transform_to_rgb(lgbm_pred),interpolation=\"nearest\")\n",
378+
"ax1.imshow(transform_to_rgb(lgbm_pred), interpolation=\"nearest\")\n",
380379
"ax2.set_title(\"With CNN Gap Filling model\", fontweight=\"bold\")\n",
381-
"ax2.imshow(transform_to_rgb(cnn_pred),interpolation=\"nearest\")\n",
380+
"ax2.imshow(transform_to_rgb(cnn_pred), interpolation=\"nearest\")\n",
382381
"plt.suptitle(\"Water Predictions for a lake in Myanmar AOI\", y=0.95, fontweight=\"bold\", fontsize=15)"
383382
]
384383
},

0 commit comments

Comments
 (0)