Importing OpenStreetMap data
Introduction
OpenStreetMap (OSM) is a project that aims to create a free, editable map of the world. It is contributed to by a community of volunteer mappers. These volunteers collect data on any type of geographical feature in their surroundings (such as roads, railways, buildings, etc) and upload it to OSM so that it is available for free as open data. This tutorial will explain how to access OSM data so that you can use it in QGIS.
Raster base map
OpenStreetMap can be accessed in raster format under the XYZ Tiles section of the Browser panel.
- Open a browser panel via
- Expand the XYZ tiles section
- Double click on OpenStreetMap to add it to the project
Vector data
QuickOSM plugin
In order to obtain small datasets from OpenStreetMap (e.g. selected features from a single city), use the following steps. If you find that the query is timing out, then the dataset you are requesting is most likely too large and you should follow the steps in the next section (bulk data downloads).
Step 1: Install and open the QuickOSM plugin.
- Unsure of how to install a plugin? > check this tutorial.
- Open the QuickOSM plugin via or via its icon in the toolbar.
Step 2: Select the required values from the drop-down menus in the QuickOSM window:
- Key = the name of the type of features that should be added to the project (e.g. building, trees, highway, etc)
- Value = [optional] the name of a more specific type of feature (e.g. hotel)
- Choose an option from the drop down menu which describes how the features should be located (e.g. in / around / canvas extent)
- Enter the name of the geographic location you would like to obtain features for (e.g. a village, a town...)
Step 3: Run the query.
Step 4: Remove any unnecessary layers.
- After closing the QuickOSM window, you will notice that the plugin adds multiple layers to the project (usually a polygon, line and point layer or selection of these).
- Not all layers will be useful for your application so remove the ones that are unnecessary.
Note: Data obtained from OSM using the QuickOSM plugin is not actually stored on your computer but accessed via a database on the web. If you would like to have a copy of the data on your computer, then export the layer(s) so that they are stored locally:
- Right click on the layer
- Select Export > Save feature as...
- Select the file format and file name
- Recommended file format for vector layers is "GeoPackage"
Bulk data downloads
In order to obtain large datasets from OpenStreetMap (e.g. all features of an entire country), you can use a free download server such as Geofabrik. Follow these simple steps:
Step 1: Go to https://download.geofabrik.de/.
Step 2: Choose the area that you would like download data for. The webpage is organised in a hierarchical structure so first select a continent, then a country and finally a province / sub-region.
Step 3: Download the .shp.zip file.
Step 4: Extract the contents of the zip file.
- The folder will contain a number of different files. Each file contains a different type of feature (e.g. buildings, roads or waterways).
Step 5: Open the file(s) you are interested in by dragging and dropping the .shp files onto the QGIS interface.
Useful links
- QuickOSM plugin tutorial: https://www.qgistutorials.com/en/docs/3/downloading_osm_data.html
- OpenStreetMap QGIS wiki: https://wiki.openstreetmap.org/wiki/QGIS#OpenStreetMap_in_QGIS