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

Overpass query to find multipolygon relations with just one member

0
1

Hi

I hacked at this OverPass Wiki example to find multi-polygon relations with just one member. The resulting routine seems to work but looks like it is running unnecessary steps. I've run out of knowledge. Is there anything I can do to tidy it up & make it run more efficiently?

rel({{bbox}})[type=multipolygon]->.relations;
foreach .relations -> .relation (
  (
   way(r.relation);
  )->.elem_all;

  rel.relation( if:elem_all.count(ways) == 1 );
  out geom;
);

OverpassTurbo Link

asked 19 Mar '18, 21:13

DaveF's gravatar image

DaveF
3.3k8498133
accept rate: 16%


One Answer:

5

There's a count_members evaluator that looks inside of each individual relation:

[bbox:{{bbox}}];
rel[type=multipolygon](if:count_members() == 1);
out geom;

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

answered 20 Mar '18, 00:32

maxerickson's gravatar image

maxerickson
12.7k1083176
accept rate: 32%

Ah, thank you. my Google search 'overpass count' wasn't specific enough to find it.

(20 Mar '18, 14:45) DaveF

Source code available on GitHub .