How can I install PostGIS on CentOS 8?. This guide will walk you through the steps of installing PostGIS on CentOS 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 CentOS 8.
Step 1: Install PostgreSQL Database server
PostgreSQL is a dependency for using PostGIS features. Install PostgreSQL on CentOS 8 using our guide below.
How to install PostgreSQL on CentOS 8
Step 2: Install PostGIS on CentOS 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 config-manager --set-enabled PowerTools
Disable default PostgreSQL AppStream repository.
sudo dnf -qy module disable postgresql
Install PostGIS for PostgreSQL 12:
sudo yum install postgis25_12
If you’re working on PostgreSQL 11, then run:
sudo yum install postgis25_11
Hit the y key to start the installation.
CentOS-8 - AppStream 12 kB/s | 4.3 kB 00:00
CentOS-8 - Base 30 kB/s | 3.8 kB 00:00
CentOS-8 - Extras 11 kB/s | 1.5 kB 00:00
CentOS-8 - PowerTools 7.8 MB/s | 2.0 MB 00:00
Extra Packages for Enterprise Linux 8 - x86_64 43 kB/s | 31 kB 00:00
PostgreSQL 12 for RHEL/CentOS 8 - x86_64 19 kB/s | 3.8 kB 00:00
PostgreSQL 11 for RHEL/CentOS 8 - x86_64 30 kB/s | 3.8 kB 00:00
PostgreSQL 10 for RHEL/CentOS 8 - x86_64 8.1 kB/s | 3.8 kB 00:00
PostgreSQL 9.6 for RHEL/CentOS 8 - x86_64 19 kB/s | 3.8 kB 00:00
PostgreSQL 9.5 for RHEL/CentOS 8 - x86_64 7.3 kB/s | 3.8 kB 00:00
PostgreSQL 9.4 for RHEL/CentOS 8 - x86_64 6.2 kB/s | 3.8 kB 00:00
Dependencies resolved.
========================================================================================================================================================
Package Architecture Version Repository Size
========================================================================================================================================================
Installing:
postgis25_12 x86_64 2.5.3-6.rhel8 pgdg12 4.4 M
Installing dependencies:
blas x86_64 3.8.0-8.el8 AppStream 429 k
boost-serialization x86_64 1.66.0-6.el8 AppStream 128 k
lapack x86_64 3.8.0-8.el8 AppStream 8.6 M
mariadb-connector-c x86_64 3.0.7-1.el8 AppStream 148 k
mariadb-connector-c-config noarch 3.0.7-1.el8 AppStream 13 k
openblas x86_64 0.3.3-2.el8 AppStream 4.3 M
openblas-threads x86_64 0.3.3-2.el8 AppStream 4.4 M
qt5-qtbase x86_64 5.11.1-7.el8 AppStream 3.3 M
qt5-qtbase-common noarch 5.11.1-7.el8 AppStream 39 k
qt5-qtbase-gui x86_64 5.11.1-7.el8 AppStream 6.0 M
qt5-qtsvg x86_64 5.11.1-2.el8 AppStream 182 k
unixODBC x86_64 2.3.7-1.el8 AppStream 458 k
xcb-util-image x86_64 0.4.0-9.el8 AppStream 21 k
xcb-util-keysyms x86_64 0.4.0-7.el8 AppStream 16 k
xcb-util-renderutil x86_64 0.3.9-10.el8 AppStream 19 k
xcb-util-wm x86_64 0.4.1-12.el8 AppStream 32 k
atlas x86_64 3.10.3-7.el8 BaseOS 6.5 M
libgfortran x86_64 8.3.1-4.5.el8 BaseOS 638 k
libquadmath x86_64 8.3.1-4.5.el8 BaseOS 169 k
pcre2-utf16 x86_64 10.32-1.el8 BaseOS 228 k
SuperLU x86_64 5.2.0-7.el8 PowerTools 191 k
libaec x86_64 1.0.2-3.el8 PowerTools 39 k
libdap x86_64 3.19.1-2.el8 PowerTools 686 k
openblas-openmp x86_64 0.3.3-2.el8 PowerTools 4.4 M
openblas-threads64_ x86_64 0.3.3-2.el8 PowerTools 4.3 M
armadillo x86_64 9.700.2-1.el8 epel 38 k
arpack x86_64 3.7.0-1.el8 epel 194 k
cfitsio x86_64 3.47-1.el8 epel 577 k
freexl x86_64 1.0.5-4.el8 epel 34 k
hdf x86_64 4.2.14-5.el8 epel 651 k
hdf5 x86_64 1.10.5-4.el8 epel 2.1 M
libgeotiff x86_64 1.5.1-1.el8 epel 99 k
libgta x86_64 1.2.1-1.el8 epel 34 k
netcdf x86_64 4.7.0-2.el8 epel 647 k
ogdi x86_64 4.1.0-1.el8 epel 241 k
xerces-c x86_64 3.2.2-3.el8 epel 991 k
CGAL x86_64 4.14-1.rhel8 pgdg12 524 k
SFCGAL x86_64 1.3.7-2.rhel8 pgdg12 19 k
SFCGAL-libs x86_64 1.3.7-2.rhel8 pgdg12 1.9 M
gdal30-libs x86_64 3.0.2-1.rhel8 pgdg12 7.3 M
geos38 x86_64 3.8.0-1.rhel8 pgdg12 643 k
postgresql12-contrib x86_64 12.1-2PGDG.rhel8 pgdg12 2.4 M
proj62 x86_64 6.2.1-1.rhel8 pgdg12 1.8 M
Transaction Summary
========================================================================================================================================================
Install 44 Packages
Total download size: 70 M
Installed size: 338 M
Is this ok [y/N]: y
This will install PostGIS v2.5 for PostgreSQL 12.
$ rpm -qi postgis25_12
Name : postgis25_12
Version : 2.5.3
Release : 6.rhel8
Architecture: x86_64
Install Date: Mon 20 Jan 2020 10:40:35 PM EAT
Group : Unspecified
Size : 29786216
License : GPLv2
Signature : DSA/SHA1, Mon 04 Nov 2019 10:05:01 PM EAT, Key ID 1f16d2e1442df0f8
Source RPM : postgis25_12-2.5.3-6.rhel8.src.rpm
Build Date : Mon 04 Nov 2019 10:04:57 PM EAT
Build Host : koji-rhel8-x86-64-pgbuild
Relocations : (not relocatable)
Vendor : PostgreSQL Global Development Group
URL : http://www.postgis.net/
Summary : Geographic Information Systems Extensions to PostgreSQL
Description :
....
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.
-bash-4.2$ createuser test_user -bash-4.2$ createdb test_db -O test_user
3.
Connect to the test database:
$ psql -d test_db psql (12.1) Type "help" for help.
4.
Enable the PostGIS extension on the database:
test_db=# CREATE EXTENSION postgis; CREATE EXTENSION
5.
Verify
test_db=# SELECT PostGIS_version(); postgis_version 2.5 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.