This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

Proximity search - node with tag1 near node with tag2

4
3

Is there a way to search for a node situated within a given distance from at least one other node with a given tag?

Applications:

asked 12 May '14, 03:05

dandv's gravatar image

dandv
40131114
accept rate: 0%

edited 12 May '14, 03:17

Uh, those examples are ...

(12 May '14, 07:56) scai ♦

One Answer:

5

Thankfully, the Overpass API supports an around operator. One needs to be careful with queries that return many nodes, and the query likely to return the fewest nodes should be first. Bounding boxes help.

Here's an example for the second query:

<query type="node">
  <has-kv k="amenity" v="brothel"/>
  <bbox-query {{bbox}}/>
</query>
<query type="node">
  <around radius="1000"/>
  <has-kv k="amenity" v="police"/>
</query>

<print/>

You can see it live for Berlin:

alt text

answered 12 May '14, 05:04

dandv's gravatar image

dandv
40131114
accept rate: 0%

Source code available on GitHub .