User:Kees 59/Notes Overpass
Overpass turbo
- Main article: Overpass turbo
Wizard
- Main article: Overpass turbo/Wizard
location filter "in" with multiple results possible
There are several places in the Netherlands that share the same name. As a result thereof the results of the "in" filter can result in the wrong place.
Example: Utrecht exists as a 'Provincie', a municipality and a city.
| "size" | admin_level= | OSM id [1] |
|---|---|---|
| Provincie | 4 | relation 47667 |
| Municipality | 8 | relation 419203 |
| City | 10 | relation 1433619 |
Wizard example: tourism=museum in utrecht[2]
Leads to the Overpass query
/*
This has been generated by the overpass-turbo wizard.
The original search was:
“tourism=museum in utrecht”
*/
[out:json][timeout:25];
// fetch area “utrecht” to search in
{{geocodeArea:utrecht}}->.searchArea;
// gather results
nwr["tourism"="museum"](area.searchArea);
// print results
out geom;
Which produces an undefined result. There is no indication which of the 3 utrechts is used.
Searching for solutions, I found the option to filter by element id in Overpas QL (<element>(id)). Where <element> is one of the three OSM element types (node, way or relation) or the Overpass type area and id is a positive integer.
for areas the integer depends on the area being a closed way or a relation:
- closed way: the id is identical to the way id of the closed way
- for relations: the id is (3600000000 + <the relation id>). For the provincie utrecht (id:47667) this would result in
area(3600047667)
Replacing {{geocodeArea:utrecht}} with area(3600047667) leads to the following
[out:json][timeout:240];
// fetch area relation “47667” to search in
area(3600047667)->.searchArea;
// gather results
nwr["tourism"="museum"](area.searchArea);
// print results
out geom;
Substituting the relevant ids for the three "sizes" leads[3] to the following results:
| "size" | area id | loaded | ||
|---|---|---|---|---|
| nodes | ways | relations | ||
| wizard | N/A | 15 | 4 | 4 |
| Provincie | 3600047667 | 74 | 10 | 4 |
| Municipality | 3600419203 | 15 | 4 | 4 |
| City | 3601433619 | 14 | 4 | 4 |
Look like the wizard uses the Municipality.
Externe links
- https://www.google.com/search?client=firefox-b-d&q=limit+overpass+by+relation+id
- https://stackoverflow.com/questions/60749066/use-polygon-as-search-area-overpass-api-overpass-turbo