enter image description here

I'm really just looking to get borders for cities and regions around the world. Ideally in a shapefile format.

Does anyone know how I can do that from OpenStreetMap?


2 Answers 2


If it's for specific cities and regions, you can use Overpass Turbo to create queries like admin_level=6 to find border ways. You'll want to consult the Tag:boundary=administrative wiki page to make sure that you're using the right admin level for the country you're looking at.

If, however, you want to just extract those borders for the whole planet, you'll need to download a local copy of the OSM database from https://planet.openstreetmap.org/, then use a tool like Osmosis to extract the particular objects you're looking for. In Osmosis, you'd need to use the --tag-filter command, among other things.

I don't personally have experience working with OSM data directly with GDAL, but it does have the capability of reading and filtering OSM files, which you can read about here. The added benefit of GDAL is that you can also use it in conjunction with ogr2ogr to export directly to shapefile.

Finally, perhaps you're really just looking for shapefiles of those boundaries, and don't want to fiddle around with these commands. In that case, you have a couple options.

  1. Download regions and countries individually from Geofabrik, which come as shapefiles. This is ill-advised, as the extracts will contain everything, and will require some work to filter out the boundaries and bring them all together from disparate layers. And that's not to mention that it would eat up a lot of storage space unnecessarily.

  2. You can always just go to an alternate source like Natural Earth, which provides global coverage of boundaries as shapefiles, among many other things.

If, for whatever reason, the data must come from OSM, then I would suggest getting familiar with GDAL and/or Osmosis.


It depends how many boundaries you would like to extract from OSM. For single city shape osmnx would be easiest option.

If you need to get admin boundaries for whole country, processing OSM data dump for country is the only viable option.

Here is a complete example in Python how to do it



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.