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

select boundaries around ways

0

EDIT: using overpass-turbo

I have been looking for all shop=alcohol in Poland and finding their respective administration boundaries since the addresses are seldom complete.

So far I have this;

[out:json][timeout:3000];

{{geocodeArea:Poland}}->.searchArea;

node[shop="alcohol"](area.searchArea)->.posts;

foreach.posts(
  out;
  is_in;
  area._[admin_level~"[467]"];
  out ids;
);

// collect area details in 2nd step
.posts is_in;
area._[admin_level~"[467]"];
out;

which is almost a direct copy from this post https://help.openstreetmap.org/questions/35976/add-reverse-geocoding-information-to-the-overpass-resulting-set

however I also need to add ways, since many of the shops have been charted that way. Therefore I tried the following;

[out:json][timeout:3000];

{{geocodeArea:Poland}}->.searchArea;

node[shop="alcohol"](area.searchArea)->.posts;
way[shop="alcohol"](area.searchArea)->.posts;

foreach.posts(
  out;
  is_in;
  area._[admin_level~"[467]"];
  out ids;
);

// collect area details in 2nd step
.posts is_in;
area._[admin_level~"[467]"];
out;

However this bugs out and the auto help, well...doesn't.

Anyone?

Thanks in advance;

asked 11 Aug '16, 15:25

scass's gravatar image

scass
21337
accept rate: 0%

edited 11 Aug '16, 15:41


One Answer:

2

There are basically two issues in your second query:

  1. Inputset union is needed to store all nodes and ways in .posts
  2. is_in; does only work on nodes, that's why an additional recursion step is needed as well to turn ways into their respective nodes - namely (._;>;); and (.posts;>;); in the query below.

Here's how the query should look like:

[out:json][timeout:3000];

{{geocodeArea:Poland}}->.searchArea;

(node[shop="alcohol"](area.searchArea);
 way[shop="alcohol"](area.searchArea);)->.posts;

foreach.posts(
  out center;
  (._;>;);
  is_in;
  area._[admin_level~"[467]"];
  out ids;
);

// collect area details in 2nd step
(.posts;>;);
is_in;
area._[admin_level~"[467]"];
out;

answered 11 Aug '16, 15:52

mmd's gravatar image

mmd
5.7k15388
accept rate: 37%

edited 11 Aug '16, 15:55

this appears to work perfectly, i'm going to have to read into recursion syntax.

Thanks for your help

(11 Aug '16, 15:58) scass

Source code available on GitHub .