3

Given I have a relation such as this example. I have installed JOSM and QGIS as well as GDAL tools for the shell. I am aware of Overpass-Turbo. What is the best way to export geometry data from OpenStreetMap into Shapefiles?

3
  • Please clarify: do you want to export exactly this one relation to a shapefile? or do you want more?
    – underdark
    Jan 3, 2015 at 16:14
  • There may be not any generally best method but the OSM driver of GDAL gdal.org/drv_osm.html used with ogr2ogr gdal.org/ogr2ogr.html is a good candidate.
    – user30184
    Jan 3, 2015 at 20:40
  • @underdark Yes, I only want to extract this relation.
    – JJD
    Jan 4, 2015 at 1:51

3 Answers 3

5

You can get the Umweltzone using the following Settings in Quick OSM. Note that you can simply search for the name:

enter image description here

Afterwards, you can use Save as ... to save to a Shapefile (or just copy the temporary Shapefile Quick OSM creates).

2
3

If the relation or way in question is closed and tagged with boundary="administrative" or boundary="political" you might be able to use MapIt: Global for this - it's a reverse geocoder for administrative and political boundary data in OpenStreetMap. (This service is mostly used for looking up enclosing boundaries in OpenStreetMap from a given latitude and longitude, but you can also look up an OpenStreetMap boundary directly from its relation ID or way ID.)

The boundary in your question doesn't have those tags, but for other readers and use cases this might be helpful. For example, for relation 62748 you could construct the URL:

... which redirects to:

That page lets you download the boundary data in various formats: GeoJSON, WKT and KML. You could then convert it to ESRI Shapefile format with ogr2ogr or QGIS.

If you want to do that programmatically, it's easiest to leave off the .html from the URL above, to give http://global.mapit.mysociety.org/code/osm_rel/62748 - that redirects to http://global.mapit.mysociety.org/area/979462 and you can just append .geojson to that latter URL get the GeoJSON version: http://global.mapit.mysociety.org/area/979462.geojson

There are some restrictions to be aware of with this service:

  • The database is only updated roughly quarterly, so the relation/way you want might be out of date or missing.
  • The only boundaries included are:
    • Relations or ways that are closed
    • Relations or ways that are either:
      • tagged with boundary="administrative" and admin_level from 1 to 12
      • or tagged with boundary="political" and political_division one of linguistic_community, insular_council, euro_const, canton, circonscription_législative, parl_const, county_division or ward (these could be extended for the next import with a pull request modifying this file.
1
  • Mark, respectfully, I'd like to give you a big smooch for this one
    – diggity
    Jan 19, 2022 at 13:32
1

If your goal is to extract features from osm database and save them to shapefiles, then I would suggest using Qgis with the quickOSM plugin.

With QuickOSM you can easilly query the Openstreepmaps database (it uses turbo overpass) and add the result to Qgis canvas while saving it to a shapefile.

1
  • Can you please extend your answer? I found Quick OSM and installed the plugin. However, I do not understand how I can query the relation given in my example with the tool.
    – JJD
    Jan 4, 2015 at 1:50

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.