Life and Shell

Writing · drones

New forestry maps in Ollebo: national layers, licences first, and finding ruts with a drone

By Mattias Hemmingsson · · 4 min read

Today we started on a new group of maps in Ollebo: Skogsbruk, forestry. Forest owners and contractors already fly drones over their land with us. What they are missing is context: how tall the trees are, how steep the ground is, where the ditches go, and what the terrain looked like before the harvester drove over it.

Sweden has excellent open data for all of that, from Skogsstyrelsen (the Swedish Forest Agency) and Lantmäteriet. Getting it into the map was the easy part. Making sure we are allowed to serve it in a commercial product took most of the day.

The layers

The pilot area is Västerbotten. These are the layers we are adding:

Layer Source Resolution Licence
Tree height (Trädhöjd) Skogsstyrelsen 1 m CC0
Slope (Lutning) Skogsstyrelsen not stated CC0
Ditches (Dikeskartor) Skogsstyrelsen not stated CC0
Terrain model (Markhöjdmodell) Lantmäteriet 1 m CC BY 4.0
Topographic background (TWK Nedladdning raster) Lantmäteriet CC BY 4.0
Soil moisture (Markfuktighetskarta) SLU 2 m unconfirmed, blocked

The topographic background was a decision on its own. Lantmäteriet's overview topographic web map service closes on 31 December 2026, so instead of building on it we import the downloadable raster version and host it ourselves.

Licences first, in code

"Open data" covers a lot of different terms. Some of what we found today:

  • Skogsstyrelsen's own data is CC0. But using the rasters in your own system needs an organisation account.
  • SLU's soil moisture map is distributed by Skogsstyrelsen, but it is built on Lantmäteriet's elevation data. Skogsstyrelsen's CC0 only covers data they produce. There is no licence text on SLU's page. So it is blocked until we have it in writing.
  • Lantmäteriet's "valuable datasets" are CC BY 4.0, and the attribution is mandatory: product name, © Lantmäteriet, that it has been processed, and the licence.
  • Current orthophotos come with GDPR terms, storage only in the EU/EEA, and use limited to an approved purpose. Blocked until we decide.

We wrote all of this down in a licence register, and then made the code enforce it. Every source file now declares:

id: lm-markhojd
status: disabled            # enabled | disabled | blocked
commercialOk: true
licenseUrl: https://www.lantmateriet.se/.../anvandningsvillkor_for_vardefulla_datamangder.pdf
licenseVerifiedAt: 2026-11-11
attribution: "Markhöjdmodell © Lantmäteriet, bearbetad av Ollebo, CC BY 4.0"
  • import, plan, seed and publish refuse any source that is not enabled with commercialOk: true.
  • The tile proxy answers 404 for such a source, even if the tiles are already in its cache.
  • The map generator skips it, so it never shows up in the layer picker.
  • geodata enforce removes anything already live whose source has since been blocked: the catalog row, the tile registration, the files and the cached tiles.
  • The attribution is shown in the map, and goes into exports and workflow results too.

Right now most layers are disabled, not blocked. The licence is fine, and we are waiting for the Skogsstyrelsen and Geotorget accounts. When the accounts are ready, flipping status turns the layer on.

Hosting national rasters with their real values

Drone maps in Ollebo are mostly pictures: RGB tiles to look at. National layers are data. Tree height is metres, slope is degrees, the terrain model is elevation. We want to colour them in the map and use the numbers in analysis.

So map-maker got new "value-preserving" Cloud-Optimized GeoTIFF variants:

  • scalar (tree height, soil moisture): keep the data type, averaged overviews
  • categorical (classes): nearest-neighbour overviews, so classes never blend
  • elevation: keep the values exactly

All of them use ZSTD with a predictor and keep the original CRS. Sources that come as many map sheets or zip files are mosaicked and clipped to the area of interest. Each publish goes into a new version folder, and the previous one is kept, so we can compare versions later.

In the map, layers in the forestry group get their own picker group and a colour legend. The legend is drawn from the tile server's own colour map, so it always matches the tiles.

External tile services through our own cache

Some layers we don't import at all. We serve them from the provider's tile service through a cached proxy at /ext/<source>/{z}/{x}/{y}:

  • each upstream tile is fetched at most once per TTL, and empty tiles are cached too
  • a per-source rate limit, request coalescing and a circuit breaker, so we never hammer a government service
  • stale-while-revalidate, so the map keeps working when upstream is slow
  • credentials only in a header, never in a URL a user can see

The same licence gate applies: no enabled + commercialOk, no tiles.

Rut-check: finding ruts with a drone

The first analysis workflow on top of these layers is rut-check. After a harvest, heavy machines can leave deep ruts (körskador), especially on wet ground. They damage the soil and can carry sediment into streams, and the forest owner has to deal with them.

A drone flight gives a terrain model of the logged area at a few centimetres. rut-check compares it with the national 1 m terrain model:

  1. Put the drone terrain model on a SWEREF 99 TM grid.
  2. Subtract the national terrain model (or, until that layer is live, the drone surface's own smooth trend).
  3. Remove the smooth background, so only small local depressions are left.
  4. Keep long, narrow depressions deeper than a threshold. A rut is a line, a hole is not.
  5. Score them higher on wet ground, using the soil-moisture layer when it is cleared.

The output is a residual elevation map, the ruts as GeoJSON and GeoPackage in SWEREF 99 TM, and a summary. You start it from the dashboard on an elevation map, and the job runs on a geodata worker that picks it up from NATS.

All results are stored per run in the private bucket. They come from a customer's own drone elevation data, and under the spridningstillstånd rules elevation models are never public.

Status

The code for all of this went in today on a forestry branch. The layers turn on one by one as the accounts come through, starting with Skogsstyrelsen's tree height, slope and ditches. The vector layers (key biotopes, nature values, wetland forests) come later, after a GDPR check, because they can touch private properties.

Filed underdrones · gis · forestry · lantmateriet · skogsstyrelsen · ollebo