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
01 - Finding nodes with a bounding box
This query selects all of nodes that are within a bounding box.
A bounding box is a rectangle that defines a geographic area. In OverpassQL a bounding box is defined by four values. The first two define the south-west corner of the box. The second pair defines its north east corner.
There are two main ways to define a bounding box within an OverpassQL query.
This example defines a bounding box that applies to the whole query. This is achieved using
a query setting called "bbox
".
Query settings provide a way to control how the entire query runs. Query settings appear
at the start of a query and are defined with square brackets: []
.
Here we're using the bbox
setting. As we'll see later, other settings let us
choose different output formats and tweak timeouts.
In the bbox
setting we're providing the coordinates for a bounding box.
These particular coordinates (25.38653, 130.99883, -25.31478, 131.08938
) define a rectangle that
includes Uluṟu. The sandstone monolith in Uluṟu-Kata Tjuta National Park, Australia.
The second way to define a bounding box is as a parameter to a statement.
To test this out, run the query in Overpass Turbo, then follow the instructions in the TRYME #1
comment to see that the bounding box is applied.
If you define a bounding box using a fixed set of points, then the query will only ever use that geographic area. But sometimes you want to run a query over whatever section of the map you're currently looking at.
The Overpass Turbo IDE provides a third way to define a bounding box. But automatically
inserting the coordinates for the current map view into your query.
This is specified by including the "{{box}}
" shortcut instead of the coordinates. Overpass Turbo will then adjust
your query before its run.
This won't happen if you submit a query directly to the API. Its only a feature of the IDE. But helpful when you're writing queries interactively.
When should you use the different variations?
- if you're using the same bounding box across your query, use a query setting. It makes the query more readable
- if you need to apply a bounding box to a single statement, then define it as a filter
- if you're writing a query intended to be used interactively within Overpass Turbo then use
{{bbox}}
- if you're querying the API directly, always submit queries using specific coordinates.
{{bbox}}
won't work
Source File | 01-nodes.osm |
Authors |
|