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();
參考: