My question is about processing raw OSM data from .osm.pbf exports.

Please don't point me to any online tools, nominatim, or overpass queries.

I have list of Nodes that represent cities in all Europe, for example node for Wrocław has ID of 418392093

I'd like to select from .osm.pbf relation that represents boundary of this city. Fortunately, boundary=administrative Relation has Wrocław's ID listed as admin_centre. Unfortunately Wrocław is also listed as admin_centre of the region it is in (Dolnośląskie voivodeship).

How can I know for sure which boundary relation matches which city node?

Subquestions:

  1. If the answer is "you can use name", is it reliable method? Does boundary has always the same name as node?
  2. If the answer is "select boundary with highest admin level", is it reliable as well? What if subregion has the same admin centre?
  3. If there isn't "official" method of doing so, why? It seems an important use case to know boundary of any city.

Raw data for Relation for administrative boundary of Wrocław city looks like this:

  {
    "ID": 2805690,
    "Members": {
      "admin_centre": [
        418392093
      ],
      "outer": [
        52452667,
        ...
        443264980
      ],
      "subarea": [
        2341621,
        ...
        2318980
      ]
    },
    "Tags": {
      "admin_level": "8",
      "boundary": "administrative",
      "name": "Wrocław",
      ...
      "name:szl": "Wrocłow",
      "old_name:eo": "Breslaŭo",
      "old_name:pl": "Wratislaw",
      "type": "boundary",
      "wikidata": "Q1799",
      "wikipedia": "pl:Wrocław"
    }
  },

Raw data for Relation for administrative boundary of a region Wrocław is in looks like this:

 {
    "ID": 224457,
    "Members": {
      "admin_centre": [
        418392093
      ],
      "label": [
        505025705
      ],
      "outer": [
        175469910,
        ...
        176467203
      ],
      "subarea": [
        451266,
        ...
        451516
      ]
    },
    "Tags": {
      "ISO3166-2": "PL-DS",
      "admin_level": "4",
      "alt_name:en": "Lower Silesian Province",
      "boundary": "administrative",
      "int_name": "wojewodztwo dolnoslaskie",
      "license_plate_code": "D",
      "loc_name": "Dolnośląskie",
      "long_name:fr": "Voïvodie de Basse-Silésie",
      "name": "województwo dolnośląskie",
      "name:ar": "محافظة سيلزيا السفلى",
      ...
      "name:zh": "下西里西亚省",
      "population": "1970217",
      "ref": "DS",
      "short_name": "dolnośląskie",
      "source:population": "Bank Danych Lokalnych - stan na dzień 31.12.2016",
      "teryt:terc": "02",
      "type": "boundary",
      "wikidata": "Q54150",
      "wikipedia": "pl:Województwo dolnośląskie"
    }
  },

asked 10 Aug '18, 17:37

sheerun's gravatar image

sheerun
103
accept rate: 0%

edited 10 Aug '18, 17:38

At a minimum you need to create geographical objects from your PBF. It so happens Nominatim & Overpass are by far and away the easiest options. You cant process relationships in geodata without turning into geographies. A short answer is process into PostGIS with osm2pgsql and write suitable queries there: the downside is that you lose some explict relationships between city nodes & boundary relations: however as there is no guarantee that these exist consistently you still have to solve the problem.

(10 Aug '18, 22:10) SK53 ♦
Be the first one to answer this question!
toggle preview

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:

×494
×95
×41
×15

question asked: 10 Aug '18, 17:37

question was seen: 176 times

last updated: 10 Aug '18, 22:10

powered by OSQA