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 Baso Minangkabau bosanski brezhoneg català čeština 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 português do Brasil 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;'

Load the scripts

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

(don't run linestring if you don't want linestrings)

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