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

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%


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

permanent link

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

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

permanent link

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

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:

×228

question asked: 30 Aug '22, 08:37

question was seen: 857 times

last updated: 30 Aug '22, 22:03

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