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

2
2

If you use overpass turbo, you can click on a node that is a part of your query and it will take you to a new window for that node. There, you can see if the node is "part of" a way. Is there any way to get this information from a standard overpass api query?

asked 06 Nov '19, 19:45

John%20Anthony%20Anthony's gravatar image

John Anthony...
51115
accept rate: 0%


Yes, please use way(bn).

A simple example. We have queried for all the barriers in Watford near London:

area[name="Watford"];
node[barrier](area)(51.5,-1,52,0);
out;

The query finds 84 or so.

Now we replace the output in line 3 by a couple of extra lines:

area[name="Watford"];
node[barrier](area)(51.5,-1,52,0);
way(bn)->.wy;
node._(w.wy);
out;

In detail: way(bn)->.wy queries for all the ways that have the just found nodes as members node._(w.wy) is composed of the two conditions that the node must be from the previous result (in this case line 2, since line 3 writes to elsewhere) and that it must be a node referenced by a just found way (from set wy, filled in line 3)

Thus we see only those nodes that are member of a way.

Further conditions on the interesting way can be injected in line 3:

area[name="Watford"];
node[barrier](area)(51.5,-1,52,0);
way(bn)[highway=cycleway]->.wy;
node._(w.wy);
out;

Now the ways that our nodes of interest must be members of are restricted to those with the tag highway=cycleway.

It gets more tricky for the related question: What are the nodes of a way that are also connected to other ways? As an example, the query for the street named Hyde Vale ...

( way[name="Hyde Vale"];
  node(w); );
out;

... becomes:

( way[name="Hyde Vale"]->.ways_to_exclude;
  node(w.ways_to_exclude)->.nodes_of_interest; );
( way(bn.nodes_of_interest)->.all_wy; - .ways_to_exclude; );
node.nodes_of_interest(w);
out geom;

We divert this time already the ways of initial interest through a named set ways_to_exclude because we need them again to remove them from the list of eligible ways. Other than that, lines 3 and 4 do the exercse to walk from the nodes to the ways and back to their nodes; and line 4 ensures that we only consider nodes that we had found already. But to avoid that all nodes qualify by being part of the street Hyde Vale (and potentially no other way) we explicitly remove these ways with the difference statement in line 3.

permanent link

answered 07 Nov '19, 12:33

Roland%20Olbricht's gravatar image

Roland Olbricht
6.7k36489
accept rate: 36%

So lets say this is my query:

[out:json]; node({}); way(bn)->.wy; node._(w.wy); out;

** {} is where a bounding box would go

Say one of the nodes that is returned is the node with id=4271787600. I can see from overpass turbo that that node is part of the way the Metropolitan Apartments. However, this query does not return me a way with name "The Metropolitan Apartments". How can I adjust the query so that I can get that information.

For context, I am looking to be able to query a bounding box and get names of all the buildings and streets that are found in that bounding box (all names that openstreetmap has at least).

(13 Nov '19, 22:28) John Anthony...

way({{bbox}}) gives you all ways in the bounding box. The query

[out:json];
way({{bbox}})[building][name];
for (t["name"])
{
  make building name=_.val,ids=set(id());
  out;
}
way({{bbox}})[highway][name];
for (t["name"])
{
  make highway name=_.val,ids=set(id());
  out;
}

returns all names of buildings and highways in the bounding box.

(14 Nov '19, 03:53) Roland Olbricht

Take a look at the recurse filters. There's also an operator, <, that will find all parents of the input set.

permanent link

answered 07 Nov '19, 11:36

maxerickson's gravatar image

maxerickson
12.7k1083176
accept rate: 32%

edited 07 Nov '19, 11:37

permanent link

answered 07 Nov '19, 11:48

DaveF's gravatar image

DaveF
3.3k8498133
accept rate: 16%

Follow this question

By Email:

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

By RSS:

Answers

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:

×483
×228
×147
×92
×91

question asked: 06 Nov '19, 19:45

question was seen: 4,821 times

last updated: 14 Nov '19, 03:53

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