4

I would like to extract all the cities along with their administrative hierarchy within a country.

I was thinking to use a mix of tag and geom information since tags are often inconsistent/incomplete:

Maybe start searching with the boundary=administrative tag which should exist for major subdivision, then list the node[place=city] within the area.

That would take quite a while though, especially when getting to smaller admin divisions.

Is there a straight way to do this?

4
  • Instead of trying to extract that information, maybe see if it already exists in the format you want. Try Open Data.
    – csk
    Oct 30, 2019 at 14:34
  • It doesn't exist for China, which is the country I'm targeting. Geonames is not very useful either. My thinking was that OSM "have" the information, but it turns out it's actually very difficult to extract
    – coolnodje
    Nov 4, 2019 at 10:09
  • China is a special case. The government keeps a pretty tight hold on geospatial information. You can get a bulk download of all OSM data for China here: download.geofabrik.de/asia/china.html
    – csk
    Nov 4, 2019 at 16:05
  • Thanks, I have downloaded that. OSM has got a lot of information about China actually. It's just that it's not super consistent, and there don't seem to be an easy way to get, for instance, "All 2nd ADM level entities and 3rd level included in each of these"... My problem is how extract structured information out of OSM at city level.
    – coolnodje
    Nov 5, 2019 at 17:16

1 Answer 1

1

The Mapzen Borders project would have provided exactly the data your looking for, but Mapzen is dead, and the download links on that page all 404 now.

What the Mapzen Borders data was:

Each country link contains a zipped directory of geojson files, each describing increasingly detailed administrative boundaries. The hierarchy varies by country but in the United States, admin layer 2 describes the national boundary, layer 4 is states, layer 6 is counties, and layer 8 is cities. The OSM wiki has specifics for each country.

The code used to produce those extracts is probably still online somewhere, but im not sure where.

1

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.