hello!
this query to openstreetmap finds you all the outdoor seating options in the twin cities metro after loading on a world map for a second. Let's talk about it!
why
eating outdoors is much safer than eating indoors! and I like to socialize with friends at places where we can eat or drink.
how
here's the query! I'll walk us through the parts of it.
- the first thing that happens is we load the world map and send the query out.
- the "out: xml" part means we could ask for some other types of things but xml puts it on the map so.
- the "timeout:120" part means we give OSM 120 seconds to cough up the data. it's important to not make this too big if you're going to edit the query, or you start eating up their server.
- the rel:(id:xxxxxxxxx) parts are OSM identifiers for the counties. you can find county identifiers by investigating a point on OSM with the question-mark-arrow button.
- I don't know what map_to_area does yet!
- "nwr" means "nodes, ways, or relations" which covers all the kinds of ways people can add the kinds of things we're interested in to the OSM.
- The (area.searchArea) seems to be saying: for the things that are the searchArea, do some stuff. So we don't get results from all over the globe.
- amenity, shop, and craft are all attributes places can have. If there's a type of place I'm not including, tell me so I can add it!
- the first "outdoor seating" asks if the attribute "outdoor seating" exists at all on the place.
- and the second "outdoor seating" is to make sure it's anything other than no. sidewalk, patio, veranda, etc, all valid and I want to map them.
- My friend David has an explanation for "(._;>;)"! This shows up in examples on the Overpass entry on the OSM wiki, but with extra whitespace. The parentheses are a "union statement", meaning they run multiple queries and take the union of their results before putting that in the output set. The semicolons come after each query. "._" is an "item query" that returns the contents of an input set as-is, specifically the default input set, "_". ">" is a "recurse down" query, which follows links from ways and relations in the input sets to nodes and ways, then returns those. Upshot: this is why Prairie Kitchen and Bar at the Hyatt shows up surrounded by column nodes. More generally, this will return more information about any place modeled as a relation, with lots of detailed nodes inside.
I hope this was helpful!
back to the pages folder
back to the main page