diff --git a/_quarto.yml b/_quarto.yml index ba07ba0..1e5865a 100644 --- a/_quarto.yml +++ b/_quarto.yml @@ -8,7 +8,7 @@ project: book: title: "notebooks4eo" author: "" - date: "10/7/2024" + date: "7/10/2024" chapters: - index.qmd - chapters/01_classification.qmd diff --git a/chapters/01_classification.qmd b/chapters/01_classification.qmd index cf04630..259cb53 100644 --- a/chapters/01_classification.qmd +++ b/chapters/01_classification.qmd @@ -153,6 +153,25 @@ plot.axes.set_title(f"RGB - Median Composite\n{start_date.strftime('%d.%m.%Y')} plt.show() ``` +### False Color Image +In addition to the regular RGB Image, we can swap any of the bands from the visible spectrum with any other bands. In this specific case the red band has been changed to the near infrared band. This allows us to see vegetated areas more clearly, since they now appear in a bright red color. This is due to the fact that plants absorb regular red light while reflecting near infrared light [@nasa2020]. + +```{python} +# compute the false color image +fc_median = ( + ds_odc[['nir', 'green', 'blue']] + .where(ds_odc.valid) + .to_dataarray(dim="band") + .transpose(..., "band") + .median(dim="time") + .astype(int) +) +fc_comp = avg(fc_median) +plot = fc_comp.plot.imshow(rgb="band", figsize=(8, 8)) +plot.axes.set_title(f"False Color - Median Composite\n{start_date.strftime('%d.%m.%Y')} - {end_date.strftime('%d.%m.%Y')}") +plt.show() +``` + ### NDVI Image 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] diff --git a/chapters/references.bib b/chapters/references.bib index 366cf1f..9362bb7 100644 --- a/chapters/references.bib +++ b/chapters/references.bib @@ -150,3 +150,11 @@ @article{rouse1974monitoring pages={309}, year={1974} } + +@online{nasa2020, + title = {Earth Observatory}, + author = {NASA}, + year = {2020}, + url = {https://earthobservatory.nasa.gov/features/MeasuringVegetation/measuring_vegetation_2.php}, + urldate = {2024-07-26} +} \ No newline at end of file diff --git a/notebooks/01_classification.ipynb b/notebooks/01_classification.ipynb index 8bd7ddb..c4cf296 100644 --- a/notebooks/01_classification.ipynb +++ b/notebooks/01_classification.ipynb @@ -195,6 +195,35 @@ "execution_count": null, "outputs": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### False Color Image\n", + "In addition to the regular RGB Image, we can swap any of the bands from the visible spectrum with any other bands. In this specific case the red band has been changed to the near infrared band. This allows us to see vegetated areas more clearly, since they now appear in a bright red color. This is due to the fact that plants absorb regular red light while reflecting near infrared light [@nasa2020]." + ] + }, + { + "cell_type": "code", + "metadata": {}, + "source": [ + "# compute the false color image\n", + "fc_median = (\n", + " ds_odc[['nir', 'green', 'blue']]\n", + " .where(ds_odc.valid)\n", + " .to_dataarray(dim=\"band\")\n", + " .transpose(..., \"band\")\n", + " .median(dim=\"time\")\n", + " .astype(int)\n", + ")\n", + "fc_comp = avg(fc_median)\n", + "plot = fc_comp.plot.imshow(rgb=\"band\", figsize=(8, 8))\n", + "plot.axes.set_title(f\"False Color - Median Composite\\n{start_date.strftime('%d.%m.%Y')} - {end_date.strftime('%d.%m.%Y')}\")\n", + "plt.show()" + ], + "execution_count": null, + "outputs": [] + }, { "cell_type": "markdown", "metadata": {},