OpenStreetMap

Who is the first OSM editor around my city?

Posted by rtnf on 30 November 2022 in English.

While editing this week’s edition of WeeklyOSM, I discovered that OSHDB version 1.0 has been released. So, I decided to test it by myself.

Set the bbox around Bekasi, Indonesia. Then set the filter to (key=highway, value=blank).

Then, I see the download button. Apparently, we can download the detailed CSV data.

So, it seems that the first highway edit happened around August 12, 2008.

Now I’m really curious, who is this OSM editor that contributed to the first highway ever around my city?


After digging the API documentation, I found a solution.

Step 1 : Get the data

Run this python script. It will generate a json file.

import requests
URL = 'https://api.ohsome.org/v1/elementsFullHistory/geometry'
data = {"bboxes": "106.9216919,-6.4162955,107.1153259,-6.0982253", "time": "2008-01-01,2016-01-01", "filter": "highway=*"}
response = requests.post(URL, data=data)
print(response.text)

Note : It’s hard to manually construct the bbox. So, i use the JOSM editor to calculate the bbox for me.

Step 2 : Process the data

This code will sort the retrieved OSM objects (that json file from step 1) according to their creation date. Then it will output a nice markdown table, with links to OSMLab’s OSM Deep History, for further inspection.

import json
from datetime import datetime
from dateutil.parser import parse

f = open('bekasi.json')
data = json.load(f)
allobj = []

for i in data['features']:
	obj = {}
	fromT = parse(i['properties']['@validFrom'])
	obj['from'] = fromT
	obj['id'] = i['properties']['@osmId']
	allobj.append(obj)

allobj = sorted(allobj, key=lambda d: d['from'])
print("Created | OSM ID")
print("-|-")
for i in allobj:
	oid = str(i['id'])
	print(str(i['from'])+ " | "+"["+oid+"](https://osmlab.github.io/osm-deep-history/#/"+oid+")")

Here’s the result :

Minor Revision

Then I suddenly realized that, why I start the query from “2008-01-01”? Can we go even further? What happens if I set the start date to 2000, for example?

{
  "timestamp" : "2022-11-30T06:03:43.184642",
  "status" : 404,
  "message" : "The given time parameter is not completely within the timeframe (2007-10-08T00:00:00Z to 2022-11-20T21:00Z) of the underlying osh-data.",
  "requestUrl" : "https://api.ohsome.org/v1/elementsFullHistory/geometry"
}

Apparently, 2007-10-08 is the maximum limit. So, I recalculated the data, based around this limit. Here’s the revision.


So, what is the first OSM highway edit around my city? I still don’t know. This statistics showed that OSM edit has already begun since 2005, but this API’s maximum limit is around 2007.

Discussion

Comment from fititnt on 2 December 2022 at 05:38

I didn’t know about this OSHDB. Nice! Thank you, rtnf! Also, this https://osmlab.github.io/osm-deep-history/ interface is quite helpful to check the tags changes over time. I will start using it!

Anyway, something I sort of miss from being a first-class citizen (sense: having better support out of the box) are queries based on things inside other things how things touch each other (e.g. sort of spatial operations). However, even administrative boundaries (which are quite common requests, because it is generic, even if boundaries can be disputed) have poor support. Yes, I do understand that because the way the data is stored in SQL databases the bboxs filter as highly optimized for performance, but in some aspects, even if via query rewriting (e.g. user try some name for a region, then is rewritten in something that the underlying storage can work with) is quite limited.

I mean, I’m not saying the full GeoSPARQL (here the preview of GeoSPARQL 1.1, which by the way cite more than one implementation using OpenStreetMap), but for example PostGIS 3.3 does have support for Spatial Relationships, so in theory, even if not the main database, might have some way to make it viable 😐

Comment from SK53 on 2 December 2022 at 17:58

There are some quirks in the earliest OSM history, some, perhaps, as a result of changes in the data model.

Log in to leave a comment