PostGIS 2.2, PostgreSQL 9.5 install guide

Regina Obe and Leo Hsu

Book in progress: pgRouting: A Practical Guide http://locatepress.com/pgrouting

http://www.postgis.us / http://www.bostongis.com / http://www.postgresonline.com
Using RevealJS

Navigating the Slides

To toggle between full slide deck and individual, use the ESC key.

Use s key to see the slide notes.

These instructions apply to all the slides we'll be posting. Best experienced with Firefox or Chrome.

Where to Get it?

There are many

Covered here: http://postgis.net/install, but we'll repeat a bit.

Mac

Quickest and Newbie friendly http://postgresapp.com. Has PostgreSQL 9.5 and PostGIS 2.2, but as of this writing does not have SFCGAL or pgRouting or ogr_fdw.

Homebrew another popular option http://braumeister.org/formula/postgis

Latest recipes include PostgreSQL 9.5, PostGIS 2.2.1 (with sfcgal 1.2.2), pgRouting 2.1

Windows

Downloads and instructions here: http://postgis.net/windows_downloads

  • Stable version: Get from Application Stackbuilder. PostGIS 2.2 (with SFCGAL 1.2) for PostgreSQL 9.3-9.5, includes pgRouting 2.1, ogr_fdw, and pgpointcloud companion extensions.
  • Bleeding Edge including with SFCGAL 3D support and PostGIS 2.3 (built for PostgreSQL 9.3-9.5) - get from Winnie, the PostGIS windows build-bot. Winnie builds a fresh pot whenever any changes in PostGIS code base. She has updates for stable releases as well.

RedHat EL, CentOS, Scientific Linux

RedHat EL, CentOS, Scientific Linux, Amazon Linux: Use PostgreSQL Yum repo: http://yum.postgresql.org

Some instructions you might find useful: An almost idiot's guide to install PostgreSQL 9.5, PostGIS 2.2 and pgRouting 2.1.0 with Yum

Ubuntu and Debian

Create a database

Create a database if you don't have one already. No postgres database does not count, and please don't install PostGIS in postgres.

CREATE DATABASE presentation;

If your distribution did not come with raster or running with lower than PostgreSQL 9.1, Sorry, can't use CREATE EXTENSION. Go here

Extensions: Spatially enable your database

Connect to your database first and then run the below commands

CREATE EXTENSION postgis;
CREATE EXTENSION hstore; --popularly used with OSM data
CREATE EXTENSION fuzzystrmatch;
CREATE EXTENSION postgis_tiger_geocoder;
CREATE EXTENSION postgis_topology;

Other extensions commonly used or packaged with PostGIS

CREATE EXTENSION pgrouting;
-- You'll see these more in PostGIS 2.2
CREATE EXTENSION postgis_sfcgal; --not always present
CREATE EXTENSION address_standardizer; 
CREATE EXTENSION pointcloud; --usually packaged separately
CREATE EXTENSION pointcloud_postgis; --usually packaged separately
CREATE EXTENSION ogr_fdw; --usually packaged separately

No Extensions: Spatially enable your database

Connect to your database first preferably using psql and then run the following scripts which are usually located in /share/contrib/postgis-2.1 of your postgresql install.

\i postgis.sql
\i spatial_ref_sys.sql
-- if you happen to have raster and want it
\i rtpostgis.sql

For tiger geocoder, run the correct scripts Tiger geocoder install without extensions.

Verify install of PostGIS

SELECT postgis_full_version();

POSTGIS="2.2.1 r14555" GEOS="3.5.0-CAPI-1.9.0 r4090" PROJ="Rel. 4.9.1, 04 March 2015" 
GDAL="GDAL 2.0.1, released 2015/09/15" LIBXML="2.7.8" LIBJSON="0.12" RASTER

If you have sfcgal extension installed as well, then your output will look like:

POSTGIS="2.2.1 r14555" GEOS="3.5.0-CAPI-1.9.0 r4090" SFCGAL="1.2.2" PROJ="Rel. 4.9.1, 04 March 2015" 
GDAL="GDAL 2.0.1, released 2015/09/15" LIBXML="2.7.8" LIBJSON="0.12" RASTER

Verify install of pgRouting

SELECT * FROM pgr_version();
 version |       tag       | build |  hash   | branch | boost
---------+-----------------+-------+---------+--------+--------
 2.1.0   | pgrouting-2.1.0 | 1     | b38118a | master | 1.59.0