I'd like to find ways that are members of more than one type=multipolygon relation with role "outer" with Overpass API as this often indicates errors/problems. I'm not sure how to approach this correctly. This is how far I got:

relation({{bbox}})
  [type=multipolygon];
way(r:"outer");
rel(bw:"outer")(if:count(relations) > 1);
(._;>;);

out;

I start with multipolygon relations, look for their outer ways and try to find those ways parent relations where they have the role outer and look if there are more than one.

Alternatively I could also start with ways, but I thought it might be good to restrict the input set more:

way({{bbox}});
rel(bw:"outer")(if:count(relations) > 1);
(._;>;);

out;

I was not able to find any results and once I got an out of memory error. Is this somehow correct what I'm trying to do? Is this even possible with Overpass API?

asked 12 Mar '17, 21:35

nebulon42's gravatar image

nebulon42
16112
accept rate: 0%

edited 12 Mar '17, 21:36

If a way is on the shared boundary between adjoining multipolygons, wouldn't it correctly be an "outer" for both? It seems to me that this would be a common and very much correct situation, so I wouldn't say that it would "often indicate errors/problems".

(13 Mar '17, 17:09) alester

Good point. I missed that. What I meant is that a closed way that is in more than one multipolygon with role outer would indicate a potential problem. For a non-closed way this would indeed be a valid and maybe common situation.

(13 Mar '17, 21:22) nebulon42

I'm not sure it is the best way to do it, but one way to find them is to use a foreach statement to look through the relations one by one:

relation({{bbox}})[type=multipolygon]->.multis;
foreach.multis->.multi(
  // calculate outer ways of other multipolygons
  (.multis - .multi)->.others;
  way(r.others:"outer")->.otherways;
  // outer ways of current multi
  way(r.multi:"outer")->.multiways;
  // output ways in both sets
  way.multiways.otherways;
  out geom;
  );

http://overpass-turbo.eu/s/nsO

A slightly adjusted query eliminates the duplicates by collecting the found ways together in a set before outputting them:

relation({{bbox}})[type=multipolygon]->.multis;
foreach.multis->.multi(
  // calculate outer ways of other multipolygons
  (.multis - .multi)->.others;
  way(r.others:"outer")->.otherways;
  // outer ways of current multi
  way(r.multi:"outer")->.multiways;
  // collect found ways for output
  (way.multiways.otherways;.all;)->.all;
);
.all out geom;

http://overpass-turbo.eu/s/nsW

permanent link

answered 13 Mar '17, 15:57

maxerickson's gravatar image

maxerickson
11.0k1075155
accept rate: 30%

Thanks, it clearly works, so I accepted it as answer. But as alester has pointed out above I haven't formulated the problem well.

(13 Mar '17, 21:39) nebulon42

I am not good with Overpass, but could write a little program to extract them from a planet file, if you are not getting any answers here. Just open an issue on https://github.com/osmlab/fixing-polygons-in-osm .

permanent link

answered 13 Mar '17, 10:34

Jochen%20Topf's gravatar image

Jochen Topf
4.4k54664
accept rate: 34%

Thanks for the offer! This would be a possibility, but Overpass API has the advantage of minutely diffs that I can't easily setup for myself. This allows for some agile clean-up.

(13 Mar '17, 21:25) nebulon42
Your answer
toggle preview

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:

×355
×190
×108
×6

question asked: 12 Mar '17, 21:35

question was seen: 1,581 times

last updated: 13 Mar '17, 21:39

powered by OSQA