Detect names on outer ways of a multipolygon

Hi, it is my understanding that the name of multipolygon or boundary relations should go on the relation and the ways of the rings should remain unnamed generally in most circumstances. Is there a way to detect for names on the rings so I can check if they need attention?

Edit: Thanks TheSwavu and Lumikeiju for the solutions

1 Like
[out:json][timeout:900];
area["ISO3166-1"="AU"]->.a;
rel(area.a)["name"]["type"~"^(multipolygon|boundary)$"];
foreach->.this(
  way(r.this)["name"](if: t["name"] == this.u(t["name"]));
    foreach(
    out center;
    );
  );
1 Like

A basic approach is to simply query Overpass for ways with the name key that are children of relations in a search area that have the type=boundary or type=multipolygon tags:

(Overpass Turbo link)

[out:xml][timeout:120];

// Define your search area (replace "Seattle" with the location you want to search in)
{{geocodeArea:Seattle}}->.searchArea;

// Find relations in the search area that are tagged "type=boundary" or "type=multipolygon"
rel(area.searchArea)["type"~"boundary|multipolygon"];

// Find ways that are children of these relations have the key "name"
way(r)["name"];

(._;>;); out meta;

However, you’ll get a lot of false positives. So, I’d filter out the ways that are also "inner"s:

(Overpass Turbo link)

[out:xml][timeout:120];

// Define your search area (replace "Seattle" with the location you want to search in)
{{geocodeArea:Seattle}}->.searchArea;

// Find relations in the search area that are tagged "type=boundary" or "type=multipolygon"
// Save them in a new set called "allRelations"
rel(area.searchArea)["type"~"boundary|multipolygon"]->.allRelations;

// Find ways that are children of relations in the "allRelations" set and have the role "inner"
// Save them in a new set called "inners"
way(r.allRelations:"inner")->.inners;

// Find ways that are children of relations in the "allRelations" set and have the key "name"
// Save them in a new set called "namedWays"
way(r.allRelations)["name"]->.namedWays;

// Subtract the ways in the "inners" set from the ways in the "namedWays" set
(way.namedWays; - way.inners;);

(._;>;); out meta;

Still not perfect (you could filter so that only the "inner"s with only a single parent relation are subtracted, for example) but usable!