Colour Coded OSM Notes displayed based on last edit date

Posted by pole_climber on 2 June 2017 in English (English)

A few years back within the Tendring District of England I started to place Notes on OSM when local government granted planning permission permitting development of new dwellings, roads or change of use of buildings i.e. an office building becomes a residential property. It’s a semi automatic utility which might feature in a future diary entry but for now let’s focus on OSM Notes.

I’ve created quite a few Notes and they’ve become difficult to manage. I needed a visual map highlighting notes that have not been reviewed for years so I, and others, can focus on returning to the oldest Notes updating and closing accordingly. After some thought I created this UMAP available at UMAP.

The rest of this diary is about how that’s produced.


I use a Raspberry PI, a credit card size always on computer running a Linux based OS. A cron job runs every Saturday and downloads from OSM all the open notes in the area I’m interested in. A Python program runs after the download sorting through the notes separating them into three CSV files, one for notes not edited within that last year, another for notes over 6 months old and another for notes edited within the last 6 months. These CSV files are currently manually loaded into my UMAP as layers but that can also be automated.

Now the detail

Downloading OSM Notes

There is an OSM Note API described in detail here

First we need the coordinates of the area you want to download. The easiest way I’ve found to do this is click on EXPORT (top left) on OSM, then select Manually Select a different area adjusting the displayed box to the area you want to extract notes – KEEP IT SMALL. The numbers displayed in the grey box are you’re bbox coordinates LEFT, BOTTOM, RIGHT & TOP as defined by the Notes API.

I then execute a wget command as follows.

wget -O /media/networkshare/raspberry/notes.xml ",51.7653,1.3019,51.9489&limit=10"

-O defines my output file

.xml as the file extension downloads notes in XML format

&limit=10 only 10 notes downloaded – maximum is 10,000.

Now I have a file called notes.xml listing all the notes in my area of interest.

Processing using Python

A screen shot of the Python Code is shown below The input and output file names are configurable as are the two date fields. In the sample above I’ve set the code to extract notes older than 365 days into the first file, notes between 365 and 183 days into file two and notes not edited in the past 183 days into the third file. The code produces CSV files for easy importing into UMAP. Each note also includes the username of the last person who edited the note and also the last comment and a clickable link through to the actual note hosted on OSM.

After executing the code using your input file notes.xml three new files (as defined by you) will exist ready for importing into UMAP.

Import into UMAP

I’m not going to explain the full process of creating a UMAP here, only the import process and the finer details of interaction and remote data. Click the import button (arrow as shown below) and then set the input file, file type, the layer and click REPLACE if you want your new data to replace the existing data.

The CSV file contains, in this order, 1. Longitude 2. Latitude 3. Note ID 4. Note Status 5. Note Date (last edit) 6. OSM User who made the edit 7. The Note text with commas and line spacing removed by the utility.

When a user clicks on a note a box appears which UMAP allows you to control the content and format. To change the formatting select Manage Layers, Edit (one of your layers), Interaction Options and format the Popup content template as shown below.

Automating the entire process

The download of data from OSM and running the utility are already fully automated. The one last piece I haven’t yet completed is “uploading” the data weekly to UMAP. This is actually easy if you have some hosting space as UMAP supports Remote Data. To complete this section you just need to Manage Layers, Edit (one of your layers), Remote Data and set the location of the three csv files which will be dynamically loaded as required. I’ve tried to use Google Drive for this purpose but annoyingly google drive changes the file name each time a revision is uploaded. A job for another day.

I hope that’s been of interest. I can make the code available to those interested, just get in touch.

Comment from RobJN on 2 June 2017 at 23:14

Awesome! Would be great if the site did this sort of thing (one for the wishlist).

Comment from GOwin on 3 June 2017 at 01:38

That's a very detailed post, @pole_climber. Thank you for sharing.

Login to leave a comment