User Tools

Site Tools


osm_qgis

This is an old revision of the document!


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

http://download.geofabrik.de/australia-oceania/australia.html

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.

https://github.com/AmericanRedCross/workflows/blob/master/converting_pbf_into_spatialite.md

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

eg 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

Fields

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. This can be accessed by QGIS, but is a little more effort. If you

3. Access the new file from QGIS→Add Layer→Add Spatialite Layer. You will want to filter it by area (eg MBRIntersects(BuildMBR(132,-24,134,-23), geometry)) and some other attributes to avoid being overwhelmed with data.

This is useful for not just cliffs, but lots of other pieces of data

eg roads, the Larapinta Trail, campsites.

ogr2ogr -f “SQLite” -dsco SPATIALITE=YES ausosm20210905.db australia-20210905.osm.pbf

To cut out a section of streets within a municipality, you can

Change the CRS to a metric one so that buffering by say “10” is in metres not degrees!

Some other methods of getting OSM data into QGIS can be found at https://wiki.openstreetmap.org/wiki/QGIS_tutorial

osm_qgis.1677901556.txt.gz · Last modified: 2023/03/04 14:45 by bushwalking

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki