OpenStreetMap logo OpenStreetMap

Large and small trees

Posted by SomeoneElse on 31 May 2025 in English. Last updated on 12 June 2025.

Some large and small trees in Woollaton Park

The diameter_crown tag is fairly well used for trees. It’d be nice when showing trees to show larger ones as larger than smaller ones. One challenge is that the values can be a bit hit and miss. There are a couple of sorts of issues there:

One is “obviously silly values from an import gone wrong” like the 289 diameter_crown=width: 2.0; color: green; that have found their way into the database, perhaps by a failed JSON conversion.

Another is “human but not machine readable values” like “4 - 7 m

Another again is implausible values for certain tree types. For example, this is apparently a London Plane that is 5 times wider than it is high. That’s technically possible with a bit of pruning, but unlikely. Much more likely is that the data was not sanity checked before import, and the “diameter” figure here is actually a “circumference”.

In order to work around these issues, when processing the data prior to display I:

  • Make sure that diameter_crown is actually a number > 0. If it isn’t, I default it to 5.
  • Make sure that diameter_crown is not more than 35. 35 was chosen as a reasonable cut-off for “large, but not unfeasibly so” (there are genuinely larger trees of course, but many in OSM are just rubbish data).

It would have been nice to have used the actual “diameter_crown” value when rendering. On raster (which I’ve not looked at yet) that would have meant one icon per zoom level, which isn’t ideal. On vector, it would be nice to have the MapLibre map style do calculations based on diameter_crown directly (the documentation suggests that something might be possible, but is spectacularly unclear, and attempts to do something with that haven’t yet worked), so instead for now I went with three “large” sizes and one “normal” one.

Here is a map, centred on a large rhododendron.

Edit 12/06/2025: The raster version of that map (that updates every 5 minutes) is now live too. Here is that big rhododendron again, but on a raster map.

Location: Selehurst, Lower Beeding, Crabtree, Horsham, West Sussex, England, RH13 6PR, United Kingdom
Email icon Bluesky Icon Facebook Icon LinkedIn Icon Mastodon Icon Telegram Icon X Icon

Discussion

Comment from Binnette on 1 June 2025 at 09:24

Good idea 💡 I think it can be simplified as 2 or 3 differents rendering:

3 renderings example: - small tree icon (diam<5) - medium (5<diam<10) - large (diam>10)

Or something like so.

Also have to think about not hiding objects under the trees while rendering: trash can, bench, drinking water, etc.

But yes, I agree that it could make the map more “alive” 🌳🌲

Comment from SomeoneElse on 1 June 2025 at 09:45

3 renderings example: - small tree icon (diam<5) - medium (5<diam<10) - large (diam>10)

Based on the usage that taginfo suggests I’m actually using four sizes - “<=10”, “>10”, “>20” and “>30”. There are enough of the larger two to justify them being there as well; but above 35 some values seem to become silly.

Also have to think about not hiding objects under the trees while rendering

A couple of lines in the style try and do that. One is icon-allow-overlap (and also the way that the tree icon is drawn it’s designed to not look messy when drawn over others), and another is text-optional, which means that the icon will be shown even if there is no room for the text.

Comment from Binnette on 11 June 2025 at 22:19

Hi SomeoneElse, what is the next step of your idea?

Maybe consider doing a demo with overpass turbo (or ultra) and MapCSS to render different trees sizes?

That way, we can see how it looks to have a better impression.

Have a nice day.

Comment from SomeoneElse on 11 June 2025 at 23:10

The vector version is live already - see https://map.atownsend.org.uk/vector/index.html#15.94/52.947792/-1.209111 for the area in the picture above.

That map on that site covers UK and Ireland, but it’d be relatively easy for someone to create a similar map for a different area. The script used to create the map just takes Geofabrik areas as parameters (so here “europe britain-and-ireland”). You could use “europe france” as a parameter in the script to get a similar map for France, and as long as the machine generating the times didn’t run out of memory (there are ways of preventing that) it should “just work”.

I’ve also made similar changes to the raster version of the same map, so “different sized trees” should appear there too.

Log in to leave a comment