Skip to content

Commit

Permalink
gave chapters the tuw look
Browse files Browse the repository at this point in the history
  • Loading branch information
npikall committed Jul 24, 2024
1 parent b499105 commit f337254
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 37 deletions.
6 changes: 6 additions & 0 deletions _quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@ book:
- chapters/01_classification.qmd
- chapters/02_floodmapping.qmd
- chapters/references.qmd
navbar:
logo: https://www.tuwien.at/index.php?eID=dumpFile&t=f&f=180458&token=fe76daebeea536ee4be1650979e817f6fc0a2ea2
sidebar:
logo: https://www.tuwien.at/index.php?eID=dumpFile&t=f&f=180458&token=fe76daebeea536ee4be1650979e817f6fc0a2ea2

bibliography: chapters/references.bib

format:
html:
theme: cosmo
title-block-banner: "#006699"
title-block-banner-color: white
35 changes: 22 additions & 13 deletions chapters/01_classification.qmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Classification
author: Pikall Nikolas
subtitle: Finding forests with satelite imagery
jupyter:
kernelspec:
name: "01_classification"
Expand All @@ -11,8 +11,9 @@ format:
code-fold: show
eval: true
---
In this Notebook, we will use ``Scikit learn`` to classify an ``Sentinel-2`` Image. We will use two different classifiers and compare the results.
To get started we need to import the following modules.

## Data Acquisition
In this chapter, we will employ machine learning techniques to classify a scene using satellite imagery. Specifically, we will utilize ``scikit-learn`` to implement two distinct classifiers and subsequently compare their results. To begin, we need to import the following modules.

```{python}
from datetime import datetime, timedelta
Expand Down Expand Up @@ -45,11 +46,10 @@ from sklearn.model_selection import train_test_split
import matplotlib.colors as colors
```

## Data Acquisition
Before we start, we need to load the data. We will use ``odc-stac`` to get data from Earth Search by Element 84. Here we define the area of interest and the time frame, aswell as the EPSG code and the resolution.
Before we start, we need to load the data. We will use ``odc-stac`` to obtain data from Earth Search by Element 84. Here we define the area of interest and the time frame, aswell as the EPSG code and the resolution.

### Searching Catalog
The module ``odc-stac`` provides access to free, open source Sattelite data. To actually get to the data, we define some parameters, which specify where and when we want Satelite data from. Also we define what data collection we want to get the data from, since there are multiple to choose from. In this example we use _multispectral imagery_ from the Sentinel-2 Satelite.
The module ``odc-stac`` provides access to free, open source satelite data. To retrieve the data, we must define several parameters that specify the location and time period for the satellite data. Additionally, we must specify the data collection we wish to access, as multiple collections are available. In this example, we will use multispectral imagery from the Sentinel-2 satellite.

```{python}
dx = 0.0006 # 60m resolution
Expand Down Expand Up @@ -93,12 +93,13 @@ items = pystac_client.Client.open(
print(len(items), 'scenes found')
```

Here we will have a look at the area south-east of Vienna, where the Nationalpark _Donauauen_ is located. The time we are interested in is the beginning of may of 2024.
After passing these parameters to the `stac-catalog`
We have now found **10 scenes** that we can use for our analysis.
We will now focus on the area south-east of Vienna, where the Nationalpark _Donauauen_ is situated. The time frame we are interested in is the beginning of May 2024.
After passing these parameters to the `stac-catalog` we have found **10 scenes** that we can use for our analysis.

### Loading the Data
Now we will load the data directly into an ``xarray`` dataset, which we can use to perform computations on the data.
Now we will load the data directly into an ``xarray`` dataset, which we can use to perform computations on the data. ``xarray`` is a powerful library for working with multi-dimensional arrays, making it well-suited for handling satellite data.

Here's how we can load the data using odc-stac and xarray:

```{python}
# define a geobox for my region
Expand All @@ -120,8 +121,9 @@ with ProgressBar():

## Data Visualization
### RGB Image
As we are now in posession of the image data, we can start with the computations and visualizations.
First we define a mask to filter out the clouds and the areas with no data and then we can plot a composite median image of the data, which is just an image where each pixel value is the median value of all the scences we have found. This is necessary to get rid of clouds and outliers, which some images may have.
With the image data now in our possession, we can proceed with computations and visualizations.

First, we define a mask to exclude cloud cover and areas with missing data. Subsequently, we create a composite median image, where each pixel value represents the median value across all the scenes we have identified. This approach helps to eliminate clouds and outliers present in some of the images, thereby providing a clearer and more representative visualization of the scene.

```{python}
# define a mask for valid pixels (non-cloud)
Expand Down Expand Up @@ -151,7 +153,13 @@ plt.show()
```

### NDVI Image
To get an first impression of the data, we can calculate the NDVI (Normalized Difference Vegetation Index) and plot it. This gives us a good overview of the vegetation in the area. The values can range from -1 to 1 where the following meanings are associated with these values:
To get an first impression of the data, we can calculate the NDVI (Normalized Difference Vegetation Index) and plot it. The NDVI is calculated by useing the following formula. [@rouse1974monitoring]

$$
NDVI = \frac{NIR - Red}{NIR + Red}
$$

This gives us a good overview of the vegetation in the area. The values can range from -1 to 1 where the following meanings are associated with these values:

- -1 to 0 indicate dead plants or inanimate objects
- 0 to 0.33 are unhealthy plants
Expand All @@ -167,6 +175,7 @@ ndvi = normalized_difference(ds_odc.nir, ds_odc.red)
ndvi.median(dim="time").plot.imshow(cmap='cmc.cork').axes.set_title('NDVI')
plt.show()
```

## Classification

### Regions of Interest
Expand Down
10 changes: 10 additions & 0 deletions chapters/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,13 @@ @software{quast_getting_2024
doi = {10.5281/zenodo.6459598},
url = {https://doi.org/10.5281/zenodo.6459598}
}

@article{rouse1974monitoring,
title={Monitoring vegetation systems in the Great Plains with ERTS},
author={Rouse, John Wilson and Haas, R{\"u}diger H and Schell, John A and Deering, Donald W and others},
journal={NASA Spec. Publ},
volume={351},
number={1},
pages={309},
year={1974}
}
55 changes: 31 additions & 24 deletions notebooks/01_classification.ipynb
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
{
"cells": [
{
"cell_type": "raw",
"cell_type": "markdown",
"metadata": {},
"source": [
"---\n",
"title: Classification\n",
"author: Pikall Nikolas\n",
"format:\n",
" html:\n",
" code-fold: show\n",
"subtitle: Finding forests with satelite imagery\n",
"jupyter: \n",
" kernelspec:\n",
" name: \"01_classification\"\n",
" language: \"python\"\n",
" display_name: \"01_classification\"\n",
"format: \n",
" html:\n",
" code-fold: show\n",
"eval: true\n",
"---"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In this Notebook, we will use ``Scikit learn`` to classify an ``Sentinel-2`` Image. We will use two different classifiers and compare the results. \n",
"To get started we need to import the following modules."
"---\n",
"\n",
"## Data Acquisition\n",
"In this chapter, we will employ machine learning techniques to classify a scene using satellite imagery. Specifically, we will utilize ``scikit-learn`` to implement two distinct classifiers and subsequently compare their results. To begin, we need to import the following modules."
]
},
{
Expand Down Expand Up @@ -62,11 +62,10 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Data Acquisition\n",
"Before we start, we need to load the data. We will use ``odc-stac`` to get data from Earth Search by Element 84. Here we define the area of interest and the time frame, aswell as the EPSG code and the resolution.\n",
"Before we start, we need to load the data. We will use ``odc-stac`` to obtain data from Earth Search by Element 84. Here we define the area of interest and the time frame, aswell as the EPSG code and the resolution.\n",
"\n",
"### Searching Catalog\n",
"The module ``odc-stac`` provides access to free, open source Sattelite data. To actually get to the data, we define some parameters, which specify where and when we want Satelite data from. Also we define what data collection we want to get the data from, since there are multiple to choose from. In this example we use _multispectral imagery_ from the Sentinel-2 Satelite."
"The module ``odc-stac`` provides access to free, open source satelite data. To retrieve the data, we must define several parameters that specify the location and time period for the satellite data. Additionally, we must specify the data collection we wish to access, as multiple collections are available. In this example, we will use multispectral imagery from the Sentinel-2 satellite."
]
},
{
Expand Down Expand Up @@ -120,12 +119,13 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Here we will have a look at the area south-east of Vienna, where the Nationalpark _Donauauen_ is located. The time we are interested in is the beginning of may of 2024.\n",
"After passing these parameters to the `stac-catalog`\n",
"We have now found **10 scenes** that we can use for our analysis. \n",
"We will now focus on the area south-east of Vienna, where the Nationalpark _Donauauen_ is situated. The time frame we are interested in is the beginning of May 2024.\n",
"After passing these parameters to the `stac-catalog` we have found **10 scenes** that we can use for our analysis. \n",
"\n",
"### Loading the Data\n",
"Now we will load the data directly into an ``xarray`` dataset, which we can use to perform computations on the data."
"Now we will load the data directly into an ``xarray`` dataset, which we can use to perform computations on the data. ``xarray`` is a powerful library for working with multi-dimensional arrays, making it well-suited for handling satellite data.\n",
"\n",
"Here's how we can load the data using odc-stac and xarray:"
]
},
{
Expand Down Expand Up @@ -157,8 +157,9 @@
"source": [
"## Data Visualization\n",
"### RGB Image\n",
"As we are now in posession of the image data, we can start with the computations and visualizations.\n",
"First we define a mask to filter out the clouds and the areas with no data and then we can plot a composite median image of the data, which is just an image where each pixel value is the median value of all the scences we have found. This is necessary to get rid of clouds and outliers, which some images may have."
"With the image data now in our possession, we can proceed with computations and visualizations.\n",
"\n",
"First, we define a mask to exclude cloud cover and areas with missing data. Subsequently, we create a composite median image, where each pixel value represents the median value across all the scenes we have identified. This approach helps to eliminate clouds and outliers present in some of the images, thereby providing a clearer and more representative visualization of the scene."
]
},
{
Expand Down Expand Up @@ -198,7 +199,13 @@
"metadata": {},
"source": [
"### NDVI Image\n",
"To get an first impression of the data, we can calculate the NDVI (Normalized Difference Vegetation Index) and plot it. This gives us a good overview of the vegetation in the area. The values can range from -1 to 1 where the following meanings are associated with these values:\n",
"To get an first impression of the data, we can calculate the NDVI (Normalized Difference Vegetation Index) and plot it. The NDVI is calculated by useing the following formula. [@rouse1974monitoring]\n",
"\n",
"$$\n",
"NDVI = \\frac{NIR - Red}{NIR + Red}\n",
"$$\n",
"\n",
"This gives us a good overview of the vegetation in the area. The values can range from -1 to 1 where the following meanings are associated with these values:\n",
"\n",
"- -1 to 0 indicate dead plants or inanimate objects\n",
"- 0 to 0.33 are unhealthy plants\n",
Expand Down

0 comments on commit f337254

Please sign in to comment.