Back to projects

Urban Tree Transfer

I tested whether a model trained in Berlin could recognise tree genera in Leipzig from Sentinel-2 data and how much local data it needed.

Role
Geospatial data preparation, model training and evaluation
Period
2025 to March 2026
Status
completed
Links
Code on GitHub Report as PDF (English)
Weighted F1 in Berlin
0.75
Weighted F1 in Leipzig, zero-shot transfer
0.38
Share of local data at which transfer helps
25 to 50%

Background

Many cities have no tree cadastre. Mapping trees in the field is expensive. A model can recognise tree genera from satellite data, but its performance drops when it moves to another city. The size of this drop in tree genus recognition had yet to be measured systematically.

Research question

I trained a model on data from Berlin and tested it in Leipzig. First, I measured how well it recognised tree genera there without additional training data. Then I used different amounts of data from Leipzig to see how much of the loss I could recover.

Summary of results

Without local data, the Berlin model performed about half as well in Leipzig. It performed better than a model trained from scratch mainly when I had a quarter to half of the Leipzig data for further training.

Data

I combined the tree cadastres from Berlin and Leipzig. The Berlin cadastre contains 905,132 trees, and the Leipzig cadastre contains 167,867. After quality filtering, 782,022 trees remained for the analysis. I use the genus recorded in the cadastre as the target class for the model. I distinguish 17 genus classes.

The satellite data come from Google Earth Engine. I use Sentinel-2 monthly composites for 2021, which combine several observations per month into a single image. I use cloud masking to exclude parts of the images that clouds cover. I calculate vegetation indices from the satellite data by combining different spectral bands into metrics for vegetation.

To match each tree to the satellite image, I adjust the position from the cadastre to the tree crown. I derive a canopy height model from elevation models to represent crown height above the ground. I use the adjusted position to assign each tree the values of one pixel.

Pipeline and spatial blocks

I implemented the processing pipeline as a Python package with tests. The package lets me repeat the workflow from raw data to evaluation. During feature selection, I decide which of the calculated features to use in the model.

Neighbouring trees tend to be similar. Because of this spatial autocorrelation, a random split can place similar trees in both the training and validation sets. The result then depends in part on how many trees from the same area the model saw during training.

I therefore divide the data into spatial blocks of 1200 m. In block cross-validation, I hold out entire blocks for validation and train on the remaining blocks. I also split the training and test data by block. I leave the test set unfiltered.

Random split versus spatial blocks Two fields side by side, each with ten by six tree dots on a faint grid. In the left field, random split, the dots are training or test one by one in a mixed pattern; about one in five is test. In the right field, spatial blocks, 1200 m, thicker lines divide the field into five by three blocks of two by two trees. Whole blocks are training or test; three test blocks have an accent background and their dots are outlines only. Below the left field: neighbouring trees end up in training and test, the score looks too good. Below the right: whole blocks are training or test, the test measures real transfer. At the bottom a legend: filled dot training, open dot test. The three test blocks are highlighted. Random split Spatial blocks, 1200 m Neighbouring trees end up in training and test: the score looks too good Whole blocks are training or test: the test measures real transfer Training Test
Fig. 1With a random split, the test set includes trees near those used for training. Spatial blocks separate training and test data.

Models and experiments

I compare four models. Random Forest combines the predictions of many decision trees. XGBoost adds trees one at a time to correct errors in the predictions made so far. The 1D CNN uses filters to find patterns in a sequence of input values. TabNet selects which features to use for prediction when it processes tabular data. I use an automated search to choose the settings that must be fixed before training, called hyperparameters.

First, I optimise the models in Berlin. Then I examine domain shift, which is the change in the data when moving to another city. I test this through zero-shot transfer by applying the Berlin model in Leipzig without using local training data.

In the third experiment, I adapt the pretrained model to Leipzig through fine-tuning on local data. I use 10%, 25%, 50% and 100% of the Leipzig data. For comparison, I train a model from scratch in Leipzig. This lets me assess the benefit of pretraining in Berlin at different shares of local data.

Hypotheses

I defined the hypotheses before the experiments and tested them statistically. The results supported one hypothesis. Recognition performance dropped by different amounts for different genera when I moved the model to Leipzig.

I rejected another hypothesis. Spectral separability, which measures how well satellite signals distinguish genera, did not predict transfer performance.

Test set results

I use weighted F1 for the evaluation. It accounts for how often predictions for a genus are correct and how many of its trees the model finds. More common genera carry more weight in the overall score.

In Berlin, XGBoost reaches a weighted F1 of 0.75. With zero-shot transfer to Leipzig, the score drops to 0.38. Fine-tuning with 10% of the Leipzig data raises it to 0.50, with 25% to 0.57 and with 50% to 0.66. With 100%, the pretrained model reaches 0.77. Training from scratch in Leipzig reaches 0.79.

With all the Leipzig data, training from scratch performs about as well as fine-tuning. The practical benefit of transfer occurs at intermediate shares of 25 to 50% of local data. For a city without a tree cadastre, this gives an indication of how much field survey work it needs.

Class balancing, where I balance the influence of genera with different frequencies during training, improved the score by around 18 percentage points. It had a larger effect than the choice of model. In Berlin, class balancing improves the result. It also widens the transfer gap, which is the difference between the results in Berlin and Leipzig.

Leipzig: score by share of local data Line chart: weighted F1 of the Berlin model in Leipzig, fine-tuned with 0, 10, 25, 50 and 100 percent of the Leipzig training data; the five steps are evenly spaced. Values: without Leipzig data (zero-shot) 0.38, at 10 percent 0.50, at 25 percent 0.57, at 50 percent 0.66, at 100 percent 0.77. Two dashed reference lines: a model trained from scratch on Leipzig data only, 0.79, and the Berlin model on the Berlin test set, 0.75. The line of the fine-tuned Berlin model is highlighted. 0.3 0.4 0.5 0.6 0.7 0.8 0 % 10 % 25 % 50 % 100 % Share of Leipzig training data Weighted F1 Leipzig only, from scratch: 0.79 Berlin model on the Berlin test: 0.75 0.38 0.50 0.57 0.66 0.77 zero-shot Berlin model, fine-tuned in Leipzig
Fig. 2Weighted F1 for XGBoost in Leipzig by share of local training data, compared with training from scratch and the Berlin test result.

Limitations

The analysis covers one year and two cities with the same climate. I distinguish trees at genus level. I analyse a single pixel for each tree.

I use the genus labels from the cadastres without checking them. Label noise from incorrect genus labels can distort the measured transfer gap.

Status

I completed the project in March 2026. The report is available in English as a PDF.

Next case study

Tourengenie