Talk:Overpass API/Overpass API by Example
Problem with Fire Station example example
- I've tried the Overpass_API_by_Example#Counties_without_fire_station Counties without fire station example, and it raises a warning in the last substraction:
(.all_level_8_areas - .level_8_areas_with_firestation);
- Parse error: ";" expected, "-" found.
--Josemoya (talk) 12:05, 25 July 2018 (UTC)
Thanks for the report, I just fixed this issue. Mmd (talk) 12:16, 25 July 2018 (UTC)
Musem Data
Presumably "Museum Data" is nothing to do with museums? Does it just mean "data at a previous point in time"? If so, I'd suggest changing the text to say that.
How does this correspond to "attic data" (a term, presumably made up by overpass, that I've heard elsewhere)?
SomeoneElse (talk) 10:42, 1 June 2019 (UTC)
- The term attic data can also be found in some quite dated version control systems, notably CVS (see https://stackoverflow.com/questions/15923592/restoring-cvs-module-from-attic). "Museum data" and "Attic data" are just synonyms. Mmd (talk) 10:55, 1 June 2019 (UTC)
Query for relations which contains double/identical ways
Is it currently possible to search for relations (e.g. type=route) and show only relations where the mapper added (maybe by mistake) a identical way(-id) as member twice (member role doesn't matter)? If so, how it would look like?--MalgiK (talk) 07:19, 8 November 2019 (UTC)
- This query finds relations with any duplicate members, not only ways. Click on the steering-wheel icon on the right to show a real-world non-error example:
rel({{bbox}})(if: count_members() != count_distinct_members()); out geom;
- --Zstadler (talk) 13:58, 22 June 2020 (UTC)
Readability and performance enhancement suggestion
The "Find wikidata relations having identical wikidata way members" example uses a set named .all for all members with a wikidata tag of all relations. If I understand the goal of this query, it would be simpler to understand and faster to execute if the search is done using the members of each relation separately.
My proposed revision, with my comments enclosed within /* ... */ is:
rel[wikidata]({{bbox}}); // get all relations with wikidata tag in current bounding box
/*
* Avoid this query
*
*/
// way(r)[wikidata]->.all; // get all way members with wikidata tag
foreach -> .rel( // process each relation one by one
// find out all way members where the wikidata tag matches the relation's wikidata tag
/*
* Replace the use of the .all set with a tag filter on the relation's members
*
*/
// way.all(r.rel)(if: t["wikidata"] == rel.u(t["wikidata"]))->.ways;
way[wikidata](r.rel)(if: t["wikidata"] == rel.u(t["wikidata"]))->.ways;
// if any way members could be found, print the current relation first...
rel.rel(if:ways.count(ways) > 0);
out center;
// ... followed by all ways with a matching wikidata tag
.ways out tags;
);
--Zstadler (talk) 12:24, 22 June 2020 (UTC)
Filter by value and not key
Is it possible to filter objects tagged with a value but NOT with this key? For example, all objects with key != "website" but value ~ "www." --Pa 1919 (talk) 20:53, 21 October 2023 (UTC)
- Hi Pa 1919, hope I understood correctly your question. I tested my query on real data. That's why I removed/filtered many keys that contains www (facebook, etc).
[out:json]; area["ref:INSEE"="97411"]->.searchArea; nw[~"."~"www",i](area.searchArea)->.withWww; ( nw.withWww[website~"www",i]; nw.withWww["contact:website"~"www",i]; nw.withWww["image"~"www",i]; nw.withWww["brand:website"~"www",i]; nw.withWww["facebook"~"www",i]; nw.withWww["contact:facebook"~"www",i]; nw.withWww["heritage:website"~"www",i]; nw.withWww["contact:instagram"~"www",i]; nw.withWww["operator:website"~"www",i]; ) -> .toRemove; ( nw.withWww; - nw.toRemove; ); out geom;
- --Binnette (talk) 17:59, 22 October 2023 (UTC)
- Thank you! That's exactly it. I was trying to find a way to find all the incorrect keys associated with urls such as "internet_access=www...." used instead of "website=" or "contact:website=".
- If I understand correctly you need to collect all the data and then remove the unwanted data. Wouldn't it be easier to have a simple tag request that would look like:
- [!"key"="value"] /* filter objects tagged with this value but not this key*/ (model from: https://wiki.openstreetmap.org/wiki/Overpass_API/Language_Guide#Tag_request_clauses_(or_%22tag_filters%22))--Pa 1919 (talk) 10:14, 23 October 2023 (UTC)