Calculate different indices of Sentinel-2 and Landsat 8 raster images and, if desired, cut them to a specific area of interest (AOI, recommended since they are clipped beforehand and can therefore strongly decrease execution times!).
Following indices are available so far:
Index | Sentinel-2 | Landsat 8 |
---|---|---|
Atmospherically Resistant Vegetation Index (ARVI) | x | x |
Green Chlorophyll Vegetation Index (GCI) | x | x |
Green Normalized Difference Vegetation Index (GNDVI) | x | |
Normalized Burn Ratio (NBR) | x | x |
Normalized Burn Ratio 2 (NBR2) | x | x |
Normalized Difference Build-up Index (NDBI) | x | x |
Normalized Difference Moisture Index (NDMI) | x | x |
Normalized Difference Red-Edge Vegetation Index (NDRE) | x | |
Normalized Difference Snow Index (NDSI) | x | x |
Normalized Difference Vegetation Index (NDVI) | x | x |
Normalized Difference Water Index (NDWI) | x | x |
Red-Edge Inflection Point (REIP) | x | |
Soil-Adjusted Vegetation Index (SAVI) | x | x |
Structure Intensive Pigment Vegetation Index (SIPI) | x | x |
If you want any indices to be implemented as well, please don't hesitate to write an issue.
The following outputs can be automatically generated and saved to ./results/
:
As before, if there is any type of output which you would want to get as well, please write an issue.
Required data to calculate indices are multispectral raster images with specific bands needed for specific indices. So far both the Sentinel-2 and Landsat 8 satellite platforms with their respective multispectral sensoring systems are implemented and can be used as input datasets.
Note: indices for Landsat 8 datasets can only be calculated with a spatial resolution of 30 meters, Sentinel-2 offers the possibility to calculate with a spatial resolution of 10, 20 and 60 meters.
The datasets can be acquired through different ways, the following two are only exemplarily shown:
Exemplary multispectral raster data for both satellites (S is Sentinel-2, L is Landsat 8) can be found here and should be put into ./data/raster/
(unzip so as the name of the file is the first folder like ./data/raster/L*/tif-files
).
If you want to clip the raster data, you will need a shapefile with your AOI. It has to be manually put into ./data/shapes/
.
An example AOI to test the program can be found in the HeiBOX folder mentioned above as well (unzip without creating a new folder like ./data/shapes/aoi.shp
).
To run the program every machine having at least Python 3.9 installed is suitable. Your Python environment should additionally include following libraries:
The rest should be included in the python installation. If you are using Linux or Mac, you should check the relative paths beforehand.
Create your virtual python environment and clone the repository. Open the terminal and navigate to the cloned/downloaded folder index-calculator
. If you don't have the required packages installed already, call this first:
$ pip install -r ./requirements.txt
You should then be ready to execute the program.
If ready, call the program without any arguments to access the help within the terminal with information on how to use the arguments:
$ python src/main.py
usage: main.py [-h] -i Index name [-c Clip] [-sat Satellite] [-r Resolution] [-ov Optional value]
[-tif Save raster] [-gp Generate plot] [-sp Save plot] [-txt Save as txt] [-stat Statistics]
Calculate an index with Sentinel-2 satellite imagery.
You can use the following options to adapt the calculation to your needs. Have fun!
required arguments:
-i Index name String | Choose which index gets calculated.
Check the README for a list of possible indices.
optional arguments:
-c Clip String | Clip raster to shapefile with shapefile. Use the name and file-type only
(like aoi.shp). Default value: None
-sat Satellite String | You can use different satellite datasets (sentinel2/s2 or landsat8/l8).
Default value: s2
-r Resolution Integer | When using Sentinel-2 datasets, the indices can be calculated with
different resolutions (10, 20, 60 (m)). Default value: highest resolution possible
-ov Optional value Float | Some indices need additional values like the L-value in SAVI (0.5).
Default value: as in literature
-tif Save raster Boolean | Do you want to export the results/ndarray as tif-file locally
to ./results/? Use true/false. Default: false
-gp Generate plot Boolean | Do you want to generate a plot? Use true/false. Default: true
-sp Save plot Boolean | Do you want to save the plot locally to ./results/? Use true/false.
Default: false
-txt Save as txt Boolean | Do you want to save the results/ndarray as txt-file locally
to ./results/? Use true/false. Default: false
-stat Statistics Boolean | Do you want to generate statistics (histogram & descriptive) for
the results and save them locally to ./results/? Use true/false. Default: false
Exiting program, call again with arguments to run.
If finished with multiple analyses, you can empty ./results/
and delete temporary used files from ./data/.
Make sure to save any results you want to keep to another location BEFORE executing the following command!
To do a cleanup, call:
$ python src/cleanup.py
If you have any questions, wishes or ideas, feel free to ask me in the issues section, I'm looking forward to it. Have fun!