User Tools

Site Tools


Mapping with OSM Data in QGIS

This topic builds on the Mapping from NSW Lidar with QGIS tutorials, though the data can also be used standalone.

One of the really useful sources of mapping data for Australian users is OpenStreetMap (OSM). It can be a bit of a pain to get set up, but is worth putting in the effort, particularly if you are interested in areas outside NSW.

There's a few steps to get going.

Download raw data

Download the .PBF file (australia-latest.osm.pbf) from

Convert data


Open up the OSGEO4W Shell that comes with QGIS (look under Start → All Programs → QGIS)

Run the following command to convert the .PBF file to SQLite (SpatiaLite) format.

ogr2ogr -f "SQLite" -dsco SPATIALITE=YES {name_of_new_file}.db {name_of_extracted_file}.pbf


ogr2ogr -f "SQLite" -dsco SPATIALITE=YES E:\geodata\ausosm-20230303.db E:\geodata_raw\australia-20230303.osm.pbf

It's useful to include the date in the filenames so you know when the data is from.


If you need to crop the PBF file, the use the following command:

ogr2ogr -f "SQLite" -dsco SPATIALITE=YES -spat {x min} {y min} {xmax} {ymax} {output filename}.db {input file name}.osm.pbf

eg For NSW data only, you could run:

ogr2ogr -f "SQLite" -dsco SPATIALITE=YES -spat 141 -37.5 153.75 -28 E:\geodata\nswosm-20230303.db E:\geodata_raw\australia-20230303.osm.pbf

The coordinates above are in the following order: West South East North


You may want to control the fields that you are importing from OSM. This is done using the osmconf.ini file, that can be found under your QGIS installation eg C:\Program Files\QGIS 3.22.10\apps\gdal\share\gdal\osmconf.ini

If you are using Windows, you'll need to edit this file with Administrator permissions (open Notepad by Shift-Right Click→Run as Administrator).

Under Points, Lines and MultiPolygons, find the section that says “# keys to report as OGR fields” and edit the list underneath. For example:

Lines: attributes=name,highway,waterway,barrier,man_made,natural,surface,service,access

Points: attributes=name,barrier,highway,place,man_made,aeroway,amenity,tourism,information,ford,gate,leisure,natural,railway,waterway

Other tags not listed will still be imported, but in a generic field called other_tags. You will still be able to access these tags in QGIS, but it will require a little more effort each time. So you should aim to capture any regularly used tags in the list above. Also note that some tags are explicitly excluded using the ignore field. You might find you want some of these eg ele(vation) and you should remove any such tags that you want.

If you make any changes, take a backup of your osmconf.ini file. If you upgrade QGIS, it will revert to the default, and you'll need to restore osmconf.ini if you want those fields to come through next time you process an OSM file.

It may be worth storing a copy of it in (say) your profile folder for QGIS, which is retained on upgrade eg C:\Users\<username>\AppData\Roaming\QGIS\QGIS3\profiles\default, and doesn't need admin permissions to edit.

You can then use the -oo flag in the convert data process to point to the file location eg:

ogr2ogr -f "SQLite" -dsco SPATIALITE=YES -oo CONFIG_FILE=C:\Users\brennant\AppData\Roaming\QGIS\QGIS3\profiles\default\osmconf.ini E:\geodata\ausosm-20231210.db E:\geodata_raw\australia-20231210.osm.pbf

Load data in QGIS

Open QGIS.

Go to Layer→Data Source Manager and select SpatiaLite.

Select New, and locate the file.

Once you have set up the connection, you can extract data using (for example) the Processing Toolbox→Vector Overlay→Extract/clip by extent. Select one of the layers within the file (points, lines, multipolygons) as the Input Layer, and select an area to load - by map or by file. Be careful not to make it too large, or you'll get very slow performance.

Style data in QGIS

Here are some sample bushwalking-based style files for OSM points and OSM lines:

Note that they will only work fully if you have matched the tags that I'm importing.

That said, you can generally fix any issues relating to tags by replacing a basic filtering rule such as



hstore_to_map(other_tags)['natural'] = 'peak'

Some other methods of getting OSM data into QGIS can be found at

osm_qgis.txt · Last modified: 2023/12/11 09:20 by bushwalking

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki