1

I have this query for overpass turbo ,

[out:json][timeout:25];
area["ISO3166-1:alpha2"="AM"][admin_level~"2"]->.search;
(way(area.search)[place~"town|city"];
 rel(area.search)[place~"town|city"];
)->.w;
.w map_to_area->.e;
.e out center tags;

This quer returns node like this:

{
  "type": "area",
  "id": 3610255555,
  "tags": {
    "admin_level": "6",
    "boundary": "administrative",
    "name": "Եղեգնաձոր",
    "name:de": "Jeghegnadsor",
    "name:en": "Yeghegnadzor",
    "name:hy": "Եղեգնաձոր",
    "name:it": "Jeghegnadzoras",
    "name:ja": "イェゲグナゾル",
    "name:pl": "Jeghegnadzor",
    "name:ru": "Ехегнадзор",
    "name:uk": "Єгеґнадзор",
    "place": "town",
    "population": "7944",
    "type": "boundary",
    "wikidata": "Q39538",
    "wikipedia": "hy:Եղեգնաձոր"
  }
},

How can I get lat and lng of this area or the center of area ?

1 Answer 1

1

"Areas" is an Overpass API internal artifact, which is not suitable to calculate a center point for. Instead you want to determine the center using out center; for both ways and relations:

[out:json][timeout:25];
area["ISO3166-1:alpha2"="AM"][admin_level~"2"]->.search;
wr(area.search)[place~"^(town|city)$"];
out center;
2
  • but this query will return 2 points on the map, 1 relation and 1 way ibb.co/q1QZS6S @mmd Mar 30 at 16:46
  • That’s totally expected if the same town has been mapped as both way and relation. It’s a data issue. You need to deal with this in your post processing step.
    – mmd
    Mar 31 at 4:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.