Skip to content

Commit

Permalink
Merge pull request #46 from digitalearthafrica/session4-quiz
Browse files Browse the repository at this point in the history
Week 4 solutions and quiz
  • Loading branch information
caitlinadams committed Sep 22, 2020
2 parents 36d5571 + a764121 commit ac7c1df
Show file tree
Hide file tree
Showing 16 changed files with 3,157 additions and 22 deletions.
1,395 changes: 1,395 additions & 0 deletions docs/_static/session_4/Calculate_NDVI_Part_1_solution-annotated.ipynb

Large diffs are not rendered by default.

1,632 changes: 1,632 additions & 0 deletions docs/_static/session_4/Calculate_NDVI_Part_2_solution-annotated.ipynb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Sessions 5 -- 6 will be added shortly.
Latest Updates
-------------------

- **22/09/2020:** The `Session 4 quiz <./session_3/04_s4_solution.ipynb>`_ is live.
- **17/09/2020:** `Session 4: Indices <./session_4/index.rst>`_ has been added.
- **15/09/2020:** The `Session 3 quiz <./session_3/04_s3_solution.ipynb>`_ is live. Video slides are now available to download under each video.
- **10/09/2020:** `Session 3: Composites <./session_3/index.rst>`_ has been added.
Expand Down
14 changes: 7 additions & 7 deletions docs/session_4/02_calculate_ndvi_part_1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"source": [
"## Running the notebook\n",
"\n",
"This notebook is still set up to run the session 3 exercise, so you'll need to follow the instructions below to modify it. Work cell by cell and pay attention to what needs to be changed.\n",
"This notebook is still set up to run the Session 3 exercise, so you'll need to follow the instructions below to modify it. Work cell by cell and pay attention to what needs to be changed.\n",
"\n",
"### Set up\n",
"\n",
Expand Down Expand Up @@ -106,7 +106,7 @@
"```\n",
"This will plot images for the 1st, 6th and 8th timestep of the loaded data (remember that Python starts counting at 0). Your image should match the one below. \n",
"\n",
"<img align=\"middle\" src=\"images/1.PNG\" alt=\"The DE Africa Sandbox Jupyterlab tutorial image.\" width=\"100%\">"
"<img align=\"middle\" src=\"images/1-10x10.PNG\" alt=\"The DE Africa Sandbox Jupyterlab tutorial image.\" width=\"100%\">"
]
},
{
Expand Down Expand Up @@ -139,7 +139,7 @@
"source": [
"Follow the steps below to resample the dataset time steps to quarterly.\n",
"\n",
"1. Delete the code for plotting all rgb images:\n",
"1. Delete the code for plotting all RGB images:\n",
"\n",
" ```\n",
" rgb(sentinel_2_ds, bands=['red', 'green', 'blue'], \n",
Expand Down Expand Up @@ -190,7 +190,7 @@
"rgb(geomedian_resample, bands=['red', 'green', 'blue'], col=\"time\", col_wrap=4)\n",
"```\n",
"\n",
"<img align=\"middle\" src=\"images/2.PNG\" alt=\"The DE Africa Sandbox Jupyterlab tutorial image.\" width=\"100%\">"
"<img align=\"middle\" src=\"images/2-10x10.PNG\" alt=\"The DE Africa Sandbox Jupyterlab tutorial image.\" width=\"100%\">"
]
},
{
Expand All @@ -203,7 +203,7 @@
"\n",
"`sentinel_2_ds`\n",
"\n",
"<img align=\"middle\" src=\"images/3.PNG\" alt=\"The DE Africa Sandbox Jupyterlab tutorial image.\" width=\"800\">"
"<img align=\"middle\" src=\"images/3-nonir.PNG\" alt=\"The DE Africa Sandbox Jupyterlab tutorial image.\" width=\"800\">"
]
},
{
Expand All @@ -212,14 +212,14 @@
"source": [
"`geomedian_resample`\n",
"\n",
"<img align=\"middle\" src=\"images/4.PNG\" alt=\"The DE Africa Sandbox Jupyterlab tutorial image.\" width=\"800\">"
"<img align=\"middle\" src=\"images/4-nonir.PNG\" alt=\"The DE Africa Sandbox Jupyterlab tutorial image.\" width=\"800\">"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Looking at the dimensions the raw dataset(`sentinel_2_ds`) has 71 time steps loaded but after resampling(`geomedian_resample`) to quaterly the time dimension is now 4."
"Take a look at the dimensions. The raw dataset `sentinel_2_ds` has 71 time steps loaded, but after resampling to quarterly as in `geomedian_resample`, the time dimension is now 4. This makes sense because the year has been divided into four quarters."
]
},
{
Expand Down
33 changes: 18 additions & 15 deletions docs/session_4/03_calculate_ndvi_part_2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"source": [
"# Calculating NDVI: Part 2\n",
"\n",
"This exercise follows on from the previous section. In the [final exercise of the previous session](../session_4/03_calculate_ndvi_part_2.ipynb), you constructed a notebook to resample the sentinel dataset to quaterly time steps.\n",
"This exercise follows on from the previous section. In the [previous part of this exercise](../session_4/03_calculate_ndvi_part_2.ipynb), you constructed a notebook to resample a year's worth of Sentinel-2 data into quarterly time steps.\n",
"\n",
"In this section, you will conitnue from where you ended in the previous session. Most of the code will remain unchanged, but we will introduce a add a new measurement to the existing measurements which will enable us to calculate and plot NDVI."
"In this section, you will conitnue from where you ended in the previous exercise. Most of the code will remain unchanged, but we will introduce a new measurement to the existing measurements which will enable us to calculate and plot NDVI."
]
},
{
Expand Down Expand Up @@ -39,22 +39,22 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Making changes to the load Cell\n",
"## Making changes to the load cell\n",
"Make the following changes below to modify the load cell.\n",
"\n",
"\n",
"### Adding `nir` measurement\n",
"\n",
"To calculate NDVI, we need to load Sentinel-2's near-infrared band (`nir` in the Sandbox).\n",
"To add the band, modify the load cell according to the step below:\n",
"To calculate NDVI, we need to load Sentinel-2's near-infrared band. In the Sandbox, it is called `nir`.\n",
"To add the band, modify the `load_ard` cell according to the step below:\n",
"\n",
"1. Add `nir` to the measurements array.\n",
"\n",
" ```\n",
" measurements = ['red', 'green', 'blue', 'nir']\n",
" ```\n",
"\n",
"If you completed the above step 1, your load cell should look like:\n",
"If you completed the above step, your `load_ard` cell should look like:\n",
"\n",
" sentinel_2_ds = load_ard(\n",
" dc=dc,\n",
Expand Down Expand Up @@ -87,27 +87,30 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Creating a new Cell\n",
"### Creating a new cell\n",
"\n",
"After successfully running the notebook, this cell will be the last cell\n",
"After successfully running the notebook, this cell will be the last cell:\n",
"\n",
"`geomedian_resample`\n",
"\n",
"<img align=\"middle\" src=\"images/4.PNG\" alt=\"The DE Africa Sandbox Jupyterlab tutorial image.\" width=\"100%\">\n",
"<img align=\"middle\" src=\"images/4-nir.PNG\" alt=\"The geomedian_resample dataset with NIR band.\" width=\"100%\">\n",
"\n",
"Follow the steps below to create a new cell\n",
"Notice it now contains the NIR band data, which is the data we just loaded. \n",
"\n",
"Follow the steps below to create a new cell.\n",
"\n",
"1. Make sure the last cell is selected.\n",
"2. Press the `Esc` key, then follow it by pressing the `B` key. A new cell will be created below the current cell.\n",
"\n",
"Use the method above to create a new cell"
"Use the method above to create a new cell."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Manually calculate an index\n",
"## Calculate NDVI\n",
"\n",
"One of the most commonly used remote sensing indices is the Normalised Difference Vegetation Index or `NDVI`. \n",
"This index uses the ratio of the red and near-infrared (NIR) bands to identify live green vegetation.\n",
"The formula for NDVI is:\n",
Expand All @@ -125,7 +128,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Calculate NDVI\n",
"### Define NDVI formula\n",
"\n",
"In a new cell, calculate the NDVI for the resampled geomedian dataset. To make it simpler, you can store the red and near-infrared bands in new variables, then calculate the NDVI using those variables, as shown below:\n",
"\n",
Expand All @@ -135,7 +138,7 @@
" \n",
" NDVI = (nir - red) / (nir + red)\n",
"```\n",
"Run the cell using `Shift + Enter`\n",
"Run the cell using `Shift + Enter`.\n",
"\n",
"### Plot NDVI for each geomedian\n",
"\n",
Expand Down Expand Up @@ -227,7 +230,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
"version": "3.6.9"
}
},
"nbformat": 4,
Expand Down
103 changes: 103 additions & 0 deletions docs/session_4/04_s4_solution.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Session 4 Quiz and Solution"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In Session 4, you created a notebook to load satellite products, resample the data into quarterly segments, and then calculate and plot the Normalised Difference Vegetation Index (NDVI). Combining bands into indices such as NDVI can yield important insights into the data which might not be apparent using true-color RGB imagery alone."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Quiz"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If you would like to be awarded a certificate of achievement at the end of the course, we ask that you [complete the quiz](https://docs.google.com/forms/d/e/1FAIpQLSffGiKtV5lgBBYrgBwplYUlDhsZ05td6CRAufJ05MeAkNRWMw/viewform?usp=sf_link). You will need to supply your email address to progress towards the certificate. After you complete the quiz, you can check if your answers were correct by pressing the **View Accuracy** button.\n",
"\n",
"The quiz will ask you to use the notebook you developed for this session's exercise on calculating NDVI. If you would like to confirm that your notebook works as expected, you can check it against the solution notebook provided below. "
]
},
{
"cell_type": "raw",
"metadata": {
"raw_mimetype": "text/restructuredtext"
},
"source": [
".. note::\n",
" The solution notebooks below do not contain the answer to the quiz. Use them to check that you implemented the exercises correctly, then use your exercise notebook to answer the quiz. Accessing the solution notebook will not affect your progression towards the certificate."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Solution notebook"
]
},
{
"cell_type": "raw",
"metadata": {
"raw_mimetype": "text/restructuredtext"
},
"source": [
".. note::\n",
" We strongly encourage you to attempt the exercise on the previous page before downloading the solution below. This will help you learn how to use the Sandbox independently for your own analyses."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[Download the solution notebook for the Session 4 Part 1 exercise](../_static/session_4/Calculate_NDVI_Part_1_solution-annotated.ipynb)\n",
"\n",
"[Download the solution notebook for the Session 4 Part 2 exercise](../_static/session_4/Calculate_NDVI_Part_2_solution-annotated.ipynb)\n",
"\n",
"To view a solution notebook on the Sandbox, you will need to first download \n",
"it to your computer, then upload it to the Sandbox. Follow these instructions:\n",
"\n",
"1. Download the notebook by clicking the link above.\n",
"2. On the Sandbox, open the **Training** folder.\n",
"3. Click the **Upload Files** button as shown below.\n",
"\n",
"<img align=\"middle\" src=\"../_static/session_2/05_solution_uploadbutton.png\" alt=\"Upload button.\" width=400>\n",
"\n",
"4. Select the downloaded notebook using the file browser. Click **OK**.\n",
"5. The solution notebook will appear in the **Training** folder. Double-click to open it."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.9"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Binary file added docs/session_4/images/1-10x10.PNG
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/session_4/images/1.PNG
Binary file not shown.
Binary file added docs/session_4/images/2-10x10.PNG
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/session_4/images/2.PNG
Binary file not shown.
Binary file added docs/session_4/images/3-nonir.PNG
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/session_4/images/3.PNG
Binary file not shown.
Binary file added docs/session_4/images/4-nir.PNG
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/session_4/images/4-nonir.PNG
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/session_4/images/4.PNG
Binary file not shown.
1 change: 1 addition & 0 deletions docs/session_4/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ First, we will introduce several band indices and what they measure. Then we wil
01_band_indices
02_calculate_ndvi_part_1
03_calculate_ndvi_part_2
04_s4_solution

0 comments on commit ac7c1df

Please sign in to comment.