For this workshop you need:
All required tools are available on the OSGeo Live, 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 installed 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 (for Ubuntu 14.04)
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
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.
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/html/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 "user"
psql -U user
-- 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
The pgRouting workshop will make use of OpenStreetMap data, which is already available on OSGeo Live. If you don’t use the OSGeo Live 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="-122.8,45.4,-122.5,45.6"
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 OSGeo Live 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 OSGeo Live installation as well as processing time might take very long.