CentOS安装PostGIS

PostGIS是PostgreSQL的一个插件,需要注意其版本匹配关系,详细的版本匹配关系可以在官网(https://trac.osgeo.org/postgis/wiki/UsersWikiPostgreSQLPostGIS)上找到。

1、安装epel

yum -y install epel-release

2、安装PostGIS

版本号格式为:_前为postgis版本,后面为postgresql版本。

yum install postgis2_96

这里匹配的是PostGIS2.4版本。

3、新建扩展 

安装完postgis后,需要先激活数据库上的PostGIS功能,然后才能存储空间数据,才可以使用空间数据库功能。

切换到操作系统的postgres用户

sudo -i -u postgres

连接到数据库

-bash-4.2$ psql -d scgis

新建扩展

scgis=# CREATE EXTENSION postgis;

附完整的扩展

-- Enable PostGIS (includes raster)
CREATE EXTENSION postgis;
-- Enable Topology
CREATE EXTENSION postgis_topology;
-- Enable PostGIS Advanced 3D 
-- and other geoprocessing algorithms
-- sfcgal not available with all distributions
CREATE EXTENSION postgis_sfcgal;
-- fuzzy matching needed for Tiger
CREATE EXTENSION fuzzystrmatch;
-- rule based standardizer
CREATE EXTENSION address_standardizer;
-- example rule data set
CREATE EXTENSION address_standardizer_data_us;
-- Enable US Tiger Geocoder
CREATE EXTENSION postgis_tiger_geocoder;

CREATE EXTENSION ogr_fdw;
CREATE EXTENSION pgrouting;
CREATE EXTENSION pointcloud;
CREATE EXTENSION pointcloud_postgis;

验证PostGIS版本

scgis=# SELECT PostGIS_version();
scgis=# SELECT postgis_full_version();

验证PostgreSQL的版本

scgis=# select version();

参考:

https://www.cnblogs.com/giser-s/p/11195697.html

原文地址:https://www.cnblogs.com/hans_gis/p/12640656.html