How to install PostGIS on Ubuntu 16.04

Today’s post is going to be sort of like a memo card which shows how we could install PostGIS on a fresh install of Ubuntu 16.04.

Installing PostGIS

To install PostGIS first, type the following into the command line:

sudo apt-get install postgis

Enabling PostGIS in your database

Once PostGIS installed you’ll need to enable it as an extension in your PostgreSQL database. To do so open the psql prompt by typing:

sudo -u postgresql psql

This takes you right to the psql console where the next step is connecting to your database.

\c your-database

In your database it takes only a single line of SQL to enable PostGIS that you have just installed:


CREATE EXTENSION postgis;

If you have done everything correctly, you should see the following results when you run SELECT PostGIS_version();

postgis_version
---------------------------------------
2.4 USE_GEOS=1 USE_PROJ=1 USE_STATS=1
(1 row)

Leave a Reply

Your email address will not be published. Required fields are marked *