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 |
You can use the make statement to create your own count elements:
For further information: https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#The_statement_make See also this example answered 06 Feb '21, 09:37 MarcoR @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: [out:json][timeout:60]; 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
1
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
|