Osmosis/PostGIS Setup

From OpenStreetMap Wiki
Jump to: navigation, search
Available languages — Osmosis/PostGIS Setup
· Afrikaans · Alemannisch · aragonés · asturianu · azərbaycanca · Bahasa Indonesia · Bahasa Melayu · Bân-lâm-gú · Basa Jawa · Basa Sunda · Baso Minangkabau · bosanski · brezhoneg · català · čeština · corsu · dansk · Deutsch · eesti · English · español · Esperanto · estremeñu · euskara · français · Frysk · Gaeilge · Gàidhlig · galego · Hausa · hrvatski · Igbo · interlingua · Interlingue · isiXhosa · isiZulu · íslenska · italiano · Kiswahili · Kreyòl ayisyen · kréyòl gwadloupéyen · Kurdî · latviešu · Lëtzebuergesch · lietuvių · magyar · Malagasy · Malti · Nederlands · Nedersaksies · norsk bokmål · norsk nynorsk · occitan · Oromoo · oʻzbekcha/ўзбекча · Plattdüütsch · polski · português · română · shqip · slovenčina · slovenščina · Soomaaliga · suomi · svenska · Tiếng Việt · Türkçe · Vahcuengh · vèneto · Wolof · Yorùbá · Zazaki · српски / srpski · беларуская · български · қазақша · македонски · монгол · русский · тоҷикӣ · українська · Ελληνικά · Հայերեն · ქართული · नेपाली · मराठी · हिन्दी · भोजपुरी · অসমীয়া · বাংলা · ਪੰਜਾਬੀ · ગુજરાતી · ଓଡ଼ିଆ · தமிழ் · తెలుగు · ಕನ್ನಡ · മലയാളം · සිංහල · བོད་ཡིག · ไทย · မြန်မာဘာသာ · ລາວ · ភាសាខ្មែរ · ⵜⴰⵎⴰⵣⵉⵖⵜ ⵜⴰⵏⴰⵡⴰⵢⵜ‎ · አማርኛ · 한국어 · 日本語 · 中文(简体)‎ · 中文(繁體)‎ · 吴语 · 粵語 · ייִדיש · עברית · اردو · العربية · پښتو · سنڌي · فارسی · ދިވެހިބަސް

This is a description of Setup PostGIS in Debian / Ubuntu

Procedure to import data into PostgreSQL

A bit of set-up is required to get PostgreSQL to work with osmosis. This page describes a procedure to get it set up to import a Planet dump.

As only an outline is given, some shell and PostgreSQL knowledge is required.

Install Postgresql and PostGIS

On a recent Ubuntu system, use

sudo apt install postgresql-9.4-postgis-2.1 openjdk-7-jre-headless

Any version 9.1/2.0 or later should work.

Install and compile Osmosis

See https://wiki.openstreetmap.org/wiki/Osmosis#Downloading

On a recent Ubuntu system, use

sudo apt install osmosis

Create and Initialise Database

sudo -u postgres createuser -s your_username
createdb pgsnapshot
psql -d pgsnapshot 'CREATE EXTENSION postgis; CREATE EXTENSION hstore;'

Run the script

psql -d pgsnapshot -f osmosis_dir/script/pgsnapshot_schema_0.6.sql

When needed, and this can also be at a later stage when specific queries require this (and will report that they need it), one or more the following support scripts can also be run:

psql -d pgsnapshot -f osmosis_dir/script/pgsnapshot_schema_0.6_action.sql
psql -d pgsnapshot -f osmosis_dir/script/pgsnapshot_schema_0.6_bbox.sql
psql -d pgsnapshot -f osmosis_dir/script/pgsnapshot_schema_0.6_linestring.sql

Please, see the header of each individual file for what it contributes. If you don't know what is means you can skip them.[1]

Note that you can ignore this message

psql:/usr/share/doc/osmosis/examples/pgsnapshot_schema_0.6.sql:4: NOTICE:  table "actions" does not exist, skipping

Running osmosis

You can either use write pgsql or write pgsql dump. This example uses write pgsql

osmosis --read-pbf extract.osm.pbf --log-progress --write-pgsql database=pgsnapshot 

You may need to set up postgresql's pg_hba.conf

For small extracts when building geometry with lots of RAM nodeLocationStoreType=InMemory can be faster.

For recent planets, InMemory takes close to 64GB of RAM.

See also

  • https://lists.openstreetmap.org/pipermail/osmosis-dev/2017-May/001815.html