3. Installation and Requirements

For this workshop you need:

  • Preferable a Linux operating system like Ubuntu
  • An editor like Gedit or Mousepad
  • Geoserver for the routing application
  • Internet connection

All required tools are available on the OSGeo LiveDVD, so the following reference is a quick summary of how to install it on your own computer running Ubuntu 12.04 or later.

3.1. pgRouting

pgRouting on Ubuntu can be done using packages from a Launchpad repository:

All you need to do is to open a terminal window and run:

# Add pgRouting launchpad repository
sudo apt-add-repository -y ppa:ubuntugis/ppa
sudo apt-add-repository -y ppa:georepublic/pgrouting
sudo apt-get update

# Install pgRouting package
sudo apt-get install postgresql-9.3-pgrouting

# Install osm2pgrouting package
sudo apt-get install osm2pgrouting

# Install workshop material (optional, but maybe slightly outdated)
sudo apt-get install pgrouting-workshop

# For workshops at conferences and events:
# Download and install from http://trac.osgeo.org/osgeo/wiki/Live_GIS_Workshop_Install
wget --no-check-certificate https://launchpad.net/~georepublic/+archive/pgrouting/+files/pgrouting-workshop_[version]_all.deb
sudo dpkg -i pgrouting-workshop_[version]_all.deb

This will also install all required packages such as PostgreSQL and PostGIS if not installed yet.

Note

  • Once pgRouting 2.0 has been released it will be available in the stable repository on Launchpad.
  • To be up-to-date with changes and improvements you might run sudo apt-get update & sudo apt-get upgrade from time to time, especially if you use an older version of the LiveDVD.
  • To avoid permission denied errors for local users you can set connection method to trust in /etc/postgresql/<version>/main/pg_hba.conf and restart PostgreSQL server with sudo service postgresql restart.
local   all             postgres                                trust
local   all             all                                     trust
host    all             all             127.0.0.1/32            trust
host    all             all             ::1/128                 trust

pg_hba.conf can be only edited with “superuser” rights, ie. from the terminal window with

sudo nano /etc/postgresql/9.3/main/pg_hba.conf

To close the editor again hit CTRL-X.

3.2. Workshop

When you installed the workshop package you will find all documents in /usr/share/pgrouting/workshop/.

We recommend to copy the files to your home directory and make a symbolic link to your webserver’s root folder:

cp -R /usr/share/pgrouting/workshop ~/Desktop/pgrouting-workshop
sudo ln -s ~/Desktop/pgrouting-workshop /var/www/pgrouting-workshop

You can then find all workshop files in the pgrouting-workshop folder and access to

Note

Additional sample data is available in the workshop data directory. To extract the file run tar -xzf ~/Desktop/pgrouting-workshop/data.tar.gz.

3.3. Add pgRouting Functions to database

Since version 2.0 pgRouting functions can be easily installed as extension. This requires:

  • PostgreSQL 9.1 or higher
  • PostGIS 2.x installed as extension

If these requirements are met, then open a terminal window and execute the following commands (or run these commands in pgAdmin 3:

# login as user "postgres"
psql -U postgres

# create routing database
CREATE DATABASE routing;
\c routing

# add PostGIS functions
CREATE EXTENSION postgis;

# add pgRouting core functions
CREATE EXTENSION pgrouting;

Note

If you’re looking for the SQL files containing pgRouting function, you can find them in /usr/share/postgresql/<version>/contrib/pgrouting-2.0/:

-rw-r--r-- 1 root root  4126 Jun 18 22:30 pgrouting_dd_legacy.sql
-rw-r--r-- 1 root root 43642 Jun 18 22:30 pgrouting_legacy.sql
-rw-r--r-- 1 root root 40152 Jun 18 22:30 pgrouting.sql

3.4. Data

The pgRouting workshop will make use of OpenStreetMap data, which is already available on the LiveDVD. If you don’t use the LiveDVD or want to download the latest data or the data of your choice, you can make use of OpenStreetMap’s API from your terminal window:

# Download using Overpass XAPI (larger extracts possible than with default OSM API)
BBOX="-1.2,52.93,-1.1,52.985"
wget --progress=dot:mega -O "sampledata.osm" "http://www.overpass-api.de/api/xapi?*[bbox=${BBOX}][@meta]"

More information how to get OSM data:

An alternative for very large areas is the download services of Geofabrik. Download a country extract and unpack the data like this:

wget --progress=dot:mega http://download.geofabrik.de/[path/to/file].osm.bz2
bunzip2 [file].osm.bz2

Warning

Data of a whole country might be too big for the LiveDVD as well as processing time might take very long.

Table Of Contents

Previous topic

2. About

Next topic

4. Create a Network Topology

License

This work is licensed under a Creative Commons Attribution-Share Alike 3.0 License.

Creative Commons License