This project will take a aerial image (RGBI) and an nDSM to classify four Trees Outside Forest classes:
- Class 1: Forest
- Class 2: Patch
- Class 3: Linear
- Class 4: Tree
If no nDSM is available it can take a image-based DSM and a DEM to automatically create it.
An automated approach with manual refinement is used to create the reference data for training and validation. First, a mask is created for all values below a threshold for the nDSM of 3m. The threshold for the nDSM was set to include shrubs but exclude high growing crops. This was then used to mask the NDVI, which was then clustered into two classes using K-means. This results in one class containing all buildings and the other class containing the trees. As there was an issue with some roofs having shadows, the tree mask was updated using the Shadow Index (SI) with values lower than 150. The SI is calculated as follows:
SI = sqrt((255 - Blue) * (255 - Green))
Afterwards, the remaining tree raster cells were filtered by a morphological closing (5×5) and polygonized. To clean the results smaller objects than 3m² were delted and the edges we smoothed using To distinguish between forest and TOF, we follow the FAO definition. Forest is defined as areas larger than 0.5ha and with a width larger than 20m. The width of the polygons is calculated using smaller site of the smallest rotated enclosing rectangle. All polygons with a smaller width than 20m and smaller area than 0.5ha are classified as TOF. These TOF polygons are then classified into the following classes:
- Patch: Areas smaller than 0.5ha and larger than 500m² and elongation (length divided by width) lower than 3.
- Linear: Elongation is higher than 3.
- Tree: Smaller than 500m² \end{itemize} Finally, a manual refinement step was necessary to ensure the quality of the reference data. In particular, linear objects that were part of a forest polygon had to be cut and reclassified.
To create and activate a conda environment with the necessary dependencies, follow these steps:
-
Create a new conda environment:
conda create --name tof-detection python=3.x
-
Activate the environment:
conda activate tof-detection
-
Install the required dependencies:
pip install -r requirements.txt
- To install the necessary dependencies, run:
pip install -r requirements.txt
To start the process you need the following folder structure:
main.py
├── Sites
| ├── Site_Name
| | ├── DGM
| | ├── TOP
| | ├── bDOM
| | ├── nDOM
Abbreviations refer to German governmental data. DGM = Digital Terrain Model, TOP = True Orthophoto, bDOM= image-based Digital Surface Model, nDOM = normalized Digital Surface Model
The files in these folders should build like "Folder_Name_ID.tif" like "bDOM_33_382_5856.tif".
You can either put directly a normalized Digital Surface Model or let it create by DGM and Digital Terrain Model with an image-based Digital Surface Model
The script does have two functionalities:
- Creating the TOF classes from the input data with a shapifile as result
python main.py "Site_Name" --epsg "EPSG:Number"Now it's time for the manual refinement in the Site_Name Shapefile!
- Create the masks to then use them for training with tif masks as result
python main.py "Site_Name" --create_masks --epsg "EPSG:Number"Ensure that the EPSG code provided matches the coordinate system of your data.
@INPROCEEDINGS{Lucas_2024,
author={Lucas, Moritz and Barkov, Viacheslav and Pecenka, Ralf and Atzmueller, Martin and Waske, Björn},
booktitle={IGARSS 2024 - 2024 IEEE International Geoscience and Remote Sensing Symposium},
title={Mapping Trees Outside Forests Using Semantic Segmentation},
year={2024},
pages={4435-4438},
doi={10.1109/IGARSS53475.2024.10641035}
}Contributions are welcome! Please submit a pull request or open an issue for any changes or suggestions.
This project is licensed under the MIT License.
For support or questions, please contact [moritz.lucas@uos.de].