Why not ask your question on the new OpenStreetMap Community Forum?

I have the follow Overpass Turbo query, and I would count number of NWR per each of the input sets. That is: 1) number of NWR for Trader Joe's 2) number of NWR for Safeway I tried many times, and still not sure how to make it, can someone help please? [out:json][timeout:60]; (nwrbrand="Trader Joe's";)->.TJ; (nwrbrand="Safeway";)->.SW; (.TJ; .SW;); out skel center count;

asked 06 Feb '21, 07:53

steve_nonego's gravatar image

accept rate: 0%

You can use the make statement to create your own count elements:

nwr[brand="Trader Joe's"];

make count brand = set(t["brand"]), 
           total = count(nwr);


make count brand = set(t["brand"]), 
           total = count(nwr);

For further information: https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#The_statement_make

See also this example

permanent link

answered 06 Feb '21, 09:37

MarcoR's gravatar image

accept rate: 25%

@MarcoR Thanks for you solution, it does what I expected!

I look up the links you recommend, yet I still not fully understand the query. Can you help me to understand the following?

For: nwrbrand="Trader Joe's";

make count brand = set(t["brand"]), total = count(nwr); out;

1) We didn't give the nwr[] a input set name, so it's automatically assume the set( ) is refer to the one above?

2) I look up the examples, it also use t["xxxx"], what is the t refer to? tag?

Last but not least, I slightly modified the query as:


nwrbrand="Trader Joe's"; make count category = set("Number of Trader's"), total = count(nwr); out;

nwrbrand="Safeway"; make count brand = set("Number of Safeway"), total = count(nwr); out;

(07 Feb '21, 19:33) steve_nonego

You are welcome ;)

1) The input set, if not specified, is the default one: _; as far as I undestand, nwr[…], doesn't have an input set as all it does is searching data in the map database, but it has an output set, which is _; this set is used as input set by the following command (make …); the next nwr[…] overwrites the default set with the new results so that the following 'make' statament can calculate the proper results;

2) t["xxx"] returns the value of the tag "xxx"; see https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#Tag_Value_and_Generic_Value_Operators

Hope this helps!

(08 Feb '21, 09:38) MarcoR
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 06 Feb '21, 07:53

question was seen: 733 times

last updated: 08 Feb '21, 09:39

powered by OSQA