Overpass query example

The map at a past date

Query OpenStreetMap as it was on a past day with the date setting. Example: the cafés of central Zürich on 1 January 2015.

History queries are part of the Medium and Large plans. The result below runs on our server for this page.

Overpass keeps the old versions of every element. With the [date:…] setting, the whole query runs on the data of that moment: the tags and positions elements had then, and the elements that existed then.

This query finds the cafés in central Zürich on 1 January 2015. The first example searches the same box today.

The query

[out:json][timeout:60][date:"2015-01-01T00:00:00Z"];
nw(47.365,8.535,47.380,8.555)(if:t["amenity"]=="cafe");
out center;

Run it

Running the query…

Live result from overpass.ch, cached for up to 12 hours. Map data © OpenStreetMap contributors (ODbL).

How it works

  1. [date:"2015-01-01T00:00:00Z"] sets the moment, in UTC. Every statement of the query sees the data of that moment.
  2. nw(47.365,8.535,47.380,8.555) searches nodes and ways in the box. Relations are left out: at a past date they make a query many times slower.
  3. (if:t["amenity"]=="cafe") keeps the cafés. In history queries this is faster than ["amenity"="cafe"], because the tag is checked only on the elements in the box.
  4. out center; prints the cafés with the tags and the position they had on that day.
  5. The history starts on 12 September 2012, when OpenStreetMap changed its licence. An earlier date gives only the elements that nobody edited between that date and September 2012.

Variations

  • Areas work at a past date, with their current outline: area["name"="Zürich"]["admin_level"="8"]->.a; and nw(area.a). For all of Zürich this takes about 10 seconds.
  • One object at a past date, for example a shop before it was deleted: [date:"2024-04-01T00:00:00Z"];node(7815426573);out meta;.
  • What changed between two dates: see changes in an area.

Run it from your code

curl https://api.overpass.ch/v1/YOUR_API_KEY/interpreter \
  --data-urlencode 'data@query.overpassql'

Save the query as query.overpassql. It works the same in Overpass Turbo, QGIS and JOSM.

More examples

All examples →