NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

I am trying to write a query that will return all pubs and bars around a certain point. I'm having issues with the results that are ways. At the moment I am getting all the nodes for the way and then using some post processing to match up the first node of the way to the node lat/long data. Obviously, this is largely inefficient. This is the query I'm currently using. Many thanks.

[out:json]; (node[amenity=pub](around:5000,51.5152117,-0.144044); foreach(out;) way[amenity=pub](around:5000,51.5152117,-0.144044); foreach( out; node(w); out; ); node[amenity=bar](around:5000,51.5152117,-0.144044); foreach(out;) way[amenity=bar](around:5000,51.5152117,-0.144044); foreach( out; node(w); out;);); (._;%3E;)

asked 29 Sep '18, 23:26

adam__'s gravatar image

accept rate: 0%

Each way lists it's member nodes, so in your post processing you can build a mapping of node ids to nodes and use that to retrieve a way node, you don't need to order the output. So a query like should work.


You might also be interested in out center; which converts ways to a node at the center of the bounding box of the way (or relation).

permanent link

answered 30 Sep '18, 04:30

maxerickson's gravatar image

accept rate: 32%

out center is exactly what I'm after. My final query is since I don't need individual lat/lon of the ways nodes

(30 Sep '18, 12:10) adam__

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]( "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: 29 Sep '18, 23:26

question was seen: 1,717 times

last updated: 30 Sep '18, 12:10

NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum