Install PostGIS on Rocky Linux 8|CentOS 8|AlmaLinux 8

Posted on 73 views

This guide will walk you through the steps of installing PostGIS onRocky Linux 8|CentOS 8|AlmaLinux 8 Linux. PostGIS is a PostgreSQL database extension which allows GIS (Geographic Information Systems) objects to be stored in the database. PostGIS is an open source software licensed under a Creative Commons Attribution-Share Alike 3.0 License.

PostGIS has support for GiST-based R-Tree spatial indexes and functions which aids in analysis and processing of GIS objects. Below are the core features of PostGIS.

Features of PostGIS

The PostGIS 2+ series provides:

  • 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

Follow the steps below to install PostGIS on Rocky Linux 8|CentOS 8|AlmaLinux 8 Linux system

Step 1: Install PostgreSQL Database server

PostgreSQL is a dependency for using PostGIS features. Install PostgreSQL on CentOS 8 using our guide below.

Step 2: Install PostGIS onRocky Linux 8|CentOS 8|AlmaLinux 8

After the installation of PostgreSQL and adding EPEL repository, proceed to install PostGIS from the PostgreSQL added. The repository was added using command like below:

sudo yum -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm

Enable EPEL and PowerTools repositories:

sudo dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo dnf install dnf-plugins-core
sudo dnf config-manager --set-enabled powertools

Disable default PostgreSQL AppStream repository.

sudo dnf -qy module disable postgresql

Install PostGIS for PostgreSQL 14:

sudo yum install postgis32_14

Install PostGIS for PostgreSQL 13:

sudo yum install postgis32_13

If you’re working on PostgreSQL 12, then run:

sudo yum install postgis32_12

Hit the key to start the installation.

....
Transaction Summary
======================================================================================================================================================================================================
Install  92 Packages

Total download size: 94 M
Installed size: 404 M
Is this ok [y/N]: y

This will install PostGIS v2.5 for PostgreSQL 12.

$ rpm -qi postgis32_14
Name        : postgis32_14
Version     : 3.2.1
Release     : 1.rhel8
Architecture: x86_64
Install Date: Wed May 18 17:25:52 2022
Group       : Unspecified
Size        : 36582866
License     : GPLv2+
Signature   : DSA/SHA1, Mon Feb 14 14:03:27 2022, Key ID 1f16d2e1442df0f8
Source RPM  : postgis32_14-3.2.1-1.rhel8.src.rpm
Build Date  : Mon Feb 14 14:01:01 2022
Build Host  : koji-rhel8-x86-64-pgbuild
Relocations : (not relocatable)
Vendor      : PostgreSQL Global Development Group
URL         : https://www.postgis.net/
Summary     : Geographic Information Systems Extensions to PostgreSQL
....

Step 3: Enable PostGIS Spatial features

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 test_user
[[email protected] ~]$ createdb test_db -O test_user

3.Connect to the test database:

[email protected] ~]$ psql -d test_db
psql (14.1)
Type "help" for help.

test_db=#

4.Enable the PostGIS extension on the database:

test_db=# CREATE EXTENSION postgis;
 CREATE EXTENSION

5. Verify

test_db=# SELECT PostGIS_version();
             postgis_version            
 3.2 USE_GEOS=1 USE_PROJ=1 USE_STATS=1
 (1 row)
test_db=# \q

Refer to Official PostGIS Documentation for a usage guide and advanced configurations.

Here are installation guides for other systems.

coffee

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