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
03 - Filtering nodes that have a tag
This query demonstrates how to filter nodes based on their tags.
This is a useful and important feature. You'll be using it a lot in your queries.
Tags in OpenStreetMap are used to attach information to nodes, ways and relations. There is an ever growing list of tags used to capture different types of data.
Often, when we're querying the database we're not interested in all of the nodes (or ways or relations) in an area. Just those tagged as a specific type.
We can specify filters in our Overpass QL queries to restrict the results to just those features that have specific tags and values.
Tag filters as defined within square brackets ([]
). This query adds a filter to
the node
statement:
node["name"]
This limits the set of returned nodes to those that have a name
tag, regardless
of its value.
As we saw in the previous example, many nodes in the OpenStreetMap data are there to help define larger geospatial features. They aren't all individually points of interest. So they don't typically have any tags attached to them.
When you run this query you'll see that there are now only around 30 nodes returned compared to the 4,000 or so returned in the previous examples.
OpenStreetMap is a multilingual map. And some tags, like names, might have values in several different languages.
The OSM data model doesn't allow tags to have multiple values, e.g. one per language. Instead we use multiple tags, which are qualified by a language code.
For example, if we wanted to find nodes that have a name in Pitjantjatjara, which is
the dialect spoken by the people that live around Uluṟu, then we would instead
filter for a tag called name:pjt
.
Who gets to decide what goes in the default name
tag? That's something for
local mappers to discuss and agree on. See the links below for more information.
Links | |
Source File | 03-nodes-basic-filter.osm |
Authors |
|