3

I get regions with landuse=industrial with this query

[out:json];
area["name"="my_area"]->.searchArea;
(
  way["landuse"="industrial"](area.searchArea);
  relation["landuse"="industrial"](area.searchArea);
);
out body;
>;
out skel qt;

now i am trying to get the building in that area. (all buildings no matter the tags)

[out:json];
area["name"="my_area"]->.searchArea;
(
  way["landuse"="industrial"](area.searchArea)["building"];
  relation["landuse"="industrial"](area.searchArea)["building"];
);
out body;
>;
out skel qt;

but this does only return buildings that have the tag "landuse"="industrial"? I want all buildings with the general area has "landuse"="industrial". (buildings can have any tags)

2 Answers 2

1

The correct solution is a bit more involved, because you need to convert relations explicitly into an internal representation called area (this happens implicitly for ways).

// fetch both ways and relations with landuse=industrial in your current bbox
wr["landuse"="industrial"]({{bbox}});

// visualize landuse=industrial ways and relations for debugging purposes
out geom;

// explicitly convert relation to area, also include ways in search area
map_to_area -> .searchArea;

// query for buildings inside search area
nwr["building"](area.searchArea);

// and print results
out body;
>;
out skel qt;

Note: the query uses the shorter version "wr" for ways & relations, as well as "nwr" for nodes, ways & relations to avoid some extra typing.

Check out this overpass turbo link for an example: https://overpass-turbo.eu/s/1tzE

Sample screenshot highlighting buildings both inside landuse=industrial ways and relations:

enter image description here

0

You need to save the search area and then do a second query part on the search area. This seems to work, using the bounding-box of the overpass-turbo web site - you may need to change this to your initial area search area.

[out:json][timeout:25];
// gather results
(
  // query part for: “landuse=industrial”
  node["landuse"="industrial"]({{bbox}});
  way["landuse"="industrial"]({{bbox}});
  relation["landuse"="industrial"]({{bbox}});
) -> .searchArea;
// print results
( 
  way["building"](area.searchArea); 
  node["building"](area.searchArea); 
  relation["building"](area.searchArea); 
);
out body;
>;
out skel qt;

For a local industrial area near me I get:

enter image description here

And you can see it is returning buildings, but not the houses in the bounding box (which are also tagged as buildings).

The query for the industrial area alone returns this:

enter image description here

The query text for that being:

[out:json][timeout:25];
// gather results
(
  // query part for: “landuse=industrial”
  node["landuse"="industrial"]({{bbox}});
  way["landuse"="industrial"]({{bbox}});
  relation["landuse"="industrial"]({{bbox}});
) ;
out body;
>;
out skel qt;

All done on http://overpass-turbo.eu/

Confession: I did use ChatGPT to find out how to save the search area and then re-use it, but it took a lot of further crafting to get this solution working. My use of ChatGPT here was no more than using it to find something in a user manual for Overpass. ChatGPT is pretty good at understanding Overpass, which I find very difficult as a human to understand...

3
  • Unfortunately, this doesn't really work, if your landuse=industrial is a relation. Please compare overpass-turbo.eu/s/1tzy (your version) vs. overpass-turbo.eu/s/1tzz (expected results). Combining ways and relations in one query then gives the expected result for both ways and relations: overpass-turbo.eu/s/1tzB
    – mmd
    Commented Apr 10, 2023 at 20:18
  • Why doesn't it work if landuse=industrial is a relation, although I've got relation["landuse"="industrial"]({{bbox}}) in the first part of the query that then creates the -> .searchArea?
    – Spacedman
    Commented Apr 11, 2023 at 8:41
  • 1
    Short answer: it hasn't been implemented yet as of today. Long answer: Relations still require an upfront mapping to an "area" (something Overpass API internal, that has been pre-calculated on the server according to predefined area creation rules). So if you put the relation in the ".searchArea" without the additional "map_to_area" step, you won't get any results.
    – mmd
    Commented Apr 11, 2023 at 11:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.