Overpass Tutorial
- 00 - The Beginning
- 01 - Finding nodes with a bounding box
- 02 - Outputting data about nodes
- 03 - Filtering nodes that have a tag
- 04 - Find nodes by matching tags and their values
- 05 - Find nodes by applying multiple filters
- 06 - Extracting multiple sets of nodes
- 07 - Calculating differences between results
- 08 - Generating JSON output
- 09 - Generating CSV output
- 10 - The default set
- 11 - Querying a set
- 12 - Searching within a radius using around
- 13 - Using around to filter against a set of results
- 14 - Searching by polygon
- 15 - Finding ways
- 16 - Ways and their nodes
- 17 - Ways and their tags
- 18 - Combining node and way queries
- 19 - Finding ways from their nodes
- 20 - Finding relations
- 21 - Type agnostic queries (nwr)
- 22 - Areas
- 23 - Finding the areas enclosing a feature
- 24 - Find the area derived from a feature
- 25 - Areas via Nominatim search
- 26 - Timeouts and endpoints
00 - The Beginning
The OpenStreetMap data model consists of:
- nodes - single points, e.g a postbox or tree
- ways - a set of connected points, e.g. a path or a building
- relations - a grouping of ways and nodes, e.g. a collection of buildings
When you drill down from relations and ways you always end up with nodes. Nodes are the most basic element of the data model: a point on the map with some data attached to it as tags (name-value pairs).
Our first query is one of the simplest possible OverpassQL queries. It select
the node that has an id
of 1
from the OSM database. It then outputs some
information about that node.
We'll learn more about different ways to query for nodes, ways and relations in other queries.
And we'll also learn how to control what information is extracted and output from the database.
But, for this first query, the main things to note is that a query consists of a series of statements. In this case there are two. Each statement ends with a semi-colon.
The first statement (node(1)
) performs the query.
The second statement (out
) creates the output.
An OverpassQL query is a list of statements that are executed by the API. More complex queries will consist of many more statements of different types. These statements build up sets of results that are then returned to the user.
The Overpass Turbo IDE helpfully displays those results on a map, where it can. But if you use the API directly, e.g. from a script or application, then you can choose to consume and use the data however you like.
To run the query, click the "Run" button. A new window will open containing your results. As you work through this tutorial, you're encouraged to actually run the queries and, where suggested, customise them to explore some of the features of the language.
In case you're wondering node number 1 happens to be a communications tower in Italy. I have no idea why.
One important thing to note is that OpenStreetMap identifiers are not guaranteed to be stable. Someone could come along and delete a node and then it might later be recreated by the same or a different user. The node will end up with a new identifier.
When you use OverpassQL you're likely to be querying information based on their location or metadata, rather than their identifier. Or, if you do, be prepared that the nodes, ways or relations you're fetching might disappear in the future.
Source File | 00-node-1.osm |
Authors |
|