Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grouping items #395

Closed
mmd-osm opened this issue May 4, 2017 · 3 comments
Closed

Grouping items #395

mmd-osm opened this issue May 4, 2017 · 3 comments

Comments

@mmd-osm
Copy link
Contributor

mmd-osm commented May 4, 2017

I've read this great blog post by @mojodna the other day: https://aws.amazon.com/de/blogs/big-data/querying-openstreetmap-with-amazon-athena/

Case study 3 highlights a GROUP BY use case, where the number of buildings is shown along with the building:condition. Currently, it's only possible to return all buildings via Overpass, without the grouping.

[out:csv("building:condition"; false)]
[bbox:23.6948,90.3907,23.7248,90.4235];
way["building:condition"];
out;

(runtime: 92ms)

Running the result through sort | uniq -c will return the desired result.

So, counting is of course possible. However, identifying each different building condition and counting the objects for each of those conditions doesn't seem to be feasible as of today.

image

Minimal approach:

  • New statement to remove duplicate entries based on a number of given keys, or maybe on some evaluator result (generate derived objects may be another approach)
  • Extend foreach to handle derived objects as well
[bbox:23.6948,90.3907,23.7248,90.4235];
way["building:condition"]->.buildings;
remove_duplicates key = t["building:condition"];    // or something similar, maybe based on evaluators to produce a key?!
foreach -> .distinct_entry;

   way.buildings(if:t["building:condition"] == .distinct_entry..);
   make count key = .key....
              count = ...
     
   out;
);
@mmd-osm
Copy link
Contributor Author

mmd-osm commented Oct 11, 2017

Similar:

Gibt es bereits ein Tool (/eine overpass-Abfrage?) o.ä., alle verwendeten keys/tags für einen bestimmten Bereich (Ort; bbox) sich in einer schlichten Liste nur mit der Zahl ihres Vorkommens anzeigen/'auswerfen' zu lassen?
Etwa nach dem Schema für Berlin:
amenity=drinking_water -> 66x

@tyrasd
Copy link
Contributor

tyrasd commented Mar 19, 2018

looks like this is implemented in 0.7.55: #467 (comment) (second example in "for" section)?

@mmd-osm
Copy link
Contributor Author

mmd-osm commented Mar 29, 2018

looks like this is implemented in 0.7.55:

Yes, exactly, @mojodna's example 3 can be written as follows now:

[out:csv(count, "building:condition"; true)]
[bbox:23.6948,90.3907,23.7248,90.4235];
way[building];
for(t["building:condition"])
{
   make stat "building:condition"=_.val,
             count = count(ways);
   out;
};

Result:

count	building:condition
29500	
4898	average
1785	good
2420	poor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants