While it might make sense to convert a pbf into a postgis database using something like OSM2pgsql, I often just want to convert a pbf file to a spatialite file.
Why convert pbf to spatialite? pbf takes forever to load.
In Terminal on a Mac, I typed ogr2ogr -f SQLite [my].sqlite [file].pbf.
I think ogr2ogr is available as part of GDAL if you\’ve followed the instructions correctly for installing QGIS. More on what OGR stands for is on the FAQ page. Basically, it\’s a prefix to a simple features library… Whatever that means.
So, for California I typed in
ogr2ogr -f SQLite california.sqlite
And then I dragged the california-latest.osm.pbf file onto the terminal to get the correct path to the file.
So, it looked like this
ogr2ogr -f SQLite california.sqlite /Users/macbook/Downloads/california-latest.osm.pbf
The result went into the home directory, and I just moved it to a desired location.
I opened the spatialite file in QGIS and saved my queries to a GeoPackage.