Book Image

Mastering PostGIS

By : Dominik Mikiewicz, Michal Mackiewicz , Tomasz Nycz
Book Image

Mastering PostGIS

By: Dominik Mikiewicz, Michal Mackiewicz , Tomasz Nycz

Overview of this book

PostGIS is open source extension onf PostgreSQL object-relational database system that allows GIS objects to be stored and allows querying for information and location services. The aim of this book is to help you master the functionalities offered by PostGIS- from data creation, analysis and output, to ETL and live edits. The book begins with an overview of the key concepts related to spatial database systems and how it applies to Spatial RMDS. You will learn to load different formats into your Postgres instance, investigate the spatial nature of your raster data, and finally export it using built-in functionalities or 3th party tools for backup or representational purposes. Through the course of this book, you will be presented with many examples on how to interact with the database using JavaScript and Node.js. Sample web-based applications interacting with backend PostGIS will also be presented throughout the book, so you can get comfortable with the modern ways of consuming and modifying your spatial data.
Table of Contents (9 chapters)

pgRouting algorithms


pgRouting is equipped with quite a few algorithms specialized in different aspects of routing. Although all are routing algorithms, for the sake of convenience, let's split them into the following artificial functional groups:

  • All pairs shortest path
  • Shortest Path
  • Driving distance
  • Traveling Sales Person

 

 

All pairs shortest path

All pairs shortest path algorithms are good for calculating the total costs of the shortest path for each node in the graph. There are two of those available in pgRouting:

  • All pairs shortest path, Johnson's algorithm: Good for calculating costs over sparse graphs
  • All pairs shortest path, Floyd-Warshall algorithm: Good for calculating costs over dense graphs

Let's give it a shot:

select * from pgr_floydWarshall('select gid as id, the_geom, source::int4, target::int4, cost::float from pgr.ways where ST_Intersects(the_geom, ST_MakeEnvelope(16.3618,48.2035,16.3763,48.2112,4326))', false); 

This query picks roughly a thousand of the edges of Vienna city center...