How To Install PostGIS on Debian 11 / Debian 10

Posted on 175 views

In this blog post we discuss how you can install PostGIS on Debian 11 / Debian 10 Linux system. PostGIS is an open source extension for the powerful PostgreSQL relational database system. It enables you to create Geographic objects on the PostgreSQL database server. The features of PostGIS are derived from Open Geospatial Consortium SQL specifications.

PostGIS is installable on most Linux distributions, Windows and macOS operating systems. We’ll add the PostGIS APT repository for PostgreSQL then install PostGIS on Debian system from the repository to get the latest releases of the package.

Some key features of PostGIS extension are:

  • Processing and analytic functions for both vector and raster data for splicing, dicing, morphing, reclassifying, and collecting/unioning with the power of SQL
  • raster map algebra for fine-grained raster processing
  • Spatial reprojection SQL callable functions for both vector and raster data
  • Support for importing / exporting ESRI shapefile vector data via both commandline and GUI packaged tools and support for more formats via other 3rd-party Open Source tools
  • Packaged command-line for importing raster data from many standard formats: GeoTiff, NetCDF, PNG, JPG to name a few
  • Rendering and importing vector data support functions for standard textual formats such as KML,GML, GeoJSON,GeoHash and WKT using SQL
  • Rendering raster data in various standard formats GeoTIFF, PNG, JPG, NetCDF, to name a few using SQL
  • Seamless raster/vector SQL callable functions for extrusion of pixel values by geometric region, running stats by region, clipping rasters by a geometry, and vectorizing rasters
  • 3D object support, spatial index, and functions
  • Network Topology support
  • Packaged Tiger Loader / Geocoder/ Reverse Geocoder / utilizing US Census Tiger data

Step 1: Update system

Update the package repository index by running the following commands in your terminal.

sudo apt update

You can install other basic tools

sudo apt install wget curl gnupg2 software-properties-common apt-transport-https

Step 2: Add PostgreSQL repository

Pull packages signing GPG key from PostgreSQL website

wget --quiet -O - | sudo apt-key add -

Then add PostgreSQL repository to your Debian system:

echo "deb `lsb_release -cs`-pgdg main" |sudo tee  /etc/apt/sources.list.d/pgdg.list

Step 3: Install PostgreSQL Database Server

PostgreSQL is required to be installed before installation of PostGIS on Debian. Use our previous guides for this installation.

Once you’ve installed and configured PostgreSQL Database Server on your Debian system you can proceed with the installation of PostGIS extension.

Step 4: Install PostGIS on Debian 11 / Debian 10

After the installation of PostgreSQL, proceed to install PostGIS on Debian 11 / Debian 10 Linux system.

For PostgreSQL 14:

sudo apt update
sudo apt install postgis postgresql-14-postgis-3

For PostgreSQL 13:

sudo apt update
sudo apt install postgis postgresql-13-postgis-3

For PostgreSQL 12:

sudo apt update
sudo apt install postgis postgresql-12-postgis-3

Step 5: Enable PostGIS onDebian 11 / Debian 10

You need to activate PostGIS features on a database before you can store spacial data. The example below will show you how to create a database and activate the Spacial features.

1.Switch to postgres user.

sudo -i -u postgres

2.Create test user/database.

[email protected]:~$ createuser postgis_user
[email protected]:~$ createdb postgis_db -O postgis_user

3.Connect to the test database:

[email protected]:~$ psql -d postgis_db
psql (14.1 (Debian 14.1-1.pgdg110+1))
Type "help" for help.

4.Enable the PostGIS extension on the database:

postgis_db=# CREATE EXTENSION postgis;

5. Verify PostGIS is working

postgis_db=# SELECT PostGIS_version();
(1 row)

Comprehensive usage guide is available in the official PostGIS Documentation website.

PostGIS installation on other Linux distributions


Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.