18
PGROUTING IN QGIS How to tame your network - Ross McDonald @mixedbredie

Ross McDonald - PgRouting in QGIS

Embed Size (px)

Citation preview

Page 1: Ross McDonald - PgRouting in QGIS

PGROUTING IN QGIS

How to tame your network - Ross McDonald @mixedbredie

Page 2: Ross McDonald - PgRouting in QGIS

Here be dragons

Get

Merge

Load

Update

Populate

Build

Analyse

Get lost

http://ghost.mixedbredie.net/pgrouting-with-strategi/

Page 3: Ross McDonald - PgRouting in QGIS

Get the data

Open Data Download

http://bit.ly/1I0Fwz3

Page 4: Ross McDonald - PgRouting in QGIS

Merge the roads

There’s a QGIS tool for that!

Select: Motorways, A roads, B roads, primary routes, minor roads and local streets

Vector > Data Management Tools > Merge Shapefiles to One…

Page 5: Ross McDonald - PgRouting in QGIS

Load into PostGIS

QGIS DB

Manager

Schema

Table

Primary key

Geometry

SRID

Spatial index

Page 6: Ross McDonald - PgRouting in QGIS

Update the network table

Add the required columns for pgRouting

Build the indices to make it fast

ALTER TABLE os_strategi.strat_rds

ADD COLUMN source integer,

ADD COLUMN target integer, etc., etc.

CREATE INDEX strat_rds_source_idx ON os_strategi.strat_rds USING btree(source);

Page 7: Ross McDonald - PgRouting in QGIS

Populate the network table

Start and end coordinates

Length costs

Speed (average driving / walking speeds)

Time = length / speed

Reverse costs

Page 8: Ross McDonald - PgRouting in QGIS

Build the network topology

Creates a node table used for start and end

points

SELECT pgr_createtopology(

'os_strategi.strat_rds', 0.001, 'geometry',

'gid', 'source', 'target');

Page 9: Ross McDonald - PgRouting in QGIS

Analyse the network

Checks for errors

MULTILINESTRING v LINESTRING

SELECT pgr_analyzegraph(

'os_strategi.strat_rds', 0.001, 'geometry',

'gid', 'source', 'target');

Page 10: Ross McDonald - PgRouting in QGIS

Get Lost© Crown copyright and database right 2015 100023404

Page 11: Ross McDonald - PgRouting in QGIS

Djikstra Shortest Path

© Crown copyright and database right 2015 100023404Strategi Network

Page 12: Ross McDonald - PgRouting in QGIS

Driving Distance (10min)

© Crown copyright and database right 2015 100023404Strategi Network

Page 13: Ross McDonald - PgRouting in QGIS

Alpha Shapes (isochrones)

© Crown copyright and database right 2015 100023404Strategi Network

Page 14: Ross McDonald - PgRouting in QGIS

Astar heuristic shortest path

Meridian2 Network© Crown copyright and database right 2015 100023404

Page 15: Ross McDonald - PgRouting in QGIS

Turn Restricted Shortest Path

Integrated Transport Network with RRI© Crown copyright and database right 2015 100023404

Page 16: Ross McDonald - PgRouting in QGIS

Geoserver WMS + TRSP

http://ghost.mixedbredie.net/combining-pgrouting-functions-in-openlayers3/

Page 17: Ross McDonald - PgRouting in QGIS

ITN+RRI=TRSP

'select to_cost, teid as

target_id,

feid||coalesce('',''||via,'''') as

via_path from

itn_turn_restrictions‘

Directed = true

Has reverse = true

Page 18: Ross McDonald - PgRouting in QGIS

Guides

http://anitagraser.com/?s=pgrouting

http://ghost.mixedbredie.net/pgrouting-with-

strategi/

http://ghost.mixedbredie.net/using-

pgrouting-with-os-meridian2/

http://ghost.mixedbredie.net/building-itn-for-

pgrouting/