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

Finding multipolygons with more than one ‘outer’ way. Overpass?

1
1

I'd like to find multipolygons that have more than one member with the role 'outer'.

Is there a way to do that with the Overpass API, or would I have to wait for https://github.com/drolbr/Overpass-API/issues/197 to get written?

Would there be any other way to do this?

asked 10 Dec '16, 01:16

Stereo's gravatar image

Stereo
3562513
accept rate: 11%


2 Answers:

2

If you are willing to put up with a beta quality program I am working on, you can use osmium-filter. It can do a query like that: osmium-filter-simple INPUTFILE -e '@relation and (@members[@role=="outer"] > 1)' -o OUTPUTFILE. It doesn't support giving you all the ways and nodes needed for these relations yet, if you need that, you can use the Osmium tool (to be more exact, osmium getid). Other options include writing your own program using libosmium, PyOsmium, or node-osmium (see http://osmcode.org/).

answered 10 Dec '16, 09:30

Jochen%20Topf's gravatar image

Jochen Topf
5.2k55074
accept rate: 31%

edited 10 Dec '16, 09:34

Thank you Jochen, I'll give that a go!

Would you also happen to have a way of finding old-style multipolygons with it?

(10 Dec '16, 12:56) Stereo
1

Have a look at https://github.com/osmcode/osm-area-tools . There are tools that can find old-style multipolygons. I use that to create the overlay on http://area.jochentopf.com/map/index.html for instance. But you can also just download the old-style mps from http://area.jochentopf.com/ updated daily.

(10 Dec '16, 14:36) Jochen Topf

Wow, osmium-filter is impressively fast! It's an exciting tool, and I hope that you'll find time to document it :).

'@relation and "type"="multipolygon" and (@members[@role=="outer"] > 1)' did the trick.

(10 Dec '16, 14:38) Stereo

2

I ended up doing it in overpass:

[out:xml][timeout:25];
{{geocodeArea:Luxembourg}}->.searchArea;
// gather results
(
  relation["type"="multipolygon"](if: count_by_role("outer") > 1 )(area.searchArea);
  relation["type"="multipolygon"](if: count_members() == 1 )(area.searchArea);

);
// print results
out meta;
>;
out meta qt;

answered 09 May '21, 21:44

Stereo's gravatar image

Stereo
3562513
accept rate: 11%

Source code available on GitHub .