In this chapter, we will explore formal network-like geographic vector object relationships. Topological relationships are useful in many ways for geographical data management and analysis, but perhaps the most important application is optimal path finding. Specifically, you will learn how to make a few visualizations related to optimal paths: isochron polygons and accumulated traffic lines. With these visual elements as a background, we will incorporate social media feedback through Twitter in our web map application. The end result will be an application that communicates back and forth with the stakeholders about safe school routes.
In this chapter, we will cover the following topics:
Vector-based GIS, if not by definition then de facto, are organized around databases of geographic objects, storing their geometric definitions, geographic metadata, object relationships, and other attributes. Postgres is a leading open source relational database platform. Unlike SQLite, this is not a file-based system, but rather it requires a running service on an available machine, such as the localhost or an accessible server. The spatial extension to Postgres, PostGIS, provides all the functionalities around geospatial data, such as spatial references, geographic transformation, spatial relationships, and more. Most recently, PostGIS has come to support topology—the formal relationships between geometric objects. pgRouting is a topological analysis engine built around optimal path-finding. Conveniently, PostGIS now comes bundled with pgRouting. The following content applies to Postgres 9.3.
On Windows, you can use the Postgres installer to install PostGIS and pgRouting along with Postgres. On Mac, you can use the Kyngchaos binary installer found at http://www.kyngchaos.com/software/postgres. On Linux, you can refer to the PostGIS installation documentation for your distribution found at http://postgis.net/install/.
The installation instructions for Windows are as follows:
Now that we installed the Postgres database server with PostGIS, the pgRouting extensions, and the pgAdmin III client program, we want to create a new database where we can work. Perform the following steps:
Next, we need to tell Postgres that we want to use the PostGIS and pgRouting extensions with our new database. Perform the following steps:
CREATE EXTENSION postgis; CREATE EXTENSION pgrouting;