0

Is there a way to get geojson boudaries of all cities in a country ? The only thing I found is to find the geojson of only one city using this: https://nominatim.openstreetmap.org/search.php?q=Czech+Republic+Prague&polygon_geojson=1&format=json

But I need to generate a geojson file of the whole country(including all small cities etc ..)

  • Hi, and welcome to GIS SE! Please make sure you take the tour to get familiar with the Q&A format that we follow here. A good question will be as detailed as possible, describing what you're trying to accomplish, as well as what you have already tried in order to solve this on your own. An "is it possible" kind of question like this can usually be answered with a "yes", and doesn't contribute to the overall body of knowledge on the site. – JoshC Jun 19 '18 at 16:03
1

In short, yes, there is a way. Here's one of them.

Provided the boundaries are all in the OSM dataset, you can obtain the data you're looking for by using Overpass Turbo. Using Overpass does require that you be familiar with the OSM tagging format, but once you build a query, you have the option of exporting the results as a GeoJSON.

In OSM, boundaries are indicated by the key/tag combination boundary=administrative. This is always paired with a second key/tag admin_level=*, which indicates the kind of boundary. The values in admin_level and their administrative equivalents (x = State, y = County, etc.) varies by country.

In the Overpass Turbo interface, you can use the Query Wizard to build your query. For example, here is a query to grab all administrative boundaries in Iceland:

query wizard

And here is the resulting output:

query output

As you can see, there's a lot going on here. By selecting features, though, I can see how the admin_level key is being used here. I could either use this output as is and filter it myself, or I have the option of specifying a particular admin_level in the wizard by appending an "and" statement.

Once your results are to your liking, you can select "Export" in the upper-left, where you can then specify the GeoJSON format and download.

If you can't find the results you're looking for, it could be that the data is not in OSM. In that case, you'll have to keep looking for some other dataset that you can convert to GeoJSON. You might try seeing if the country has a GIS portal. Also: consider contributing this missing information to OSM if you find it!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.