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?
-
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.– user30184Jan 3, 2015 at 20:40
-
@underdark Yes, I only want to extract this relation.– JJDJan 4, 2015 at 1:51
3 Answers
You can get the Umweltzone using the following Settings in Quick OSM. Note that you can simply search for the name:
Afterwards, you can use Save as ... to save to a Shapefile (or just copy the temporary Shapefile Quick OSM creates).
-
-
2Surely: wiki.openstreetmap.org/wiki/Overpass_API/…. As an example:
rel(2003523); >; out meta;
– AndreJJan 4, 2015 at 15:43
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"
andadmin_level
from1
to12
- or tagged with
boundary="political"
andpolitical_division
one oflinguistic_community
,insular_council
,euro_const
,canton
,circonscription_législative
,parl_const
,county_division
orward
(these could be extended for the next import with a pull request modifying this file.
- tagged with
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.
-
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.– JJDJan 4, 2015 at 1:50