Upload
ross-mcdonald
View
105
Download
0
Embed Size (px)
Citation preview
PGROUTING IN QGIS
How to tame your network - Ross McDonald @mixedbredie
Here be dragons
Get
Merge
Load
Update
Populate
Build
Analyse
Get lost
http://ghost.mixedbredie.net/pgrouting-with-strategi/
Get the data
Open Data Download
http://bit.ly/1I0Fwz3
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…
Load into PostGIS
QGIS DB
Manager
Schema
Table
Primary key
Geometry
SRID
Spatial index
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);
Populate the network table
Start and end coordinates
Length costs
Speed (average driving / walking speeds)
Time = length / speed
Reverse costs
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');
Analyse the network
Checks for errors
MULTILINESTRING v LINESTRING
SELECT pgr_analyzegraph(
'os_strategi.strat_rds', 0.001, 'geometry',
'gid', 'source', 'target');
Get Lost© Crown copyright and database right 2015 100023404
Djikstra Shortest Path
© Crown copyright and database right 2015 100023404Strategi Network
Driving Distance (10min)
© Crown copyright and database right 2015 100023404Strategi Network
Alpha Shapes (isochrones)
© Crown copyright and database right 2015 100023404Strategi Network
Astar heuristic shortest path
Meridian2 Network© Crown copyright and database right 2015 100023404
Turn Restricted Shortest Path
Integrated Transport Network with RRI© Crown copyright and database right 2015 100023404
Geoserver WMS + TRSP
http://ghost.mixedbredie.net/combining-pgrouting-functions-in-openlayers3/
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
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/