I downloaded quite large OpenStreetMap dataset from https://www.geofabrik.de/ in osm (or pbf) format. Namely Czech Republic. Geofabrik provides ESRI SHP files too, but I unfortunatelly need more attributes (are not included in prebuilded shp files).

Question is, how to import OSM to the QGIS? I know 3 ways, but each of them has issues or doesn't work:

1) Vector->OpenStreetMap->Import Topology from XML...->Export Topology to SpatialLite

This works, but:

  • relations are not imported; some attributes missing (when compared with OSM map on the web)

  • polygon holes are not imported correctly (courtyards of houses are filled)

2) Add Vector Layer...

Simple, but it imports nothing! After openning .osm or .pbf file (using UTF-8 encoding), QGis shows dialog, where number of elements is ZERO (points, lines, polygons, ...)

3) Import OSM File using QuickOSM plugin

Plugin is computing many hours, but at the end, there is no new layer, or sometimes layers named OsmFile, but empty.

I have newest QGis (2.18.12) and newest QuickOSM plugin (sorry, I don't see it's version in gui). My PC is Intel Core i7, 16GB RAM, SSD disc, Windows 10 Pro.

  • ...QGis and windows is 64bit, of course Commented Sep 5, 2017 at 7:48
  • Ok thank you. I downloaded PostGIS, but installation failed (Same error as this user: osgeo-org.1560.x6.nabble.com/…). Why everything in "GIS World" doesn't work? :-( Commented Sep 5, 2017 at 8:37
  • ...sorry, my misstake, PosgreSQL must be installed first. Commented Sep 5, 2017 at 8:47
  • mmd> after some minor issues, my Postgis database works. Thank You for the hint. I imported the data, polyogon holes seems to be imported correctly. But some attributes still missing (building:levels, ...etc). The issue is that theese attributes are in relation. Is there way to "bake" relation attributes to all it's "child" polygons (or other geometries)? Commented Sep 5, 2017 at 10:48

2 Answers 2


There is no other way for calculating the number of features from the osm.pbf file than to parse all the data from the file. Therefore in your case 2) QGIS saves your time and shows the number of features as zero. That's intentional. Just select the desired layer, add it in to your map, and you will see the data.

enter image description here

QGIS open that large .pbf file rather slow. I would read first what the driver manual page http://www.gdal.org/drv_osm.html says about osmconf.ini and then convert the .pbf file into SpatiaLite database with ogr2ogr. The basic command is

ogr2ogr -f sqlite -dsco spatialite=yes czech-republic.sqlite czech-republic-latest.osm.pbf
  • Thank You, it works :-). Instead of zeroes, they should display "N/A" or something. 0 is confusing. I'am programmer, zero means "empty" for me. Commented Sep 6, 2017 at 7:56
  • QGIS is open source, as a programmer you can just fix it, make a pull request, get it accepted and that's it. But it is better to write a mail to developer list first.
    – user30184
    Commented Sep 6, 2017 at 8:02
  • 6 years later, I wonder what "it works" mean =) Does it work to convert a large osm.pbf file to SpatiaLite, and then import it?
    – Ted
    Commented May 31, 2023 at 10:53
  • Six years ago ogr2ogr imported a country wide osm.pbf file into a SpatiaLite database with geometries and attributes (with some limitations, see gdal.org/drivers/vector/osm.html), and QGIS could access the data. It should work as well today.
    – user30184
    Commented May 31, 2023 at 11:38

Whern using PostGIS layer in QGis, polygons seems to be imported correctly.

It is quite complicated procedure, but not impossible. Here are simple istructions:

  1. Install PostgreSQL
  2. Install PostGIS
  3. create and configure postgree database: You can use GUI application in PostgreSQL installation folder (pgAdmin 4)
  4. use osm2pgsql tool: something like: osm2pgsql.exe -s -U user -d databasename data.pbf -S default.style -H localhost -W -P 5432 (note: Cygwin binary works fine in Windows, but you can specify path to default.style file)
  5. connect PostGIS Layer in QGis (Vector->Add Vector Layer)

This is good solution, but it solves osm import only partially. There is still lack of clarity about relations and its tags, see my another question: Importing OpenStreetMap polygons to QGis with relation attributes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.