Limiting a complex query to an area

Hello, I am trying to limit a query to, say, Germany:

[out:json];
{{geocodeArea:Deutschland}};
// Find objects tagged "megalith" using the tag "site_type" OR "archaeological_site"
(
  nwr["site_type"="megalith"](area);
  nwr["archaeological_site"="megalith"](area);
);
out body;
>;
out skel qt;

This query though seems to ignore the second line in the union statement, nwr["archaeological_site"="megalith"](area);
Same if I flip the first and second line.

What is going on? And how can I achieve this?

Check out the following questions:

2 Likes

I’ve just used the Wizard to create this query and it seems to work:

/*
This has been generated by the overpass-turbo wizard.
The original search was:
“archaeological_site=megalith or site_type=megalith in Deutschland”
*/
[out:json][timeout:2500];
// fetch area “Deutschland” to search in
{{geocodeArea:Deutschland}}->.searchArea;
// gather results
(
  // query part for: “archaeological_site=megalith”
  node["archaeological_site"="megalith"](area.searchArea);
  way["archaeological_site"="megalith"](area.searchArea);
  relation["archaeological_site"="megalith"](area.searchArea);
  // query part for: “site_type=megalith”
  node["site_type"="megalith"](area.searchArea);
  way["site_type"="megalith"](area.searchArea);
  relation["site_type"="megalith"](area.searchArea);
);
// print results
out body;
>;
out skel qt;

Link: overpass turbo

2 Likes

Thanks! So, in a nutshell:
In Overpass Turbo, the area needs to be stored in a named inputset. Otherwise, the result of the first statement will overwrite the area in the default inputset ._, and will no longer be available for the next query, I learn.

So, this works:

[out:json];
{{geocodeArea:Deutschland}}->.searchArea;
(
  nwr["site_type"="megalith"](area.searchArea);
  nwr["archaeological_site"="megalith"](area.searchArea);
);
out body;
>;
out skel qt;
4 Likes