This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

Overpass query number of objects touched by user

2

Is it possible to build a query that just returns the number of objects of a certain type in a certain area? Possible use case: define some things that require local knowledge, run query, get a toplist of people who have been working on those things. Find local mappers! (you could even query only things that are at version 1 to have higher probability that it's original mapping) I didn't get further than this: http://overpass-turbo.eu/s/B12

Also: is this much heavier for the servers than running the query and doing the counting client-side?

asked 13 Aug '18, 14:33

joost%20schouppe's gravatar image

joost schouppe
3.4k245087
accept rate: 12%

1

It may be possible with some of the newer features. You can see similar queries (in that they group a result set and do some statistics on it) described at https://dev.overpass-api.de/blog/sliced_time_and_space.html.

I'm not certain it is possible to get the new for block to loop over users though.

(14 Aug '18, 11:30) maxerickson

That's going to be at least an interesting read. Thanks! (I'll report back here if I make progress)

(14 Aug '18, 11:37) joost schouppe

One Answer:

4

So the for loop does work on user:

[out:csv(user,total,nodes,ways,relations)][timeout:25];
{{geocodeArea:Antwerpen}}->.searchArea;
(
  way["building"="hotel"](area.searchArea);
  relation["building"="hotel"](area.searchArea);
  node["tourism"="hotel"](area.searchArea);
  way["tourism"="hotel"](area.searchArea);
  relation["tourism"="hotel"](area.searchArea);
);
for (user()){
    make stat 
     "user"=_.val,
     nodes=count(nodes),
     ways=count(ways),
     relations=count(relations),
     total = count(nodes) + count(ways) + count(relations);
    out;
};

answered 15 Aug '18, 13:31

maxerickson's gravatar image

maxerickson
12.7k1083176
accept rate: 32%

Source code available on GitHub .