postgis安装

0、环境说明:
主机名 IP 数据目录
dokcer 192.168.17.xxx /home/itm_pg/pgsql10.3

PostGIS是在对象关系型数据库PostgreSQL上增加了存储管理空间数据的能力的开源GIS数据库。GIS数据库,也叫空间数据库(Spatial database),是负责存储处理位置(空间)数据和非空间数据的数据库。

1、安装proj
[root@docker ~]# tar -xvf proj-5.2.0.tar
[root@docker ~]# cd proj-5.2.0
[root@docker ~]# ./configure --prefix=/home/itm_pg/pgsql10.3/plugin/proj
[root@docker ~]# make
[root@docker ~]# make install

2、安装GEOS
[root@docker ~]# tar -xvf geos-3.7.1.tar.bz2
[root@docker ~]# cd geos-3.7.1
[root@docker ~]#./configure --prefix=/home/itm_pg/pgsql10.3/plugin/proj/
[root@docker ~]# make
[root@docker ~]# make install

3、安装GDAL
[root@docker ~]# tar -xvf gdal-2.4.0rc1.tar
[root@docker ~]# cd gdal-2.4.0
[root@docker ~]#./configure --prefix=/home/itm_pg/pgsql10.3/plugin/proj/
[root@docker ~]# make
[root@docker ~]# make install

4、安装postgis
[root@docker ~]# tar -xvf postgis-2.5.1.tar
[root@docker ~]# cd postgis-2.5.1
[root@docker ~]#./configure --prefix=/home/itm_pg/pgsql10.3/plugin/postgis --with-pgconfig=/home/itm_pg/pgsql10.3/bin/pg_config --with-geosconfig=/home/itm_pg/pgsql10.3/plugin/proj/bin/geos-config --with-gdalconfig=/home/itm_pg/pgsql10.3/plugin/proj/bin/gdal-config --with-projdir=/home/itm_pg/pgsql10.3/plugin/proj/ --with-config=/home/itm_pg/pgsql10.3/
[root@docker ~]# make
[root@docker ~]# make install

至此便已经完成软件安装,接下来去数据库中创建extension即可。

itm_pg@docker-> psql
psql (10.3)
Type "help" for help.

postgres=# create extension postgis;
CREATE EXTENSION
postgres=# \dx
                                     List of installed extensions
  Name   | Version |   Schema   |                             Description       
                      
---------+---------+------------+-----------------------------------------------
----------------------
 plpgsql | 1.0     | pg_catalog | PL/pgSQL procedural language
 postgis | 2.5.1   | public     | PostGIS geometry, geography, and raster spatia
l types and functions
(2 rows)

注意事项:
创建extension时可能出现如下报错:

postgres=# create extension postgis;
ERROR:  could not load library "/home/itm_pg/pgsql10.3/lib/rtpostgis-2.5.so": libgdal.so.20: cannot open shared object file: No such file or directory

只需要找到libgdal.so.20文件,然后复制到/home/itm_pg/pgsql10.3/lib/目录下便可以了!

你可能感兴趣的:(postgis)