CentOS7下安裝PostGIS

CentOS7下安裝PostGIS

注意 本人的博客都遷移到本人自己搭建的博客地址,通過此處可查看。

寫在安裝之前

PostGIS的安裝和運行需要在PostgreSQL環境下,故本人安裝的環境是:

  • CentOS 7 64位

  • PostgreSQL 10.3,具體安裝可參考CentOS7 下安裝 PostgreSQL10

  • PostGIS 2.4.3, 安裝過程看本文介紹

  • geos 3.4.2, 可以使用yum install geos geos-devel

  • gdal 1.11.4, 可以使用yum install jdal gdal-devel

  • libxml 2 2.9.1, 可以使用yum install libxml libxml-devel

  • proj 4.8.0, 可以使用yum install proj proj-devel

  • json-c 0.11, 可以使用yum install json-c json-c-devel

  • pcre 8.32, 可以使用yum install pcre pcre-devel

注: 具體PostgreSQL與PostGIS之間版本的對應可查看osgeo官網說明文檔

PostGIS及其擴展的安裝

  1. 安裝PostGIS

    wget https://download.osgeo.org/postgis/source/postgis-2.4.3.tar.gz
    
    tar -zxvf postgis-2.4.3.tar.gz
    
    cd postgis-2.4.3
    
    ./configure --with-pgconfig=/usr/local/pgsql/bin/pg_config
    
    make
    
    make install
    
  2. 安裝PostGIS擴展

    PostGIS擴展文件在解壓後的源文件夾的extension文件夾下,具體安裝如下所示:

    cd extension
    
    cd postgis_sfcgal
    
    make clean & make & make install
    
    cd postgis_tiger_geocoder
    
    make clean & make & make install
    
    cd postgis_topology
    
    make clean & make & make install
    
    cd address_standardizer
    
    make clean & make & make install
    
    

在PostgresSQL數據庫創建PostGIS

  1. 使用已有的sql文件創建

    所有的SQL語句文件在PostGIS安裝成功後,存放在/usr/local/pgsql/data/share/contrib/postgis-2.4/文件夾下

    具體使用方法:

    
    ./bin/psql -d postgisdb -f ./share/contrib/postgis-
    2.4/postgis.sql
    
    ./bin/psql -d postgisdb -f ./share/contrib/postgis-
    2.4/postgis_comments.sql
    
    ./bin/psql -d postgisdb -f ./share/contrib/postgis-
    2.4/spatial_ref_sys.sql
    
    ./bin/psql -d postgisdb -f ./share/contrib/postgis-
    2.4/topology.sql
    
    ./bin/psql -d postgisdb -f ./share/contrib/postgis-
    2.4/topology_comments.sql
    
    --Raster--
    ./bin/psql -d postgisdb -f ./share/contrib/postgis-
    2.4/rtpostgis.sql
    
    ./bin/psql -d postgisdb -f ./share/contrib/postgis-
    2.4/raster_comments.sql
    
    -sfcgal--
    ./bin/psql -d postgisdb -f ./share/contrib/postgis-
    2.4/sfcgal.sql
    
    ./bin/psql -d postgisdb -f ./share/contrib/postgis-
    2.4/sfcgal_comments.sql
    
  2. 通過語言創建

    具體創建方式如下:

    ./bin/psql -d postgisdb -c "CREATE EXTESNSION postgis"
    
    ./bin/psql -d postgisdb -c "CREATE EXTESNSION postgis_topology"
    
發佈了53 篇原創文章 · 獲贊 29 · 訪問量 6萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章