Extract OpenStreetMap features
In the previous OpenStreetMap (OSM) tutorial , we learned how to extract a standard set of map features from OpenStreetMap including waterways, buildings, general points of interest, and roads.
In this tutorial, we will learn how to specify by type of feature, and extract data within a particular extent for only that type of feature.
No programming is required for this tutorial; we will use only a QGIS
plugin called QuickOSM
.
Data availability
The list of types of features you can export from OSM is impressive; you can view the full list on the OpenStreetMap Map Features Wiki .
Limitations
It must be stated that because OpenStreetMap data is user contributed (think of OSM as the Wikipedia of maps), you can expect the data exports to be incomplete. The level of completeness depends on the happenstance of who added information for the types of features you are seeking. Still, in cases where no other known data source exists, OSM extracts can be a good place to start.
How it works
To best understand the data you will be exporting, it is helpful to consider how it is created. After making an account, any OpenStreetMap (OSM) user can open the OSM editor and add features (points, lines and polygons) for phenomena in the world.
There are standards for how data should be entered and tagged, but beyond basic geometry, qualitative information about each feature is optional. That means, for instance, in some cases a restaurant may be tagged with the specific kind of ethnic cuisine, while other times the cuisine
key field might have a blank or null value.
OSM defines standard ways for entering feature data, but sometimes people enter data incompletely or incorrectly.
Query tips
For this reason, before using an export tool like the QuickOSM
QGIS plugin we will use in this tutorial, it is helpful to do some research about how the features in question have been tagged in the area you are looking for.
The first step is to consult the OpenStreetMap Map Features Wiki
and identify how a feature is supposed to be tagged. For instance, if we are looking for shopping malls, we can find that the suggested key, value pair is shop
, and mall
, respectively.
shop
, and mall
, respectively.In practice, however, features can be tagged in all sorts of idiosyncratic ways.
In this example, the contributor tagged the building correctly using the shop
key with the mall
value.
In this example, however, the contributor used the building
tag and entered mall
as the value.
Idiosyncracies like this are important to note, because, as we will see, queries are constructed by supplying the key value pair to the extract tool. If a significant number of the features you want are tagged differently than is outlined by the OSM standard, you will need to make note of that in your query building.
Reverse search
We suggest, therefore, visiting OpenStreetMap (OSM)
first as a user and inspecting the attributes of a selection of your desired features to see how they are constructed. You can inspect the attributes by right-clicking an area on the map, selecting Query features
, and clicking on the feature you are interested in. Note how the data is structured, and remember it for when you are building your query.
How to export data
-
Download QGIS if you haven’t already.
-
In the main (top, horizontal) QGIS menu, select
Plugins
, thenManage and Install Plugins
. -
Search for
QuickOSM
and install the plugin. -
Once installed, the plugin will appear under the
Vector
menu in the main QGIS menu. SelectVector
, thenQuickOSM
, thenQuickOSM
.
There are more advanced ways to build queries using this tool, but we are going to stick with the
QuickQuery
, which requires only thekey
,value
, andlocation
.
- Input the following values:
key: shop value: mall location: Jakarta
- Select
Run query
The tool will automatically render all available features as data layers in your QGIS document. Here we can see that there is both a point and polygon layer for malls.
If your query is returning no features, while it is possible that no features of that type have been contributed in the area you are searching, it is also highly likely you may need to construct your query differently. We suggest researching how your desired features have been tagged in OpenStreetMap, as outlined in the reverse search section above, and trying different queries where appropriate.
Example alternate query key: building value: mall location: Jakarta
If a significant number of features have alternate tagging, you can export them separately and then later merge the shapefiles together to create one “complete” layer.
It may be hard to see on this map below, but the key: building
, value: mall
query returned a not insignificant number of malls.
Here is the attribute table for the results of this query, showing that it has returned thirty-three instances of malls in Jakarta.
To save the results as a new data layer, right-click the layer in the layer list and select Export
. Choose Save features as
and save the data someplace logical, naming the file and selecting geoJSON
as the filetype.