Skip to content

OSM Integration

Justin Forest edited this page Jan 10, 2025 · 24 revisions

This page collects findings on how to integrate with OSM. We currently publish our data as user YerevanTreeMaps.

Table of Contents:

Current status

  • Import new trees from OSM.
  • Import tree updates from OSM.
  • Export new trees to OSM.
  • Export changes to OSM.

OSM basics

In OSM, single trees are nodes with the following tags of our interest:

  • natural=tree tag, defines a single tree.
  • leaf_type, can be mapped from species.
  • genus, holds the first part of the latin scientific name, like Quercus or Fraxinus. There are also localized versions like genus:en.
  • species is the full latin name, like Quercus robur or Tilia cordata. If this is set, then genus is not needed.
  • species:wikidata which is a code like Q158746 which has a detailed information on the wikidata site, including names in many different languages, photos. Would be great to use this in our species suggestions.

Pulling data from OSM

Updates are pulled from OSM using the treemap osm-pull command. That command uses the Overpass API to pull all natural=tree nodes from the configured area and put them with the related tags in the osm_trees table. Next we see if there are OSM nodes for which we don't have records in our trees table (matching by the osm_id field) and we add them. That's how we pull new trees from OSM. This process normally runs every hour. The update region is defined in the src/utils/env.rs file.

Pushing data to OSM

New trees are pushed to OSM using the treemap osm-push command. We look in the trees table to find trees that don't have an osm_id, create a new changeset and send 100 of those trees to OSM using the API. We then set the new received osm_id in the trees table. This is how we push new trees to OSM. This process normally runs every hour.

Some tools

  • To get information on a node by its id, a link like this can be used.
  • Overpass Turbo can be used to construct queries, run them manually and download filtered data for a bounding box. There are issues with finding data related to a country or a region, so perhaps using a pre-defined bounding box is an ok solution for now.
  • The Overpass API is the official and recommended read-only interface to the OSM data. It should be used to actually execute the queries and get the data we need.

Clone this wiki locally