height:30px height:30px height:30px

How to use OSM data in QGIS ?


height:80px height:80px height:80px

Vector, raster, database, docker, Overpass, tiles and so on …

Which one should I use ?


Etienne Trimaille

height:80px

height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

3Liz

  • French company πŸ‡«πŸ‡·
  • Open Source forever
  • Core contributors in QGIS, server side mainly
  • β™₯ QGIS Desktop β™₯ QGIS Server β™₯ PostGIS β™₯
  • Opensource solution for publishing QGIS Project on the web,
    Lizmap Web Client 🦎
  • Development, server hosting, consulting, QGIS support, training

height:80px

height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

QGIS, the powerful desktop app

height:500px

OSM vector data

height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

OpenStreetMap

  • Vector database
  • Open Database License (ODBL)
  • Worldwide coverage
  • All kind of features from landuse, to opening hours and accessibility

height:280px

height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

OSM data model

  • Different primitive objects
OSM GIS
Node Point
Way Line
Relation Polygon
  • A OSM way can either be a GIS line or GIS polygon according to its OSM tags (key/values)
  • A OSM relation can be point, line, multilinestrings, multipolygons, mixed geometry ...
height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

OSM data model

Another difference ➑ attributes

  • In GIS, the layer has one or many fields, defining all features in this specific layer

  • In OSM, the layer does not exist. Each feature is individual and has its own fields.

height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

Therefore

OSM data in QGIS will be different from raw OSM data

height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

Moreover, there are a few questions

height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

Do you need …

  • to have up to date OSM data ?
  • to work with small extent or a big extent ?
    • By the way, what small extent and big extent ? (for online API)
    • Density of data in different part of the worlds
  • to have OSM metadata such as contributor, changeset, timestamp ?
  • data designed for display or analysis or routing or geocoding or … ?
  • all OSM keys and values ?
height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

There isn't a single answer

height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

Let's see what is possible

height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

With QGIS only

  • Add the default mapnik style as a raster, from the QGIS Browser

height:400px

height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

With QGIS only

height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

With QGIS only

height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

With QGIS only

  • It starts to be an issue if you want some specific fields
  • This is called an HStore field

height:250px

height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

Use Processing Explode HStore

height:500px

height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

Or use QGIS Expression

height:360px

for selection, labelling ...

height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

Using QGIS Plugins

A few plugins in the QGIS plugin manager among the 973 plugins available 😎

height:400px

height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

QuickMapServices plugin

height:400px

OpenTopoMap in the background, based on OSM, designed for hiking πŸ”

height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

QuickMapServices plugin

height:400px

In QuickMapServices, go in Settings ➑ More services ➑ Get contributed pack to enable a lot of basemaps πŸš€.

height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

QuickOSM plugin

  • Download the data on the fly
  • Making requests to the Overpass API, similar to Overpass-Turbo
    • Server API to retrieve raw OSM data based on queries (OQL)
  • QuickOSM 2.0.0 has been released
  • Targeting both
    • non OSM contributors
    • and OSM OverpassAPI experts
  • It's removing the HStore field other_tags by exploding it
  • As it's an API, limited amount of data
  • Let's make an overview of this new version
height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

Quick Query

  • Search in your native language
    • πŸ‡¬πŸ‡§ Bakery
    • πŸ‡©πŸ‡ͺ BΓ€ckerei
    • πŸ‡«πŸ‡· Boulangerie
    • ➑ shop=bakery in OSM
  • Multi key/value support with AND/OR operator

  • Thanks to the JOSM and Vespucci community to share these presets on GitHub
height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

Quick Query

French people love πŸ₯– and πŸ§€

height:400px

height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

Map presets

  • Download many layers, many OSM objects, with a QGIS symbology at the same time with 2 clicks

height:400px

height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

Map presets

height:400px

Bicycle map, landuse, ... map presets

height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

QuickOSM in Processing

  • Available in Processing Toolbox and Modeler
  • Example : downloading fire hydrants, reprojecting in meters projection, buffering and QGIS Style

height:400px

height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

QuickOSM in Processing

height:400px

height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

Local OSM file

  • Having a PBF/OSM file on your computer ?
  • You can still filter it

height:400px

height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

Some quick tips in QuickSOM

height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

Reload the query to get latest update from OSM

height:500px

height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

Query many named places with ;

height:90px

height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

Default QGIS Actions available

height:400px

height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

QuickOSM 2.0.0

Full changelog
https://github.com/3liz/QuickOSM/releases/tag/2.0.0

  • Add history of queries
  • Add option to get the metadata of OSM data such as author, timestamp etc
  • Boost of performance using HStore processing algorithm to parse the downloaded OSM file, which is coded in C++
  • ...
height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

Geocoding

height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

Geocoding

height:400px

height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

Routing

  • ORS Tools
  • API based on OpenStreetMap data
  • isochrones and matrix calculations

height:400px

height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

Importing OSM in a database ?

https://wiki.openstreetmap.org/wiki/Databases_and_data_access_APIs#Database_Schemas

height:300px

  • Mainly osm2pgsql, used for rendering, very old project and used
  • Imposm, version 3 is updatable. Each layer has a mapping configuration
height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

Database with docker

  • 🐘 and 🐳
  • https://github.com/kartoza/docker-osm
  • Docker-compose project :
    • PostgreSQL container
    • Imposm container
    • OSMUpdate container : to download OSM diff files
  • Workflow
    • Drop a PBF file in the folder
    • Drop the area of interest for clipping (recommended) in the folder
    • Copy .example.env to .env for local settings
    • make run
height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

et voila !

Possible to customize the configuration :

  • Different mapping
  • Generalization for different scales
  • Updated every two minutes by default
  • SQL Triggers, views
  • Styles included in the QGIS layer_styles table
height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

Vector tiles

  • Vector tile support, new in QGIS 3.14 🌟
  • MapTiler / OpenMapTiles https://openmaptiles.org/
  • Presentation from Adam Laza in a few minutes
height:30px Foss4G - Buenos Aires 2021
height:30px height:30px height:30px

Questions

This was just a subset of capabilities.
There are still other plugins, other ways etc.


Etienne
🐦 @etrimaille

height:30px Foss4G - Buenos Aires 2021