30

.osm.pbf it`s the extension for OpenStreetMap extract that I get from a site that takes daily extracts from OSM: http://download.geofabrik.de/

How to import these files in QGIS (on Linux or Window)?

3 Answers 3

45

QGIS is now able to read .pbf files with Add vector layer, but the data size will most probably kill QGIS with most of the available files.

Try ogr2ogr -f SQLite my.sqlite some.pbf in the OSGEO4W shell to convert the pbf into a spatialite database, and connect to that in QGIS.

You might want to switch to the data folder or use full paths to access the files.

4
  • 1
    This is the way I do it. The ogr configuration file osmconf.ini can be edited to select or deselect the OSM keys that will be reported as fields in the database.
    – nhopton
    Dec 3, 2014 at 9:11
  • 1
    What can i do if i get this errors, during the conversion C:\Users\florinb\Downloads>ogr2ogr -f SQlite canada.sqlite canada-latest.osm.p Warning 1: organizePolygons() received an unexpected geometry. Either a polygon with interior rings, or a polygon with less than 4 points, or a non-Polygon geometry. Return arguments as a collection. Warning 1: organizePolygons() received an unexpected geometry. When i try to open the file in Qgis, i get a generic erro r message "Unexpected error when working with: C:/Users/florinb/Downloads/canada.sqlite " Jun 4, 2015 at 6:50
  • 2
    @BaditaFlorin I think this is worth a new question.
    – AndreJ
    Jun 4, 2015 at 14:43
  • And if like me you tried in the regular console and wonder why this failed, just add ` -dsco SPATIALITE=YES` to the command line. Dec 8, 2021 at 13:59
7

the openstreetmap plugin (current version 0.5) only reads osm-files , but there is a commandline-convert (both for linux as well as for windows. I only tried windows), which can convert *.pbf to *.osm. these converted osm can be importet into qgis via openstreetmapplugin

url for converter: http://wiki.openstreetmap.org/wiki/Osmconvert

3

You can also get the shapefile versions of the extracts. That way you won't have to convert anything. enter image description here

2
  • 8
    Please consider that the provided shapefiles only have a subset of the whole OSM data of the area. If you are interested in very special data, you have to fill the complete OSM data into a PostgreSQL database.
    – AndreJ
    Nov 2, 2012 at 5:49
  • 3
    Looking a few years later, I'll confirm that there's also a problem with these extracts for features that cross borders. For example, the Ottawa River is omitted (rather than split) where it straddles the border between the Canadian provinces of Ontario and Quebec, and the St. Lawrence River is omitted where it straddles the Canada/US border.
    – Canuck
    Dec 22, 2016 at 2:18

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.