In response to repeated customer requests seeking spatial datasets based on the OpenStreetMap service, CYBERTEC decided to start an initiative to address this demand.
CYBERTEC implemented a “download OpenStreetMap” service which periodically generates extracts of OpenStreetMap data in various forms, and outputs the data as an sql dump to streamline and simplify its usage. Extracts cover a particular region of interest– typically, aligned with the boundaries of countries or continents. Extract imports’ parameters have already been set for your convenience. Import variants implicitly state how your dataset was imported into our database. New variants can be created according to your wishes, contact us for more details.
The main entry point of our service, which is free of charge, is located at https://gis.cybertec-postgresql.com/.
Dataset import variants
Importing OpenStreetMap data into
PostGIS can be a hard and time-consuming task. To simplify this process and speed up the import, we decided to kick off a service offering two dataset types, periodically served as sql dumps.
The basis for all import variants are pure OSM extracts, provided as
The first type of import variant is drawn from the main objective of OpenStreetMap, which is to solve spatial questions by analyzing and visualizing spatial data. There are endless ways to import and map OSM data to PostGIS in order to serve this purpose. To support most typical use cases while retaining flexibility, we decided to implement a generic import like that of OpenStreetMap Carto (https://github.com/gravitystorm/openstreetmap-carto). Incidentally, this enables us to use this dump seamlessly as a source for tiling services, such as https://switch2osm.org/serving-tiles/ or https://github.com/Overv/openstreetmap-tile-server.
A brief description of the import chain can be found at https://gis.cybertec-postgresql.com/osmtile/readme.txt.
The second type of import variant addresses the demand for solving various kinds of routing-related questions. This time, native datasets are imported utilizing
osm2po (https://osm2po.de/), a great java application which turns pure OpenStreetMap data into a routable graph. Ideally, the resulting table will be used together with
pgRouting (https://pgrouting.org/), another terrific extension which brings geospatial routing functionality to PostgreSQL.
Checkout the import chain at https://gis.cybertec-postgresql.com/osmrouting/readme.txt.
CYBERTEC offers extracts for the whole world. Since we don’t see the need to re-invent the wheel, datasets’ spatial extents are aligned with the boundaries of countries or continents. To simplify access and downloads, the datasets are structured hierarchically, as stated in figure 1.
How often will our datasets be generated? Native extracts (
pbfs) are generated daily, dumps are produced 1 to 2 times per month. Currently, we’re trying to optimize the whole process to provide more frequent current dumps for our customers.
Dataset usage and import
So how can customers use our service? Let’s go through a typical customer scenario.
A customer plans to set up a tiling server which offers raster data covering Austria. Let’s assume tiling infrastructure is already up and running, however the missing link is a database containing OpenStreetMap data. Instead of utilizing
osm2pgsql to import the dataset, the customer can take a nice shortcut and directly download the appropriate sql dump from our service 😊.
General instructions are as follows:
First, start by heading to https://gis.cybertec-postgresql.com/ and choose your region of interest. Figure 2 shows available datasets for Austria at the present time. Since we want to setup a tiling service, our dataset import variant of choice is “Analysis, Tiling”. Let’s download the latest dump for this region from https://gis.cybertec-postgresql.com/osmtile/europe/austria/osmtile_europe_austria_latest_compressed.dump
Dataset download, restore instructions
Second, we must import our dump. How can this be accomplished?
Instructions are shown beside each published dump as readme.txt. For Austria, instructions can be accessed at https://gis.cybertec-postgresql.com/osmtile/europe/austria/readme.txt.
Let’s quickly look at the instructions to better understand how we must proceed. As a requirement, the database must be prepared with the extensions
postgres=# create database tilingdb; CREATE DATABASE postgres=# \c tilingdb psql (13.3 (Ubuntu 13.3-1.pgdg20.04+1), server 13.4 (Ubuntu 13.4-1.pgdg20.04+1)) You are now connected to database "tilingdb" as user "postgres". tilingdb=# create extension postgis; CREATE EXTENSION tilingdb=# create extension hstore; CREATE EXTENSION
Finally, the dump can be restored by executing
pg_restore -j 4 --no-owner -d tilingdb osmtile_europe_austria_latest_compressed.dump
This results in a new database schema
tilingdb=# \dn List of schemas Name | Owner ------------------------+---------- osmtile_europe_austria | postgres public | postgres (2 rows)
The listing below shows the tables generated within our schema.
tilingdb=# \dt+ osmtile_europe_austria. List of relations Schema | Name | Type | Owner | Persistence | Size | Description ------------------------+--------------------+-------+----------+-------------+---------+------------- osmtile_europe_austria | planet_osm_line | table | postgres | permanent | 1195 MB | osmtile_europe_austria | planet_osm_nodes | table | postgres | permanent | 3088 MB | osmtile_europe_austria | planet_osm_point | table | postgres | permanent | 323 MB | osmtile_europe_austria | planet_osm_polygon | table | postgres | permanent | 1865 MB | osmtile_europe_austria | planet_osm_rels | table | postgres | permanent | 102 MB | osmtile_europe_austria | planet_osm_roads | table | postgres | permanent | 130 MB | osmtile_europe_austria | planet_osm_ways | table | postgres | permanent | 1996 MB | (7 rows)
This article briefly introduces CYBERTEC’s brand new OpenStreetMap download service. The service has been released recently, and we are very curious what customers think about it. Please leave a message at firstname.lastname@example.org to give us feedback, discuss further dataset import variants, or in case you need assistance. Check out this post if you want to know how to start out with PostgreSQL and PostGIS.