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

How can I hide objects in output in Overpass Turbo?

0

I am querying objects with Overpass Turbo, which are restricted to a specific area.
I restrict the query via a relation, in this case a city boundary. Then I map them to the area to query via map_to_area

My problem is that the output always contains the relation itself, but I don't need it. It also is displayed on top of all nodes, so that I cannot see the nodes and ways in overpass turbo, but only the relation (see screenshot below).

Can I somehow suppress the relation in the output (both the map and the JSON)?

Here's my example. I would like to just have the nodes and ways.

[out:json][timeout:25]; ( {{plz=40589}} rel[postal_code="{{plz}}"]; map_to_area; node["power"="generator"]["generator:method"="photovoltaic"](area); way["power"="generator"]["generator:method"="photovoltaic"](area); ); (._;>;); out body; out count;

Screenshot of Overpass Turbo's map view with a relation shown as area, which hides all nodes and ways which are also in the output. in the bottom right corner, it says "loaded Nodes: 424, ways: 24, relations: 1, areas 1"

asked 30 Aug '22, 08:37

guerda's gravatar image

guerda
6113
accept rate: 0%


2 Answers:

1

First off - there are no power generators in the area you're searching.

https://overpass-turbo.eu/s/1ltI

So let's use an adjacent post code.

The problem was the inclusion of the area inside the union using curved brackets:

rel[postal_code=40599];map_to_area;
(
 node[power=generator]["generator:method"=photovoltaic](area);
  way[power=generator]["generator:method"=photovoltaic](area);
);
(._;>;);
out body;
out count;

However these can be removed entirely by amalgamating the objects to search for (nw):

rel[postal_code=40599];map_to_area;
nw[power=generator]["generator:method"=photovoltaic](area);
(._;>;);
out body;
out count;

https://overpass-turbo.eu/s/1ltK

answered 30 Aug '22, 11:27

DaveF's gravatar image

DaveF
3.3k8498133
accept rate: 16%

edited 30 Aug '22, 11:41

It looks like your solution works. My original code seems not to work indeed. Thank you for that!

(30 Aug '22, 17:18) guerda

As soon as I use variables, my queries return different results, interesting.

(30 Aug '22, 17:20) guerda

Show us the code.

(30 Aug '22, 22:03) DaveF

2

Just remove the relation from the output set:

[out:json][timeout:25];

  {{plz=40599}}
  rel[postal_code="{{plz}}"];
  map_to_area;
(
  node["power"="generator"]["generator:method"="photovoltaic"](area);
  way["power"="generator"]["generator:method"="photovoltaic"](area);
);
(._;>;);
out body;
out count;

The parentheses are interpreted as the "union" operator: https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#Union

answered 30 Aug '22, 11:06

MarcoR's gravatar image

MarcoR
6873820
accept rate: 23%

Thanks! I thought it would be the solution. It seems that with other postcode it does not work at all. 40667 contains ~20 generators, but it does not return any with your code. That is odd. Any idea? https://overpass-turbo.eu/s/1lum

(30 Aug '22, 17:14) guerda

Source code available on GitHub .