For this workshop you need:
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.
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 add-apt-repository ppa:georepublic/pgrouting-unstable
sudo apt-get update
# Install pgRouting package
sudo apt-get install postgresql-9.1-pgrouting
# Install osm2pgrouting package
sudo apt-get install osm2pgrouting
# Install workshop material (optional)
sudo apt-get install pgrouting-workshop
# For FOSS4G 2013 workshop:
# Download and install from http://trac.osgeo.org/osgeo/wiki/Live_GIS_Workshop_Install
wget --no-check-certificate https://launchpad.net/~georepublic/+archive/pgrouting-unstable/+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
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.1/main/pg_hba.conf
To close the editor again hit CTRL-X.
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.
Since version 2.0 pgRouting functions can be easily installed as extension. This requires:
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/9.1/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
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:
- OpenStreetMap download information in http://wiki.openstreetmap.org/wiki/Downloading_data
- OpenStreetMap data is available at the LiveDVD in /usr/local/share/osm/
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.