How to Install PostGIS on Ubuntu 18.04

Hello everyone, welcome to our GIS Tutorial. In this tutorial, I am going to show you how to install PostGIS on Ubuntu 18.04 Bionic Beaver. Before we go through the installation steps, let’s have a look at PostGIS. PostGIS is a special spatial extension for PostgreSQL. With this extension, we can store spatial and geometry information to a table or database. PostGIS is a powerful way to store our GIS datasets. PostGIS extension is not enabled by default on standard PostgreSQL installation. We need to enable the extension on each database we want.

This tutorial is based on Ubuntu 18.04. It could be slightly different on other systems. Most of the installation processes uses Terminal command. But I don’t think it is complicated. Please follow each steps on this tutorial to install PostGIS on Ubuntu 18.04. I have been using my PostGIS until now and found no issues.

What you will learn

  • Install PostgreSQL on Ubuntu
  • Install PostGIS on Ubuntu
  • Enable PostGIS extension

Lesson 1. Install PostgreSQL

Skip this step if you have PostgreSQL installed. To install PostgreSQL on Ubuntu 18.04, follow these steps.

  1. Download PostgreSQL package for Linux by EnterpriseDB
  2. Make the package executable
    sudo chmod +x postgresql-9.6.9-1-linux-x64.run
  3. Run the installer
    sudo ./postgresql-9.6.9-1-linux-x64.run
  4. The GUI installation wizard will open up.

    Specify the installation directory. Leave the default value if you don’t want to change the location.
    Specify the data directory
    Provide password for the postgres superuser


    Select Locale


    Wait until the installation is completed


    install postgis on ubuntu

    In some cases, due to missing dependencies, the StackBuilder won’t come up. StackBuilder is an additional tool that helps us to add some functionality to PostgreSQL.

Lesson 2. Install PostGIS on Ubuntu 18.04

On the previous lesson, you have successfully installed PostgreSQL on Ubuntu 18.04. Now, let’s continue to install postgis on Ubuntu 18.04. Use the following command to install postgis

sudo apt install postgis

Output

Now Install PgAdmin4. PgAdmin is a web-based tool to manage PostgreSQL server.

sudo apt install pgadmin4

After this, there should be a PgAdmin4 icon in your Ubuntu applications list.  Open it to start configuring the server.

Lesson 3. Create New Database via PgAdmin4

Open PgAdmin4 and watch the following video to connect to PostgreSQL and create a new database. On the following video, you can also see how to create or enable postgis extension on a database.

You will need to open this video from a PC. Otherwise, the video will not play.

Conclusion

On this tutorial, we learned few things: install PostgreSQL, PgAdmin4, PostGIS and then enable postgis extension on a database. This tutorial is far from a good tutorial but I hope this tutorial is useful for anyone who wants to install PostGIS on Ubuntu 18.04. Maybe I will post more stuff like this in the future.