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 |
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. answered 30 Jan '18, 13:45 SimonPoole ♦ |