Faster Map Making With osmium

It’s sunday and I am fiddling around to make some maps, maybe to put them up my own wall and that’s the moment where I usually stuggle to get data out of OpenStreetMap into QGIS: Overpass is slow and won’t give you too much data, Shapefiles are ok, but this only works for limited regions and filtering and exporting OSMPBFs into GeoJSON is annoying.

Of course it would be better to have the data in a local PostgreSQL, but in order to get it there, you need to think about what data you want to load, but since you’re still iterating and fumbling with the data, this is not yet clear, so you’d need to have some cycle of loading, purging and reloading again. Annoying.

Then I remembered that you can use osmium to get all the data into PostgreSQL, without having to filter, which is not fast enough for tile servers, but easily fast enough for some experimentation.

Just get osmium tool and fire up:

osmium export -f pg -o taiwan.pg taiwan-latest.osm.pbf

Create a Postgres database and a table for the data:

CREATE DATABASE mapmaking;
\c mapmaking
CREATE EXTENSION postgis;

CREATE TABLE taiwan (
    geom GEOMETRY,
    tags JSONB
);

And now suck the data into the table:

\copy taiwan FROM 'taiwan.pg'

Now you got all the geometries in one column, the other holds all the tags. Now, you can fire up QGIS and use that table with some rudimentary querying action:

SELECT
	geom, tags->>'ele' AS ele,
	tags->>'name',
	tags->>'name:en' AS name_en
FROM
	taiwan
WHERE tags->>'natural'='peak';

Enjoy!

By the way, my work-in-progress greyscale map looks like this:

Taiwan