I am trying to use the Overpass Api with a python script to count the number of schools (and later other points of interest) for some area given as bounding box. An example-query looks like this:

(48.58130844439305, 7.7423333727212675, 48.58435427306268, 7.7487015006498146);
(48.58130844439305, 7.7423333727212675, 48.58435427306268,  7.7487015006498146);
(48.58130844439305, 7.7423333727212675, 48.58435427306268, 7.7487015006498146);

Using overpass-turbo, I verified that there are two schools in the specified area. What I need now is an automated way to extract that number. I found an example to get counts as output (here), but this only counts nodes/way/rels, and not "entities" I am interested in. The XML I get for above query contains 31 nodes and 1 way. I thought about getting the base XML and count the number of "name"-tags as this seem to result in the number I need.

And here are my questions:

  1. Is counting "name"-tags a sure way to get what I want, or will there be some examples where it won't work?
  2. Is there any built-in way to get what I want? I would honestly be surprised if there is no faster/easier method.

closed as too broad by aldo_tapia, PolyGeo May 10 '18 at 13:23

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Counting name tags won't work for schools where the name hasn't been specified. Counting amenity=school tags is a better approach. – scai May 8 '18 at 7:42
  • Overpass API can only count the real OSM objects, such as nodes, ways, and relations, as you have already seen on the wiki page (using out count). Your question is rather unclear, as you didn't define at all what you consider to be an "entity". – mmd May 8 '18 at 8:12
  • can you post your full script? – ziggy May 8 '18 at 12:20
  • As per the Tour there should be only one question asked per question. – PolyGeo May 10 '18 at 13:24
  1. Counting name tags is not a sure way instead counties the amenity tag is a sure way, as some entities may not have a name but they will surely have the amenity tag
  2. I don't know of any built-in way but the output can be converted to geojson or any other format. in that format, the count can be easily counted.
  • Hmm.. How does converting to geojson help here? It won't magically merge some close by objects into a single "entity" (whatever the definition of an "entity" is in this case). – mmd May 8 '18 at 18:37

Not the answer you're looking for? Browse other questions tagged or ask your own question.