postgresql 10.9 源码安装postgis空间数据库扩展模块

#安装PROJ
-- PROJ是一个通用的坐标转换软件,它将地理空间坐标从一个坐标系转换为另一个坐标系。这包括地图投影和大地坐标变换。
wget http://download.osgeo.org/proj/proj-4.9.3.tar.gz
tar -xvf  proj-4.9.3.tar.gz 
cd proj-4.9.3
./configure --prefix=/usr/local/proj/
make
make install
echo "/usr/local/proj/lib/" > /etc/ld.so.conf.d/proj-4.9.3.conf
ldconfig

#安装Geos库
-- GEOS是一个集合形状的拓扑关系操作实用库(可能这么说不太准确),简单得说,就是判断两个几何形状之间关系和对两个几何形状进行操作以形成新的几何形状的库。
wget http://download.osgeo.org/geos/geos-3.7.3.tar.bz2
tar -xvf geos-3.7.3.tar.bz2
cd geos-3.7.3
./configure --prefix=/usr/local/geos/
make
make install
echo "/usr/local/geos/lib/" > /etc/ld.so.conf.d/geos-3.7.3.conf
ldconfig

#GDAL 地理数据格式操作库
wget http://download.osgeo.org/gdal/2.1.2/gdal-2.1.2.tar.gz
tar -xvf  gdal-2.1.2.tar.gz
cd gdal-2.1.2
./configure --prefix=/usr/local/gdal
make
make install
echo "/usr/local/gdal/lib" > /etc/ld.so.conf.d/gdal-2.1.2.conf
ldconfig

#安装postgis依赖
yum -y install perl-devel
yum -y install libxml2-devel

#安装postgis库
wget http://download.osgeo.org/postgis/source/postgis-2.5.0.tar.gz
tar -xvf postgis-2.5.0.tar.gz
cd postgis-2.5.0
./configure --with-pgconfig=/usr/local/pgsql/bin/pg_config --with-geosconfig=/usr/local/geos/bin/geos-config --with-gdalconfig=/usr/local/gdal/bin/gdal-config  --with-projdir=/usr/local/proj  --prefix=/usr/local/pgsql/contrib/postgis
make
make install

#测试
postgres=# select * from pg_available_extensions where name like 'postgis%';
          name          | default_version | installed_version |                               comment                               
------------------------+-----------------+-------------------+---------------------------------------------------------------------
 postgis                | 2.5.0           |                   | PostGIS geometry, geography, and raster spatial types and functions
 postgis_tiger_geocoder | 2.5.0           |                   | PostGIS tiger geocoder and reverse geocoder
 postgis_topology       | 2.5.0           |                   | PostGIS topology spatial types and functions
(3 rows)

postgres=# CREATE EXTENSION PostGIS;
CREATE EXTENSION
postgres=# CREATE EXTENSION postgis_topology;
CREATE EXTENSION
postgres=# CREATE EXTENSION  fuzzystrmatch;
CREATE EXTENSION
postgres=# CREATE EXTENSION postgis_tiger_geocoder;
CREATE EXTENSION

你可能感兴趣的:(pgsql,postgresql)