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?


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.

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.