Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Using Ordnance Survey
datasets with pgRouting
Ross McDonald
Angus Council
@mixedbredie
“The person
attempting to travel
two roads at once will
get nowhere.”
- Xun Zi
Contains OS Open Data Crown Copyright and D...
What is it?
An extension to the PostGIS enabled
PostgreSQL database to add geospatial
routing functionality.
Why use it?
• Free (as in freedom)
• Flexible (as in open source)
• Functional (as in fully featured)
• Fun (if you’re tha...
http://www.cartographicperspectives.org/index.php/journal/rt/printerFriendly/c
What does it need?
CC-BY-NC-SAReproducedwiththepermissionoftheNationalLibraryofScotland
Where can one get such things?
Data, data everywhere
• OS Open Roads
• OS Meridian2
• OS Strategi
• OS ITN
• OS Highways
• OS Water Network
OpenStreetMap
Metro extracts by Mapzen
"name1" IN ('Watling
Street','Fosse Way',
'Ackling Dyke', 'Akeman
Street', 'Cade''s Road',
'Dere Street', 'Ermin
Way', 'De...
But first you gotta be loaded
• For OS data
– Astun Loader!
– Lutra’s OS Translator II
– Ogr2ogr
– Snowflake’s GoLoader*
–...
There’s a plugin for that
• How can I use it
without writing
SQL?
• pgRouting Layer by
Anita Graser and
others in the
pgRo...
CC-BY-NC-SAReproducedwiththepermissionoftheNationalLibraryofScotland
“Most roads lead men
homewards, my road leads
forth.”...
PostgreSQL function to loop through each input
point and calculate Djikstra shortest path to every
node on the network…
pg...
pgRouting 2.2.3
• Using pgr_drivingdistance and
pgr_alphashape
• Using an all-in-one function to process
multiple input po...
Performance Enhancements
• Index your data
• Add a Bounding Box to
your query
• Make it easier for the
user
Vanilla Shortest Path
SELECT seq, id1 AS node, id2 AS
edge, cost FROM pgr_dijkstra('
SELECT gid AS id, source::integer,
ta...
M&S Shortest Path
SELECT seq, id1 AS node, id2 AS edge,
cost FROM pgr_dijkstra(' SELECT gid AS
id, source::integer, target...
Making things even better!
• Update the QGIS plugin to use new PGR
functions
• Update the plugin to use a bounding box
• A...
Not Mrs Beeton’s recipes
http://anitagraser.com
https://georepublic.info/en/blog
http://workshop.pgrouting.org/index.html
...
CC-BY-NC-SAReproducedwiththepermissionoftheNationalLibraryofScotland
Thank you
Ross McDonald
Angus Council
mcdonaldr@angus...
Pgrouting_foss4guk_ross_mcdonald
Pgrouting_foss4guk_ross_mcdonald
Pgrouting_foss4guk_ross_mcdonald
Pgrouting_foss4guk_ross_mcdonald
Pgrouting_foss4guk_ross_mcdonald
Pgrouting_foss4guk_ross_mcdonald
Pgrouting_foss4guk_ross_mcdonald
Pgrouting_foss4guk_ross_mcdonald
Pgrouting_foss4guk_ross_mcdonald
Pgrouting_foss4guk_ross_mcdonald
Pgrouting_foss4guk_ross_mcdonald
Upcoming SlideShare
Loading in …5
×

Pgrouting_foss4guk_ross_mcdonald

289 views

Published on

pgRouting presentation given at FOSS4G UK on 15 June 2016

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Pgrouting_foss4guk_ross_mcdonald

  1. 1. Using Ordnance Survey datasets with pgRouting Ross McDonald Angus Council @mixedbredie
  2. 2. “The person attempting to travel two roads at once will get nowhere.” - Xun Zi Contains OS Open Data Crown Copyright and Database Right 2016.
  3. 3. What is it? An extension to the PostGIS enabled PostgreSQL database to add geospatial routing functionality.
  4. 4. Why use it? • Free (as in freedom) • Flexible (as in open source) • Functional (as in fully featured) • Fun (if you’re that way inclined)
  5. 5. http://www.cartographicperspectives.org/index.php/journal/rt/printerFriendly/c What does it need?
  6. 6. CC-BY-NC-SAReproducedwiththepermissionoftheNationalLibraryofScotland Where can one get such things?
  7. 7. Data, data everywhere • OS Open Roads • OS Meridian2 • OS Strategi • OS ITN • OS Highways • OS Water Network
  8. 8. OpenStreetMap Metro extracts by Mapzen
  9. 9. "name1" IN ('Watling Street','Fosse Way', 'Ackling Dyke', 'Akeman Street', 'Cade''s Road', 'Dere Street', 'Ermin Way', 'Devil''s Causeway', 'Devil''s Highway', 'Ermine Street', 'Fen Causeway', 'Icknield Street', 'King Street', 'Maiden Way', 'Military Way', 'Peddars Way‘, …) https://dhs.stanford.edu /spatial- humanities/geographic- networks-pgrouting/ /en.wikipedia.org/wiki/Roman_roads_in_Britain#/media/File:Roman_Roads_in_Britannia.svg
  10. 10. But first you gotta be loaded • For OS data – Astun Loader! – Lutra’s OS Translator II – Ogr2ogr – Snowflake’s GoLoader* – Safe’s FME* • For OpenStreetMap – osm2pgrouting
  11. 11. There’s a plugin for that • How can I use it without writing SQL? • pgRouting Layer by Anita Graser and others in the pgRouting team
  12. 12. CC-BY-NC-SAReproducedwiththepermissionoftheNationalLibraryofScotland “Most roads lead men homewards, my road leads forth.” John Masefield
  13. 13. PostgreSQL function to loop through each input point and calculate Djikstra shortest path to every node on the network… pgRouting 1.0.7-dev
  14. 14. pgRouting 2.2.3 • Using pgr_drivingdistance and pgr_alphashape • Using an all-in-one function to process multiple input points IMPROVED
  15. 15. Performance Enhancements • Index your data • Add a Bounding Box to your query • Make it easier for the user
  16. 16. Vanilla Shortest Path SELECT seq, id1 AS node, id2 AS edge, cost FROM pgr_dijkstra(' SELECT gid AS id, source::integer, target::integer, cost_time::double precision AS cost, rcost_time::double precision AS reverse_cost FROM or_network', 100828, 1136587, false, true);
  17. 17. M&S Shortest Path SELECT seq, id1 AS node, id2 AS edge, cost FROM pgr_dijkstra(' SELECT gid AS id, source::integer, target::integer, cost_time::double precision AS cost, rcost_time::double precision AS reverse_cost FROM or_network WHERE geometry && ST_Expand( (SELECT ST_Collect(the_geom) FROM or_network_vertices_pgr WHERE id IN (100828, 1136587)),5000)', 100828, 1136587, false, true);
  18. 18. Making things even better! • Update the QGIS plugin to use new PGR functions • Update the plugin to use a bounding box • Add restrictions (e.g. closures, safe routes) • How does psycopg2 work? Is it a bottleneck?
  19. 19. Not Mrs Beeton’s recipes http://anitagraser.com https://georepublic.info/en/blog http://workshop.pgrouting.org/index.html http://ghost.mixedbredie.net/tag/pgrouting
  20. 20. CC-BY-NC-SAReproducedwiththepermissionoftheNationalLibraryofScotland Thank you Ross McDonald Angus Council mcdonaldr@angus.gov.uk @mixedbredie 01307476419

×