
Add OpenStreetMap Data to QGIS from Geofabrik
What you'll learn
- An overview of Geofabrik and when to use it
- How to download OpenStreetMap data from the Geofabrik website
- How to extract only specific OpenStreetMap features
Recommended for
- Anyone who wants to add OpenStreetMap data to QGIS
- Anyone who wants to use the Geofabrik website with QGIS
Introduction
Geofabrik is a website that provides OpenStreetMap data. With Geofabrik, you can easily download data for a specific region. This article explains how to use Geofabrik, which cuts OpenStreetMap data out by country and region. It covers practical steps: getting regional data from Geofabrik, adding it to QGIS, and extracting only specific features such as mailboxes.
For the background knowledge this article assumes, see the following article as well.
What is Geofabrik?
Geofabrik is a website that publishes OpenStreetMap data cut out by country and region.

The data OpenStreetMap provides officially covers the entire planet. However, the full dataset runs to hundreds of gigabytes, which is inconvenient when you only want data for one area.
Geofabrik lets you download data for a specific country or region individually. It cuts the official OpenStreetMap data at many scales, from wide regions such as Europe and South America, to countries such as Japan and the Philippines, down to areas such as Hokkaido and Shikoku. You can get just the data you need.
Pros and cons of using Geofabrik
One way to add OpenStreetMap data to QGIS is the QuickOSM plugin. However, QuickOSM fetches and extracts data from a server over the internet, so complex queries or large amounts of data can take a long time or fail to return any data.
The Geofabrik download method in this article is better suited than QuickOSM to large areas and many features. Conversely, when the target area is small or you need few features, QuickOSM adds the data faster.
For how to add data with QuickOSM, see the following article.
Download data from Geofabrik
This section walks through downloading data from the Geofabrik site, using Hokkaido as an example.
Go to the Geofabrik home page. The Sub Regions table at the lower left of the page lists regions. Find Asia and click it.

Selecting Asia on the home page opens the page below. Scroll down the Sub Regions table to find Japan, and click Japan.

Next, find the Hokkaido row in the Sub Regions table and click [.osm.pbf]. The download starts.
![Find the Hokkaido row in the Sub Regions table and click [.osm.pbf]](/_app/immutable/assets/howto_download_osm-with-geofabrik_03.BocULqdp.jpeg)
Add Geofabrik data to QGIS
Next, add the data you downloaded from Geofabrik to QGIS.
The downloaded data is in .osm.pbf format, but you can add it by drag and drop, just like an ordinary vector layer.
When you add the file, a dialog like the one below opens. For Geofabrik data, you can choose whether to import each feature shape, such as points and lines, into QGIS.

The five items in the dialog group features by the following criteria.
lines: What OpenStreetMap calls ways, generally linestrings. Examples are roads and railway tracks.multilinestrings: Relations that are not necessarily closed (not polygons), such as public transport routes. Examples are bus and railway routes.multipolygons: Relations that are closed (polygons), such as municipal boundaries and multipolygons (polygons with holes cut out of their interior), or ways that form polygons. Examples are buildings, parking lots, and municipal boundaries.other_relations: Relations that meet neither of the conditions above.points: What OpenStreetMap calls nodes, generally points. This includes features represented by a single point, such as mailboxes, as well as the points that make up lines and polygons.
For example, mailboxes are represented as points, so select at least points for them. For roads, select at least lines and multilinestrings. For buildings, select at least multipolygons. Then click Add Layers.
This time, select all five items and click Add Layers. The data takes a while to load, so wait for a moment.
When loading finishes, you can confirm that data such as buildings, railway lines, and roads has been added to QGIS.

Narrow down to specific features
As you can see once the data is loaded, there are too many features, so processing and loading take time. This section explains how to display only the data you need. As an example, extract and display only convenience stores.
First, convenience stores are represented both as points and as buildings (polygons). So hide every layer except the corresponding points and multipolygons layers.

In OpenStreetMap, convenience store features carry the shop=convenience tag, so you can normally narrow the data down to convenience stores with the QGIS filter function.
However, in Geofabrik data, OpenStreetMap tags are not always available as QGIS attributes as they are. For example, the multipolygons layer has the shop key as an attribute, but in the points layer the shop key is contained inside the other_tags attribute, as shown below.


The next two sections therefore introduce two ways to handle the data inside the other_tags attribute.
Method 1: Search the other_tags attribute as a string
The simplest way to narrow down to specific features with this data structure is to treat the other_tags attribute as a string and search it.
To search an attribute as a string, first open the Processing Toolbox at the center right of the QGIS window and click Vector selection → Extract by attribute.

The Extract by attribute dialog opens.
To extract the features with that condition in QGIS, set the following:
- Input layer: Make sure hokkaido-latest.osm - points is selected.
- Selection attribute: Select other_tags.
- Operator: Select contains.
- Value: Enter
"shop"=>"convenience". - When the settings are done, click the Run button at the lower right of the dialog.

The processing takes some time, so wait. When it finishes, QGIS adds a layer at the lower left of the main window.

Method 2: Extract specific tags from the other_tags attribute
In the other_tags attribute of Geofabrik data, multiple OpenStreetMap tags are combined into a single QGIS attribute and stored in a format called “HStore”. However, QGIS cannot use its filter function on HStore attributes, so they are hard to handle directly.
This section therefore introduces a preprocessing step that extracts the tags you need for analysis or processing from the other_tags attribute and creates them as new attributes.
To handle OpenStreetMap tags easily, use Vector table → Explode HStore Field in the Processing Toolbox. This tool extracts specific tags from an attribute and converts them into ordinary QGIS attributes.

Take convenience stores as an example. In OpenStreetMap, they should carry the shop=convenience tag. If you convert the shop key inside other_tags into a shop attribute, you can use that attribute to narrow the data down to convenience stores.
- Input layer: Select hokkaido-latest.osm - points.
- HStore field: Select other_tags.
- Expected list of fields separated by a comma (fields to select): Enter
shopthis time. To convert multiple keys to attributes, separate them with commas. For example, to use the brand key as an attribute in addition to the shop key, entershop,brand. - When the settings are done, click the Run button at the lower right.

The processing takes some time, and when it finishes QGIS adds a new layer. This layer copies all the features of the input layer and adds attributes, so it appears on top of the points layer.

Open the attribute table to see that a shop attribute has been added.

To narrow the new layer down to convenience stores, run the Extract by attribute tool with the following settings.
- Input layer: Make sure the layer you just created (here, Exploded) is selected.
- Selection attribute: Select shop.
- Operator: Select =.
- Value: Enter
convenience. - When the settings are done, click the Run button.

Back in the main window, only the convenience stores remain.

This preprocessing also makes it easy to, for example, color the features by brand value.

Conclusion
This article explained how to get data from Geofabrik and add it to QGIS, and how to narrow the added data down to specific features.
OpenStreetMap is freely usable map data that covers buildings, roads, restaurants, and many other features. By applying the steps in this article, you can extract the feature data you need from OpenStreetMap and use it for analysis and map making. Put this wealth of data to work in your own analyses and maps.
Note that if you create and publish maps using OpenStreetMap data, you need to provide attribution, such as a copyright notice. For details, see the official OpenStreetMap page “Copyright and License”.


QGIS LAB is a comprehensive information hub for QGIS, the open-source GIS software. Under the concept of “Geospatial for Greater Good,” we share the knowledge and skills to open up the world through location data.


