This project emerged after reading this Spiegel article:
https://www.spiegel.de/wissenschaft/natur/hitze-in-europa-wie-gut-stadtbaeume-vor-extremer-waerme-schuetzen-a-9a0b26e5-f8ae-4fa5-a897-2f2b026f5226?giftToken=a8462cd8-83b8-4712-8ad1-c0d1f0147f6d
It says that 30% of the surrounding area with a radius of 60 m should be shaded by trees (Croeser, Rahman & Ghosh (2026)).
Since only a few German cities were listed in the article, I wanted to visualize my home town. This is the project that resulted.
I wanted to get this done within the current July 2026 heatwave in Germany, so ChatGPT was used for coding.

You can use this repository to create the map for your town (I am curious, so feel free to share it :)).
Generate a virtual environment using python -m venv .venv or any other environment manager and install the requirements from requirements.txt.
I used the publicly available areal data Digitales Orthophoto RGB 20cm (DOP20 RGB). There you can download single 1x1 km tiles or use aria2c to download tiles in batches, i.e. for a whole city. This can be done in the command line like this using the downloaded meta4 file:
aria2c downloadErlangenData/09572142.meta4
Aria2c is available at: https://github.com/aria2/aria2
After the files are successfully downloaded I used gdal to create a mosaic of the .tif files for better memory management. In WSL or ubunut it can be installed wir sudo apt install gdal-bin. Then the mosaic file can be built like this:
dalbuildvrt canopy_mosaic.vrt tiles/*.tif
I used the pretrained model DeepLabV3Plus ResNet34 and trained it on the arial data using a few manually labelled tiles. The trained model configuration I used can be found in best_deeplabv3plus.pth. To train it yourself which might be necessary if the images look too different to the ones I used you'll need to label some images and train it using trainDeepLabV3.
Once you have a set of images you can use DeepLabV3Inference.py to perform the segmentation. You will get a large .tif file which is 0 for "not tree" and 1 for "tree".
Next, the values for each building are generated. For this, use the file createMaskAverageExportBuildings.py. This script uses the mask to calculate the percentage of area covered by trees in its surrounding. If your images are not 0.2 m per pixel, you'll need to change the radius in pixels accordingly. After creating the average, the building geo data is loaded from OSM and then zonal statistics for each building are calculated. To only use the buildings withing the municipality used, you need to get the polygon using getMunicipalityPolygon.py
Optionally, you can also visualize the tree polygons. However, these can become quite large so this is only feasible for smaller areas.To do this use createTreePolygons.py.
Copy the buildings and trees geojsons into the website folder. Currently, the initial coordinates are centered on Erlangen, Germany. To change it modify it in apps.js. Open index.html with Live View or publish your data.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copyright (c) 2026 Jakob Schultz