How to install PostGIS

By Dillon Smart · · · 0 Comments

PostGIS is a plugin which adds support for storing, indexing and querying geographic data in PostgreSQL databases.

To get started with PostGIS, you will need to install the extension on your PostgreSQL database. If you are using PostgreSQL as a service from a cloud provider, you may already have PostGIS installed.

How to check if PostGIS is installed

You can check if PostGIS is installed either by the command line or by executing a simple SQL query.

Via the command line:

\dx

Via SQL:

select * from pg_extension

Using both these methods, you can see all extensions installed on your PostgreSQL database.

Install PostGIS on MacOS

To install PostGIS on MacOS you must first install Homebrew, the widely used package managed for MacOS.

Follow the instructions on the Homebrew website to get started.

Open a new terminal window and install PostGIS via homebrew.

brew install postgis

Once the installation has completed, connect to your PostgreSQL database via the terminal or use a database management tool such as TablePlus, DBeaver or PgAdmin.

Once connected to your database, create the PostGIS exention by executing the following command:

CREATE EXTENSION postgis;

Install PostGIS on Windows

To install PostGIS on windows, follow the installation instructions from the official website.

Once the installation has completed, connect to your PostgreSQL database.

Similar to MacOS, once you have connected to your database, execute the following command:

CREATE EXTENSION postgis;

This step can also be completed using a database management GUI.

Install PostGIS on Ubuntu

To install PostGIS on Ubuntu, you will need to install the apt package.

sudo apt-get install postgis

Again, similar to MacOS and Windows, connect to your database via the command line or use a database management tool to execute the following command:

CREATE EXTENSION postgis;

PostGISPostgreSQL

0 Comment

Was this helpful? Leave a comment!

This site uses Akismet to reduce spam. Learn how your comment data is processed.

How to transform geometries with PostGIS

Updated 2nd October 2023

PostGIS is a power extention for PostgreSQL databases. It provides a suite of tools to handle and manipulate geographic data. At times, you may need to transform geometries with PostGIS for different base maps or to perform more accurate calculations, such as calculating the area of a polygon. Transform geometry with PostGIS PostGIS has a

SQL Union – What is a Union and how to combine two or more SQL Select queries

Updated 1st December 2023

The SQL UNION Operator is used to combine two or more SELECT statements together into one set of results. Things to know about SQL Union Operator To execute a SQL UNION statement successfully, you need to be away of the requirements of a UNION statement. Example using SQL UNION In our example we have 2