How do I determine if an administrative boundary has multiple polygons?

I’ve tried quite a few different queries now to get boundary geometry data for administrative areas such as counties, townships, cities, towns, villages, hamlets, neighborhoods, etc. None of the queries I’ve tried so far seem to have the “ways” or geometry items grouped together by polygon, or else I’m misunderstanding the data I’m getting back.

My use case is that I need to store this data in a database in such a way that I can use it to detect what county or other administrative area a given set of coordinates is inside of and in order to do this I’m under the assumption that I need to be storing my data in the correct field type, either polygon or multipolygon.

It seems like the data comes back from the API without anything specifying whether it’s multiple polygons or not.

The queries I’ve been using are shown below, neither of which are giving me satisfactory results.

  [out:json];
  area["ISO3166-2"="US-ME"]->.state;
  (
    rel(area.state)["type"="boundary"]["admin_level"="8"];
  );
  convert item ::=::,::geom=geom(),_osm_type=type();
  out geom qt;


  [out:json];
  area["ISO3166-2"="US-ME"]->.state;
  (
    rel(area.state)["type"="boundary"]["admin_level"="8"];
  );
  out geom qt;

1 post - 1 participant

Read full topic


Ce sujet de discussion accompagne la publication sur https://community.openstreetmap.org/t/how-do-i-determine-if-an-administrative-boundary-has-multiple-polygons/107857