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

I'm new to OSM. I downloaded an OSM Data Extract in XML format. Now I want to parse it in order to extract all the places (regions, cities, towns, villages, suburbs. neighborhoods etc). Is there any chance to see dependencies between places? E.g. if there is a suburb, how can I see that it is a part of a city which is a part of a region which is a part of a country etc?

asked 30 Jan '18, 13:18

siffash's gravatar image

siffash
16113
accept rate: 0%


OSM is a spatial dataset and the dependencies/hierarchies you are looking for are expressed by the objects being spatially "inside" each other, so a state boundary would be inside the countries boundary, a municipalities boundary inside the state boundary and so on.

That's the theory.

In real life we don't have boundaries for all such entities and in the case of non-administrative-entity places we currently don't even have an accepted modelling for areas (they will typically be represented by nodes in the absence of boundaries). And just how complete the existing data is will depend very much on what countries and regions you are looking at.

The other bad news is that in the OSM data model the geometry information is carried by the Node objects and "raw" OSM data doesn't contain pre-built geometries for polygons and multi-polygons that would represent the boundaries.

The simplest ways to get the boundary geometries and to be able to query the data spatially is to either use an OverPass API/OverPass Turbo server or run your own osm2pgsql database. There are a number of libraries that will parse OSM data for you and create geometries if you want to do this on foot, most notably Osmium.

permanent link

answered 30 Jan '18, 13:45

SimonPoole's gravatar image

SimonPoole ♦
44.7k13326701
accept rate: 18%

edited 30 Jan '18, 13:59

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:

×710
×84
×83
×1

question asked: 30 Jan '18, 13:18

question was seen: 2,119 times

last updated: 30 Jan '18, 13:59

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