NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

Please note - sorry but I couldn't get the question editor to show my XML so I've had to replace all the '<'s with '[' and all the '>'s with ']' in what follows. If someone knows how to fix this for me please let me know - thanks.

I am building a simple application which, given a worldwide lat/lon, requires details of the nearest city or town, based upon a simple as-the-crow-flies measurement. To achieve this I've chosen to use the OSM nodes which are tagged place='town' or place='city', calculating the spherical distance between my check point and each node's lat/lon. These nodes, according to http://wiki.openstreetmap.org/wiki/Key:place, represent the approximate centre of each town and city and so are ideal for my requirement.

Given my chosen approach, I extracted the data from the Overpass API, using the following requests:

curl http://www.overpass-api.de/api/xapi?node[place=city] -g -o worldcities.osm
curl http://www.overpass-api.de/api/xapi?node[place=town][@timeout=360] -g -o worldtowns.osm -g -o worldtowns.osm

This has given me 2 files of data, which I'm loading (using osm2pgsql), giving me a database which is able to support my distance searching. Each database search will give me back a nearest town/city node, which I then need to display to my application user in text (not on a map), and so I need a location name/description. I want to show more than just the town/city name and so started looking at the is_in tag.

I'm seeing that some of the place nodes have is_in tags I can use directly, such as:

[node id="271344" lat="51.2569570" lon="-1.6233744"]
[tag k="is_in" v="Wiltshire, England, UK"/]
[tag k="name" v="Ludgershall"/]
[tag k="place" v="town"/]
[tag k="wikipedia" v="en:Ludgershall, Wiltshire"/]
[/node]

I can use this to show 'Ludgershall, Wiltshire, England, UK' to my application user.

Others do not have an is_in tag:

[node id="271099" lat="50.9196406" lon="-1.4894631"]
[tag k="name" v="Totton"/]
[tag k="place" v="town"/]
[/node]

Some have an is_in but also have 'component' is_in tags, which contain additional details:

[node id="4085941" lat="52.1363806" lon="-0.4675041"]
[tag k="is_in" v="Bedfordshire"/]
[tag k="is_in:country" v="United Kingdom"/]
[tag k="is_in:country_code" v="GB"/]
[tag k="is_in:county" v="Bedfordshire"/]
[tag k="name" v="Bedford"/]
[tag k="name:lt" v="Bedfordas"/]
[tag k="name:ru" v="Бедфорд"/]
[tag k="place" v="town"/]
[tag k="population" v="80000"/]
[tag k="wikipedia" v="en:Bedford"/]
[/node]

Some only have components and no overall is_in to refer to:

[node id="16664272" lat="52.1365867" lon="-0.9859244"]
[tag k="is_in:continent" v="Europe"/]
[tag k="is_in:country" v="United Kingdom"/]
[tag k="is_in:country_code" v="GB"/]
[tag k="is_in:county" v="Northamptonshire"/]
[tag k="is_in:district" v="South Northamptonshire"/]
[tag k="name" v="Towcester"/]
[tag k="old_name" v="Lactodurum"/]
[tag k="place" v="town"/]
[tag k="wikipedia" v="en:Towcester"/]
[/node]

Some are 'backwards' (it should be 'Surrey, England', not 'England, Surrey'):

[node id="14698916" lat="51.2321130" lon="-0.3247823"]
[tag k="is_in" v="England, Surrey"/]
[tag k="name" v="Dorking"/]
[tag k="place" v="town"/]
[tag k="wikipedia" v="en:Dorking"/]
[/node]

Ideally I need a English name for each, but I'm seeing a mix of languages in some cases:

[node id="18481614" lat="51.8397184" lon="6.6161534"]
[tag k="is_in" v="Kreis Borken,Regierungsbezirk Münster,Nordrhein-Westfalen,Bundesrepublik Deutschland,Europe"/]
[tag k="is_in:continent" v="Europe"/]
[tag k="is_in:country" v="Germany"/]
[tag k="is_in:state" v="North Rhine-Westphalia"/]
[tag k="name" v="Bocholt"/]
[tag k="name:ru" v="Бохольт"/]
[tag k="place" v="town"/]
[tag k="population" v="73696"/]
[tag k="website" v="http://www.bocholt.de"/]
[tag k="wikipedia" v="de:Bocholt"/]
[/node]

I've pretty much come to the conclusion that I can't depend on the data I'm seeing in the is_in tag as it currently stands, there is too much variation in the usage, so I've been working on an alternative solution.

I'm using the area queries which the Overpass API makes available, so given a town node such as:

[node id="271099" lat="50.9196406" lon="-1.4894631"]
[tag k="name" v="Totton"/]
[tag k="place" v="town"/]
[/node]

I can make a query against the API using this request:

http://overpass-api.de/api/interpreter?data=[out:json];is_in(50.9196406,-1.4894631);out;

Which gives me... (sorry that this is quite long...):

{
  "version": 0.6,
  "generator": "Overpass API",
  "osm3s": {
    "timestamp_osm_base": "2014-06-05T10:15:01Z",
    "timestamp_areas_base": "2014-06-05T01:00:02Z",
    "copyright": "The data included in this document is from www.openstreetmap.org. The data is made available under ODbL."
  },
  "elements": [

{
  "type": "area",
  "id": 2438387676,
  "tags": {
    "name": "Southampton",
    "public_transport": "pay_scale_area",
    "ref": "SOTON",
    "source": "naptan_import"
  }
}
,
{
  "type": "area",
  "id": 3600058447,
  "tags": {
    "ISO3166-2": "GB-ENG",
    "admin_level": "4",
    "boundary": "administrative",
    "name": "England",
    "name:be": "Англія",
    "name:cy": "Lloegr",
    "name:de": "England",
    "name:el": "Αγγλία",
    "name:en": "England",
    "name:es": "Inglaterra",
    "name:fr": "Angleterre",
    "name:gd": "Sasainn",
    "name:gv": "Sostyn",
    "name:hsb": "Jendźelska",
    "name:hu": "Anglia",
    "name:it": "Inghilterra",
    "name:lt": "Anglija",
    "name:nl": "Engeland",
    "name:pl": "Anglia",
    "name:pt": "Inglaterra",
    "name:ru": "Англия",
    "name:sv": "England",
    "name:uk": "Англія",
    "name:vi": "Anh",
    "name:zh": "è‹±æ ¼è˜­",
    "name:zh-classical": "è‹±æ ¼è˜­",
    "name:zh-simplified": "è‹±æ ¼å…°",
    "name:zh-traditional": "è‹±æ ¼è˜­",
    "old_name:vi": "Anh Quốc",
    "type": "boundary",
    "wikidata": "Q21",
    "wikipedia": "en:England"
  }
}
,
{
  "type": "area",
  "id": 3600062149,
  "tags": {
    "ISO3166-1": "GB",
    "ISO3166-1:alpha2": "GB",
    "ISO3166-1:alpha3": "GBR",
    "ISO3166-1:numeric": "826",
    "admin_level": "2",
    "boundary": "administrative",
    "currency": "GBP",
    "driving_side": "left",
    "flag": "http://upload.wikimedia.org/wikipedia/commons/a/ae/Flag_of_the_United_Kingdom.svg",
    "int_name": "United Kingdom",
    "name": "United Kingdom",
    "name:ab": "Британиа Ду",
    "name:af": "Verenigde Koninkryk",
    "name:ak": "United Kingdom",
    "name:als": "Vereinigtes Königreich",
    "name:am": "ዩናይትድ ኪንግደም",
    "name:an": "Reino Unito",
    "name:ang": "Geāned Cynerīce",
    "name:ar": "المملكة المتحدة",
    "name:arc": "Ü¡Ü ÜŸÜ˜Ü¬Ü ܡܚܝܕܬܐ",
    "name:arz": "المملكه المتحده",
    "name:ast": "Reinu Xuníu",
    "name:az": "Böyük Britaniya",
    "name:ba": "Бөйөк Британия",
    "name:bar": "Vaeinigts Kinireich",
    "name:bat-smg": "Jongtėnė Karalīstė",
    "name:bcl": "Reyno Unido",
    "name:be": "Вялікабрытанія",
    "name:be-x-old": "Вялікабрытанія",
    "name:bg": "Обединено кралство Великобритания и Северна Ирландия",
    "name:bi": "Unaeted Kingdom",
    "name:bjn": "Britania Raya",
    "name:bn": "যুক্তরাজ্য",
    "name:bo": "དབྱིན་ཇི་མཉམ་འབྲེལ།",
    "name:bpy": "তিলপারাজ্য",
    "name:br": "Rouantelezh-Unanet",
    "name:bs": "Ujedinjeno Kraljevstvo Velike Britanije i Sjeverne Irske",
    "name:bug": "United Kingdom",
    "name:bxr": "Нэгдсэн Вант Улс",
    "name:ca": "Regne Unit",
    "name:cbk-zam": "Reinos Unidos de Gran Britania y Norte Irelandia",
    "name:cdo": "Ĭng-guók",
    "name:ce": "Йоккха Британи",
    "name:ceb": "Hiniusang Gingharian",
    "name:chr": "ᎡᎵᏏᎯ",
    "name:chy": "United Kingdom",
    "name:ckb": "شانشینی یەکگرتوو",
    "name:co": "Regnu Unitu",
    "name:crh": "Büyük Britaniya",
    "name:cs": "Spojené království",
    "name:csb": "Wiôlgô Britanijô",
    "name:cu": "Вєлика Британїꙗ",
    "name:cv": "Аслă Британи",
    "name:cy": "Deyrnas Unedig",
    "name:da": "Storbritannien",
    "name:de": "Vereinigtes Königreich Großbritannien und Nordirland",
    "name:diq": "Qraliya Yewbiyayiye",
    "name:dsb": "Wjelika Britaniska",
    "name:dv": "Þ”ÞªÞ‚Þ¦Þ‡Þ¨Þ“Þ¬Þ‘Þ° Þ†Þ¨Þ‚Þ°ÞŽÞ°Þ‘Þ¦Þ‰Þ°",
    "name:dz": "ཡུ་ནའི་ཊེཊ་ཀིང་ཌམ",
    "name:ee": "United Kingdom",
    "name:el": "Ηνωμένο Βασίλειο",
    "name:eml": "Régn Unî",
    "name:en": "United Kingdom",
    "name:eo": "Unuiĝinta Reĝlando",
    "name:es": "Reino Unido",
    "name:et": "Suurbritannia",
    "name:eu": "Erresuma Batua",
    "name:ext": "Réinu Uniu",
    "name:fa": "بریتانیا",
    "name:fi": "Yhdistynyt kuningaskunta",
    "name:fiu-vro": "Ãœtiskuningriik",
    "name:fo": "Stóra Bretland",
    "name:fr": "Royaume-Uni",
    "name:frp": "Royômo-Uni",
    "name:frr": "Feriind Kiningrik",
    "name:fur": "Ream Unît",
    "name:fy": "Grut-Brittanje",
    "name:ga": "An Ríocht Aontaithe",
    "name:gag": "Büük Britaniya",
    "name:gan": "英國",
    "name:gd": "An Rìoghachd Aonaichte",
    "name:gl": "Reino Unido",
    "name:gn": "Tavetã Joaju",
    "name:gu": "યુનાઇટેડ કિંગડમ",
    "name:gv": "Reeriaght Unnaneysit",
    "name:ha": "Birtaniya",
    "name:hak": "Yîn-koet",
    "name:haw": "Aupuni Mōʻī Hui Pū ʻia",
    "name:he": "הממלכה המאוחדת",
    "name:hi": "यूनाइटेड किंगडम",
    "name:hif": "United Kingdom",
    "name:hr": "Ujedinjeno Kraljevstvo Velike Britanije i Sjeverne Irske",
    "name:hsb": "Zjednoćene kralestwo",
    "name:ht": "Wayòm Ini",
    "name:hu": "Egyesült Királyság",
    "name:hy": "Միացյալ Թագավորություն",
    "name:ia": "Regno Unite",
    "name:id": "Britania Raya",
    "name:ie": "Reyatu Unit",
    "name:ig": "Obodoézè Nà Ofú",
    "name:ilo": "Nagkaykaysa a Pagarian",
    "name:io": "Unionita Rejio",
    "name:is": "Bretland",
    "name:it": "Regno Unito",
    "name:ja": "イギリス",
    "name:jbo": "gugdegubu",
    "name:jv": "Britania Raya",
    "name:ka": "გაერთიანებული სამეფო",
    "name:kab": "Legliz",
    "name:kbd": "Британиэшхуэ",
    "name:kg": "Royaume-Uni",
    "name:kk": "Ұлыбритания",
    "name:kl": "Tuluit Nunaat",
    "name:km": "រាជាណាចក្ររួម",
    "name:kn": "ಯುನೈಟೆಡ್ ಕಿಂಗ್‌ಡಂ",
    "name:ko": "영국",
    "name:koi": "Ыджыт Бритму",
    "name:krc": "Уллу Британия",
    "name:ksh": "Jrußbritannie",
    "name:ku": "Keyaniya Yekbûyî",
    "name:kv": "Ыджыд Британия",
    "name:kw": "Ruwvaneth Unys",
    "name:ky": "Улуу Британия жана Түндүк Ирландия",
    "name:la": "Britanniarum Regnum",
    "name:lad": "Reyno Unido",
    "name:lb": "Groussbritannien an Nordirland",
    "name:lez": "ЧIехибритания",
    "name:li": "Vereineg Keuninkriek",
    "name:lij": "Regno Unïo",
    "name:lmo": "Regn Ünì",
    "name:ln": "Ingɛlɛ́tɛlɛ",
    "name:lt": "JungtinÄ— KaralystÄ—",
    "name:ltg": "Lelbrytaneja",
    "name:lv": "Apvienotā Karaliste",
    "name:mg": "Fanjakana Mitambatra",
    "name:mhr": "Ушымо Королевстве",
    "name:mi": "KÄ«ngitanga Kotahi",
    "name:mk": "Обединето Кралство",
    "name:ml": "യുണൈറ്റഡ് കിങ്ഡം",
    "name:mn": "Их Британи",
    "name:mr": "युनायटेड किंग्डम",
    "name:mrj": "Кого Британи",
    "name:ms": "United Kingdom",
    "name:mt": "Renju Unit",
    "name:mwl": "Reino Ounido",
    "name:my": "ယူနိုက်တက်ကင်းဒမ်းနိုင်ငံ",
    "name:mzn": "بریتانیا",
    "name:na": "Ingerand",
    "name:nah": "Tlacetilīlli Huēyitlahtohcāyōtl",
    "name:nap": "Gran Vretagna",
    "name:nds": "Vereenigt Königriek vun Grootbritannien un Noordirland",
    "name:nds-nl": "Verienigd Keuninkriek",
    "name:ne": "संयुक्त अधिराज्य",
    "name:nl": "Verenigd Koninkrijk",
    "name:nn": "Storbritannia",
    "name:no": "Storbritannia",
    "name:nov": "Unionati Regia",
    "name:nrm": "Rouoyaume Unni",
    "name:nv": "Tótaʼ Dinéʼiʼ Bikéyah",
    "name:oc": "Reialme Unit",
    "name:or": "ଯୁକ୍ତରାଜ୍ୟ",
    "name:os": "Стыр Британи",
    "name:pa": "ਸੰਯੁਕਤ ਬਾਦਸ਼ਾਹੀ",
    "name:pag": "Reino Unido",
    "name:pam": "Pisanmetung a Ka-arian",
    "name:pap": "Reino Uni",
    "name:pcd": "Roéyôme-Uni",
    "name:pih": "Yunitid Kingdum",
    "name:pl": "Wielka Brytania",
    "name:pms": "Regn Unì",
    "name:pnb": "برطانیہ",
    "name:pnt": "Ηνωμένο Βασίλειο",
    "name:ps": "بريتانيا",
    "name:pt": "Reino Unido",
    "name:qu": "Hukllachasqa Qhapaq Suyu",
    "name:rm": "Reginavel Unì",
    "name:rmy": "Phandlo Thagaripen la Bare Britaniyako thai le Nordutne Irlandesko",
    "name:ro": "Regatul Unit al Marii Britanii și al Irlandei de Nord",
    "name:roa-rup": "Britania Mari",
    "name:roa-tara": "Regne Aunìte",
    "name:ru": "Великобритания",
    "name:rue": "Велика Брітанія",
    "name:rw": "Ubwongereza",
    "name:sa": "संयुक्त अधिराज्य",
    "name:sah": "Холбоhуктаах Хоруоллук",
    "name:sc": "Rennu Auniadu",
    "name:scn": "Regnu Unitu",
    "name:sco": "Unitit Kinrick",
    "name:se": "Ovttastuvvan gonagasriika",
    "name:sh": "Ujedinjeno Kraljevstvo",
    "name:si": "එක්සත් රාජධානිය",
    "name:simple": "United Kingdom",
    "name:sk": "Spojené kráľovstvo",
    "name:sl": "Združeno kraljestvo Velike Britanije in Severne Irske",
    "name:sn": "United Kingdom",
    "name:so": "Midowga boqortooyada Britan",
    "name:sq": "Mbretëria e Bashkuar e Britanisë dhe Irlandës së Veriut",
    "name:sr": "Уједињено Краљевство",
    "name:srn": "Ingriskondre",
    "name:ss": "United Kingdom",
    "name:stq": "Fereeniged Köönichriek fon Groot-Britannien un Noudirlound",
    "name:su": "Britania",
    "name:sv": "Storbritannien",
    "name:sw": "Ufalme wa Muungano",
    "name:szl": "Wjelgo Brytańijo",
    "name:ta": "ஐக்கிய இராச்சியம்",
    "name:te": "యునైటెడ్ కింగ్‌డమ్",
    "name:tet": "Reinu Naklibur",
    "name:tg": "Подшоҳии Муттаҳида",
    "name:th": "สหราชอาณาจักร",
    "name:tl": "Nagkakaisang Kaharian",
    "name:tpi": "Yunaitet Kingdom",
    "name:tr": "Birleşik Krallık",
    "name:tt": "Бөекбритания",
    "name:tw": "United Kingdom",
    "name:ty": "Paratāne",
    "name:udm": "Великобритания",
    "name:ug": "بۈيۈك بېرىتانىيە",
    "name:uk": "Велика Британія",
    "name:ur": "برطانیہ",
    "name:uz": "Birlashgan Qirollik",
    "name:vec": "Regno Unìo",
    "name:vep": "Sur' Britanii",
    "name:vi": "Vương quốc Anh",
    "name:vls": "Verênigd Keunienkryk",
    "name:vo": "Regän Pebalöl",
    "name:war": "Reino Unido",
    "name:wo": "Nguur-Yu-Bennoo",
    "name:wuu": "英国",
    "name:xal": "Ик Бритишин болн Ар Гәәлгүдин Ниицәтә Нутг",
    "name:xmf": "გოართოიანაფილი ომაფე",
    "name:yi": "×¤××¨××™×™× ×™×’×˜×¢ ×§×¢× ×™×’×¨×™×™×š",
    "name:yo": "Ilẹ̀ọba Aṣọ̀kan",
    "name:za": "Yinghgoz",
    "name:zea": "Vereênigd Konienkriek",
    "name:zh": "英国",
    "name:zh-classical": "英國",
    "name:zh-min-nan": "Liân-ha̍p Ông-kok",
    "name:zh-simplified": "英国",
    "name:zh-traditional": "英國",
    "name:zh-yue": "英國",
    "name:zu": "Umbuso Ohlangeneyo",
    "native_name": "United Kingdom of Great Britain and Northern Ireland",
    "native_name:da": "Det Forenede Kongerige Storbritannien og Nordirland",
    "native_name:es": "Reino Unido de Gran Bretaña e Irlanda del Norte",
    "native_name:vi": "Vương quốc Liên hiệp Anh và Bắc Ireland",
    "official_name:en": "United Kingdom of Great Britain and Northern Ireland",
    "official_name:it": "Regno Unito di Gran Bretagna e Irlanda del Nord",
    "timezone": "Europe/London",
    "type": "boundary",
    "wikidata": "Q145",
    "wikipedia": "en:United Kingdom"
  }
}
,
{
  "type": "area",
  "id": 3600129306,
  "tags": {
    "admin_level": "8",
    "boundary": "administrative",
    "designation": "non_metropolitan_district",
    "name": "New Forest",
    "population": "174309",
    "ref:gss": "E07000091",
    "ref:lau:1": "UKJ3308",
    "source:ref:gss": "OS_OpenData_Boundary-Line",
    "source:ref:lau": "ONS_OpenData",
    "type": "boundary",
    "website": "http://www.newforest.gov.uk/",
    "wikipedia": "en:New Forest District"
  }
}
,
{
  "type": "area",
  "id": 3600151304,
  "tags": {
    "admin_level": "5",
    "boundary": "administrative",
    "name": "South East England",
    "name:de": "Südostengland",
    "name:en": "South East England",
    "ref:gss": "E12000008",
    "ref:nuts:1": "UKJ",
    "source:ref:gss": "ONS_OpenData",
    "type": "boundary",
    "wikipedia": "en:South East England"
  }
}
,
{
  "type": "area",
  "id": 3600172799,
  "tags": {
    "admin_level": "6",
    "boundary": "administrative",
    "designation": "non_metropolitan_county",
    "name": "Hampshire",
    "note": "Inner ring is to seperate Hampshire from Southampton which is a UA",
    "population": "1304844",
    "ref:gss": "E10000014",
    "ref:nuts:3": "UKJ33",
    "source:ref:gss": "OS_OpenData_Boundary-Line",
    "source:ref:nuts": "ONS_OpenData",
    "type": "boundary",
    "website": "http://www.hampshire.gov.uk/",
    "wikipedia": "en:Hampshire"
  }
}
,
{
  "type": "area",
  "id": 3602698314,
  "tags": {
    "boundary": "ceremonial",
    "name": "Hampshire",
    "note": "Ceremonial County, including Portsmouth and Southampton",
    "type": "boundary"
  }
}
,
{
  "type": "area",
  "id": 3603746024,
  "tags": {
    "boundary": "statistical",
    "name": "Hampshire and Isle of Wight",
    "ref:nuts:2": "UKJ3",
    "source": "ONS_OpenData",
    "type": "boundary",
    "wikipedia": "en:NUTS of the United Kingdom"
  }
}

  ]
}

And from this is I can use code to go through the boundary admin_levels, in descending sequence, to give me:

New Forest, Hampshire, South East England, England, United Kingdom

which are exactly the details I was hoping to get from the is_in tag. So, I've started a process of doing this for all of the towns and cities, effectively adding my own 'is_in' tag to my application's database.

Here's some results from the process, with the node's is_in tag at the end (if it has one) to allows some comparison. The number at the beginning is the node's id for reference, e.g. http://www.openstreetmap.org/node/107775 for the first row.

107775 - London: Greater London, England, United Kingdom [is_in=England, United Kingdom, UK, Great Britain, Europe]
204648 - Wellington: New Zealand [is_in=North Island, New Zealand]
273316 - Itajaí: Santa Catarina, South Region, Brazil [is_in=Santa Catarina, Brazil]
358309 - Leeds: Yorkshire and the Humber, England, United Kingdom [is_in=UK,United Kingdom, Yorkshire,West Yorkshire, Airedale]
441183 - Athens: Central section of Athens, Attica Periphery, Greece [is_in=Athina municipality,Attiki,Greece,EU]
671113 - Baltimore: Maryland, United States of America
1947201 - Bath: Bath & North East Somerset, South West England, United Kingdom [is_in=Somerset, England, UK]
3216768 - St David's: Pembrokeshire, Wales, United Kingdom [is_in=Wales]
6968827 - Ljubljana: Osrednjeslovenska, Western Slovenia [is_in=Slovenia, Europe]
8087537 - Chester: Cheshire West and Chester, North West England, United Kingdom
9002746 - Charleroi: Hainaut, Wallonia (French Community), Belgium [is_in=Hainaut; Wallonie; Belgique; Europe]
9331795 - Limassol: Cyprus [is_in=Cyprus]
10021976 - Leicester: East Midlands, England, United Kingdom [is_in=Leicestershire, England, UK]
10671639 - Lincoln: Lincolnshire, East Midlands, England, United Kingdom
11094836 - Nyköping: Södermanlands län, Svealand, Sweden [is_in=Nyköping, Södermanland, Sweden, EU]
11127374 - Glasgow: Glasgow City, Scotland, United Kingdom [is_in=Scotland, UK]
11235057 - Norwich: Norfolk, East of England, United Kingdom [is_in=England, Norfolk]
12805909 - Oxford: Oxfordshire, South East England, United Kingdom [is_in=Oxfordshire, England, UK]
13707878 - Copenhagen: Capital Region of Denmark [is_in=Hovedstaden, Denmark, EU]
13766899 - Sydney: New South Wales, Australia
14446670 - Quezon City: Metro Manila, Philippines [is_in=Metro Manila]
14644309 - Iskenderun: Hatay, Mediterranean Region, Turkey [is_in=Turkey, Antakya]
15412058 - Helsingborg: Skåne län, Götaland, Sweden [is_in=Helsingborgs kommun, Skåne, Skåne län, Sweden]
16173235 - Mumbai: Maharashtra, India
16173236 - New Delhi: Delhi, India [is_in=National Capital Region, NCR, India]
16174445 - Pune: Maharashtra, India [is_in=India]
16175031 - Islamabad: Islamabad Capital Territory, Pakistan [is_in=Pakistan, Asia]
16175073 - Lahore: Punjab, Pakistan [is_in=Pakistan]
17193023 - Erlangen: Middle Franconia, Free State of Bavaria, Germany [is_in=Mittelfranken,Bayern,Bundesrepublik Deutschland,Europe]
17328659 - Vienna: Austria [is_in=Österreich,Europe]
17550787 - Pécs: Baranya megye, Southern Transdanubia, Hungary [is_in=Pécsi kistérség; Baranya megye; Dél-Dunántúl; Magyarország]
17721995 - Portsmouth: South East England, United Kingdom [is_in=Hampshire, England, UK]
17807753 - Paris: Ile-de-France, Metropolitan France
17857512 - Gloucester: Gloucestershire, South West England, United Kingdom [is_in=England, Gloucestershire]
17859918 - Coventry: West Midlands, England, United Kingdom
17861291 - Birmingham: West Midlands, England, United Kingdom [is_in=West Midlands, England, United Kingdom]
17898859 - Edinburgh: City of Edinburgh, Scotland, United Kingdom [is_in=Scotland, United Kingdom, UK, Great Britain, Europe]
17916174 - Canterbury: Kent, South East England, United Kingdom [is_in=Kent, England, UK]
17951258 - Peterborough: East of England, United Kingdom
17986274 - Plymouth: South West England, United Kingdom [is_in=Devon, England, UK]
18009959 - Exeter: Devon, South West England, United Kingdom [is_in=Devon, England, UK]
18063533 - Toronto: Ontario, Canada [is_in=Ontario, Canada]
18318938 - Hildesheim: Landkreis Hildesheim, Lower Saxony, Germany [is_in=Hildesheim,Niedersachsen,Bundesrepublik Deutschland,Europe]
18477455 - Bern: Verwaltungskreis Bern-Mittelland, Verwaltungsregion Bern-Mittelland, Switzerland [is_in=Bern-Mittelland,Schweiz,CH,Europe]
18886011 - Ottawa: Ontario, Canada [is_in=Ontario, Canada]

So, my reason for posting this is that this raises some questions:

  1. Can my processing be improved? Should I look at Overpass areas other than the ones with a boundary and admin_level tag, perhaps? How would I determine the right sort sequence when I don't have an admin_level?
  2. Should I consider sharing the results of my processing? Should I even consider using this to update the OSM central database, setting each place node with the is_in tags I have determined? I would have used a more standardised is_in tag if it had been available and so wonder if the OSM community could benefit somehow?
  3. I'm really only considering English names, but am aware I'm working with Worldwide data. If this information is to be shared what additional processing should be added? I wonder if I can determine the language which is applicable to each node so I could use, for example, the name:es tags for a Spanish location rather than the name:en ones which I'm using currently?

One thing nagging me is that I'm wondering why this approach hasn't been applied before. Map data is, by its very nature, a hierarchy of places within other places, so why is it necessary to have a free-form is_in tag to describe the hierarchy which already exists? I've read through http://wiki.openstreetmap.org/wiki/Key:is_in and the discussion about boundary polygon making is_in redundant vs. is_in permitting 'simpler searching and easy disambiguation' and I strongly agree with the latter point; in my case having the is_in tag available would save a great deal of complex boundary processing by the Overpass API servers.

Thanks for any help or guidance you can offer.

asked 05 Jun '14, 13:35

Elliveny's gravatar image

Elliveny
66447
accept rate: 0%

edited 05 Jun '14, 13:47

Please don't ask multiple questions at once. You already seem to have noted that the use of the is_in tag is discouraged. It might be easier to process, but it is difficult to keep all the is_in tags including their full hierarchy up-to-date. Boundary polygons provide much more exact borders and are easier to maintain in the long run.

(05 Jun '14, 13:58) scai ♦

Sorry, but it's difficult to avoid asking multiple questions when they relate to the same point.

I'm suggesting that if the is_in tag was set from the boundary polygons, then you avoid the need to do all that boundary processing in cases such as the one discussed in my question. If I have a planet file and an extract of the nodes representing the towns and cities I need to display, how should I determine the location name hierarchy? I think Nominatim is overkill for what I need. To ask a single question: I've found a way to achieve my requirements, is there a better approach though?

(05 Jun '14, 14:19) Elliveny

Maybe some more hints about reverse geocoding can be found at Search_engines

permanent link

answered 05 Jun '14, 23:05

stephan75's gravatar image

stephan75
12.6k556210
accept rate: 6%

Investigate "reverse geocoding" such as is possible with Nominatim or other services. The is_in tag is an old tag which is usually ignored or removed where boundary relations exist.

permanent link

answered 05 Jun '14, 13:54

EdLoach's gravatar image

EdLoach ♦
19.5k16156280
accept rate: 22%

Thanks for the suggestion. I have already worked with Nominatim and don't think it's suitable for this purpose. I'd need a local install of the whole planet file, which requires a heap of disk space and processing time. I could use an external Nominatim server, but my request volumes are likely to be too high. I could use an external Nominatim server against the city/town data and save the result, but I think this rather puts me back in the same place as I am with the Overpass API.

(05 Jun '14, 14:03) Elliveny

Given your comment on the is_in tag being old and usually ignored, I think it is also notable that Nominatim actually uses it when assessing the location name. See http://wiki.openstreetmap.org/wiki/Nominatim/Development_overview:

"All items by name listed in the is_in are searched for within the current country (in no particular order)." and "During the indexing process an address is also calculated using the first feature found for each level. Where an is_in value is provided it is used to filter the address."

(05 Jun '14, 14:34) Elliveny

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×930
×85
×63
×12
×8

question asked: 05 Jun '14, 13:35

question was seen: 56,944 times

last updated: 05 Jun '14, 23:05

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum