How to use OSM data in QGIS ?


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

Which one can I use ?


Etienne Trimaille
🐦 @etrimaille

FOSS4G - Firenze 2022

3Liz

  • Open Source forever, check our GitHub
  • Contributors in QGIS, server side mainly, plugins
  • ♥ QGIS Desktop ♥ QGIS Server ♥ PostGIS ♥
  • Opensource solution for publishing QGIS Project on the web,
    Lizmap Web Client 🦎

FOSS4G - Firenze 2022

QGIS, the powerful desktop app

OSM vector data with different symbologies

FOSS4G - Firenze 2022

QGIS, the powerful desktop app

Isochrone analysis

FOSS4G - Firenze 2022

QGIS, the powerful desktop app

Remote data with temporal controller

FOSS4G - Firenze 2022

QGIS, the powerful desktop app

3D

FOSS4G - Firenze 2022

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…
FOSS4G - Firenze 2022

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.

FOSS4G - Firenze 2022

Therefore

OSM data in QGIS will be different from raw OSM data

FOSS4G - Firenze 2022

Moreover, there are a few questions

FOSS4G - Firenze 2022

Do you need …

  • to have up to date OSM data ?
  • to work with small extent or a big extent ?
    • By the way, what is a small 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 or just the "most common ones" ?
FOSS4G - Firenze 2022

There isn't a single answer

FOSS4G - Firenze 2022

Let's see what is possible

FOSS4G - Firenze 2022

With QGIS only

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

FOSS4G - Firenze 2022

With QGIS only

FOSS4G - Firenze 2022

With QGIS only

FOSS4G - Firenze 2022

With QGIS only

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

FOSS4G - Firenze 2022

Use Processing Explode HStore

FOSS4G - Firenze 2022

Or use QGIS Expression

for selection, labelling ...

FOSS4G - Firenze 2022

Using QGIS Plugins

A few plugins in the QGIS plugin manager among the 914 plugins available 😎 (August 2022)

FOSS4G - Firenze 2022

QuickMapServices plugin

OpenTopoMap in the background, based on OSM, designed for hiking 🏔

FOSS4G - Firenze 2022

QuickMapServices plugin

In QuickMapServices, go in Settings ➡ More services ➡ Get contributed pack to enable a lot of basemaps 🚀.

FOSS4G - Firenze 2022

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.2.1 was released this weekend, during the SOTM & QGIS Contributor meeting
  • Targeting both
    • non OSM contributors
    • and OSM OverpassAPI experts
  • It's removing the HStore field other_tags by exploding it
  • As it's using an API, limited amount of data
  • Let's make an overview of this new version
FOSS4G - Firenze 2022

Quick Query

  • Search in your native language
    • 🇬🇧 Bakery
    • 🇮🇹 Panetteria
    • 🇫🇷 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
FOSS4G - Firenze 2022

Quick Query

French people love 🥖 and 🧀

FOSS4G - Firenze 2022

Map presets

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

FOSS4G - Firenze 2022

Map presets

A few steps to make new presets, with a QGIS style

FOSS4G - Firenze 2022

Map presets

Bicycle map, landuse… map presets

https://docs.3liz.org/QuickOSM/user-guide/map-preset/

FOSS4G - Firenze 2022

QuickOSM in Processing

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

FOSS4G - Firenze 2022

QuickOSM in Processing

FOSS4G - Firenze 2022

Local OSM file

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

FOSS4G - Firenze 2022

Some quick tips in QuickSOM

FOSS4G - Firenze 2022

Reload the query to get latest update from OSM

FOSS4G - Firenze 2022

Query many named places with ;

FOSS4G - Firenze 2022

Default QGIS Actions available

JOSM, Wikipedia, URL, Mapillary

FOSS4G - Firenze 2022

Default QGIS Actions available

JOSM, Wikipedia, URL, Mapillary

FOSS4G - Firenze 2022

Translations

FOSS4G - Firenze 2022

OSM relations

Issues with OSM relations

  • The underlying library (OGR) can only display relations = route, multilinestrings, multipolygons or boundary.
  • Other relations need some post-processing to manage geometries for a GIS software
FOSS4G - Firenze 2022

Geocoding

FOSS4G - Firenze 2022

Geocoding

FOSS4G - Firenze 2022

Routing

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

FOSS4G - Firenze 2022

Importing OSM in a database ?

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

  • Mainly osm2pgsql, used for rendering, very old project and used
  • Imposm, version 3 is updatable. Each layer has a mapping configuration
FOSS4G - Firenze 2022

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
FOSS4G - Firenze 2022

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
FOSS4G - Firenze 2022

Vector tiles

  • Vector tile support, new in QGIS 3.14 🌟
  • MapTiler / OpenMapTiles https://openmaptiles.org/
  • Talk at the State Of The Map by Jiri Komarek and Wladimir Szczerban
  • Talk at the FOSS4G by Adam Laza yesterday, QGIS MapTiler plugin
FOSS4G - Firenze 2022

Questions

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


Come to see me if you have any links or other tools


Etienne
🐦 @etrimaille or @3LIZ_news

FOSS4G - Firenze 2022