PostgreSQL supports many other tools in form of database extensions like UUID support, dblink. In the same way, it also supports geographic and spatial data with help of PostGIS. This blog will explain how to install PostGIS 2.5 which can be used by PostgreSQL 11.
There are many version of this spatial extension of database and currently it is on 3.0.2, however, in the blog we will explore how to install 2.5 on PostgreSQL 11 on Ubuntu. Since, we have already installed PostgreSQL 11, the required repository is already set. So Let’s start.
root@sanjeeva:/home/sanjeeva/postgres# apt install postgresql-11-postgis-2.5
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following additional packages will be installed:
gcc-7-base gdal-data libaec0 libarmadillo8 libarpack2 libblas3 libboost-serialization1.65.1 libboost-system1.65.1
libboost-thread1.65.1 libcgal13 libdap25 libdapclient6v5 libepsilon1 libfreexl1 libfyba0 libgdal20 libgeos-3.7.1 libgeos-c1v5
libgeotiff2 libgfortran4 libgif7 libgmpxx4ldbl libhdf4-0-alt libhdf5-100 libkmlbase1 libkmldom1 libkmlengine1 liblapack3
liblwgeom-2.5-0 libminizip1 libmysqlclient20 libnetcdf13 libnspr4 libnss3 libodbc1 libogdi3.2 libopenjp2-7 libpoppler73 libproj12
libprotobuf-c1 libqhull7 libquadmath0 libsfcgal1 libspatialite7 libsuperlu5 libsz2 liburiparser1 libxerces-c3.2 mysql-common
odbcinst odbcinst1debian2 poppler-data postgresql-11-postgis-2.5-scripts proj-bin proj-data
Suggested packages:
geotiff-bin gdal-bin libgeotiff-epsg libhdf4-doc libhdf4-alt-dev hdf4-tools libmyodbc odbc-postgresql tdsodbc unixodbc-bin
ogdi-bin poppler-utils ghostscript fonts-japanese-mincho | fonts-ipafont-mincho fonts-japanese-gothic | fonts-ipafont-gothic
fonts-arphic-ukai fonts-arphic-uming fonts-nanum postgis
The following NEW packages will be installed:
gcc-7-base gdal-data libaec0 libarmadillo8 libarpack2 libblas3 libboost-serialization1.65.1 libboost-system1.65.1
libboost-thread1.65.1 libcgal13 libdap25 libdapclient6v5 libepsilon1 libfreexl1 libfyba0 libgdal20 libgeos-3.7.1 libgeos-c1v5
libgeotiff2 libgfortran4 libgif7 libgmpxx4ldbl libhdf4-0-alt libhdf5-100 libkmlbase1 libkmldom1 libkmlengine1 liblapack3
liblwgeom-2.5-0 libminizip1 libmysqlclient20 libnetcdf13 libnspr4 libnss3 libodbc1 libogdi3.2 libopenjp2-7 libpoppler73 libproj12
libprotobuf-c1 libqhull7 libquadmath0 libsfcgal1 libspatialite7 libsuperlu5 libsz2 liburiparser1 libxerces-c3.2 mysql-common
odbcinst odbcinst1debian2 poppler-data postgresql-11-postgis-2.5 postgresql-11-postgis-2.5-scripts proj-bin proj-data
0 upgraded, 56 newly installed, 0 to remove and 0 not upgraded.
Need to get 29.5 MB of archives.
After this operation, 141 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://apt.postgresql.org/pub/repos/apt bionic-pgdg/main amd64 libgeos-3.7.1 amd64 3.7.1-1~pgdg18.04+1 [485 kB]
Get:2 http://archive.ubuntu.com/ubuntu bionic/main amd64 poppler-data all 0.4.8-2 [1479 kB]
Get:3 http://apt.postgresql.org/pub/repos/apt bionic-pgdg/main amd64 libgeos-c1v5 amd64 3.7.1-1~pgdg18.04+1 [64.1 kB]
Get:4 http://apt.postgresql.org/pub/repos/apt bionic-pgdg/main amd64 libsfcgal1 amd64 1.3.5-5~pgdg18.04+1 [1558 kB]
Get:5 http://apt.postgresql.org/pub/repos/apt bionic-pgdg/main amd64 liblwgeom-2.5-0 amd64 2.5.5+dfsg-1.pgdg18.04+1 [239 kB]
Get:6 http://apt.postgresql.org/pub/repos/apt bionic-pgdg/main amd64 postgresql-11-postgis-2.5-scripts all 2.5.5+dfsg-1.pgdg18.04+1 [845 kB]
Get:7 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 gcc-7-base amd64 7.5.0-3ubuntu1~18.04 [18.3 kB]
Get:8 http://archive.ubuntu.com/ubuntu bionic/universe amd64 gdal-data all 2.2.3+dfsg-2 [363 kB]
Get:9 http://archive.ubuntu.com/ubuntu bionic/universe amd64 libaec0 amd64 0.3.2-2 [18.1 kB]
Get:10 http://archive.ubuntu.com/ubuntu bionic/main amd64 libblas3 amd64 3.7.1-4ubuntu1 [140 kB]
Get:11 http://apt.postgresql.org/pub/repos/apt bionic-pgdg/main amd64 postgresql-11-postgis-2.5 amd64 2.5.5+dfsg-1.pgdg18.04+1 [2787 kB]
Get:12 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libquadmath0 amd64 8.4.0-1ubuntu1~18.04 [134 kB]
Get:13 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libgfortran4 amd64 7.5.0-3ubuntu1~18.04 [492 kB]
Get:14 http://archive.ubuntu.com/ubuntu bionic/main amd64 liblapack3 amd64 3.7.1-4ubuntu1 [2112 kB]
Get:15 http://archive.ubuntu.com/ubuntu bionic/universe amd64 libarpack2 amd64 3.5.0+real-2 [89.7 kB]
Get:16 http://archive.ubuntu.com/ubuntu bionic/universe amd64 libsuperlu5 amd64 5.2.1+dfsg1-3 [161 kB]
Get:17 http://archive.ubuntu.com/ubuntu bionic/universe amd64 libarmadillo8 amd64 1:8.400.0+dfsg-2 [81.9 kB]
Get:18 http://archive.ubuntu.com/ubuntu bionic/main amd64 libboost-serialization1.65.1 amd64 1.65.1+dfsg-0ubuntu5 [99.3 kB]
Get:19 http://archive.ubuntu.com/ubuntu bionic/main amd64 libboost-system1.65.1 amd64 1.65.1+dfsg-0ubuntu5 [10.5 kB]
Get:20 http://archive.ubuntu.com/ubuntu bionic/main amd64 libboost-thread1.65.1 amd64 1.65.1+dfsg-0ubuntu5 [43.2 kB]
Get:21 http://archive.ubuntu.com/ubuntu bionic/universe amd64 libcgal13 amd64 4.11-2build1 [275 kB]
Get:22 http://archive.ubuntu.com/ubuntu bionic/universe amd64 libdap25 amd64 3.19.1-2build1 [426 kB]
Get:23 http://archive.ubuntu.com/ubuntu bionic/universe amd64 libdapclient6v5 amd64 3.19.1-2build1 [88.9 kB]
Get:24 http://archive.ubuntu.com/ubuntu bionic/universe amd64 libepsilon1 amd64 0.9.2+dfsg-2 [41.2 kB]
Get:25 http://archive.ubuntu.com/ubuntu bionic/universe amd64 libfyba0 amd64 4.1.1-3 [110 kB]
Get:26 http://archive.ubuntu.com/ubuntu bionic/universe amd64 libfreexl1 amd64 1.0.5-1 [33.4 kB]
Get:27 http://archive.ubuntu.com/ubuntu bionic/universe amd64 proj-data all 4.9.3-2 [4020 kB]
Get:28 http://archive.ubuntu.com/ubuntu bionic/universe amd64 libproj12 amd64 4.9.3-2 [159 kB]
Setting up liblapack3:amd64 (3.7.1-4ubuntu1) …
update-alternatives: using /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3 to provide /usr/lib/x86_64-linux-gnu/liblapack.so.3 (liblapack.so.3-x86_64-linux-gnu) in auto mode
Setting up libnss3:amd64 (2:3.35-2ubuntu2.12) …
Setting up libsuperlu5:amd64 (5.2.1+dfsg1-3) …
Setting up libkmlbase1:amd64 (1.3.0-5) …
Setting up libogdi3.2 (3.2.0+ds-2) …
Setting up libpoppler73:amd64 (0.62.0-2ubuntu2.10) …
Setting up libgeos-c1v5:amd64 (3.7.1-1~pgdg18.04+1) …
Setting up libsfcgal1 (1.3.5-5~pgdg18.04+1) …
Setting up proj-bin (4.9.3-2) …
Setting up libgeotiff2:amd64 (1.4.2-2build1) …
Setting up libspatialite7:amd64 (4.3.0a-5build1) …
Setting up libarpack2:amd64 (3.5.0+real-2) …
Setting up libkmldom1:amd64 (1.3.0-5) …
Setting up liblwgeom-2.5-0 (2.5.5+dfsg-1.pgdg18.04+1) …
Setting up libhdf5-100:amd64 (1.10.0-patch1+docs-4) …
Setting up libarmadillo8 (1:8.400.0+dfsg-2) …
Setting up libkmlengine1:amd64 (1.3.0-5) …
Setting up libnetcdf13:amd64 (1:4.6.0-2build1) …
Setting up odbcinst1debian2:amd64 (2.3.4-1.1ubuntu3) …
Setting up odbcinst (2.3.4-1.1ubuntu3) …
Setting up libgdal20 (2.2.3+dfsg-2) …
Setting up postgresql-11-postgis-2.5 (2.5.5+dfsg-1.pgdg18.04+1) …
Processing triggers for libc-bin (2.27-3ubuntu1.2) …
Processing triggers for postgresql-common (220.pgdg18.04+1) …
Building PostgreSQL dictionaries from installed myspell/hunspell packages…
Removing obsolete dictionary files:
Processing triggers for man-db (2.8.3-2ubuntu0.1) …
root@sanjeeva:/home/sanjeeva/postgres#
To start using you need to create extension after logging to the database. We will explore this in next blog