• [zz] 安装PostGIS(Linux篇)


    0.安装PostgreSQL数据库

       参考安装PostgreSQL数据库(Linux篇)

    1.安装proj4

    #tar zxvf proj-4.8.0.tar.gz

    #cd proj-4.8.0

    #./configure --prefix=/opt/proj-4.8.0
    #make
    #make install
    #ls /opt/proj-4.8.0

    编辑文件/etc/ld.so.conf.d/proj-4.8.0.conf
    #vi /etc/ld.so.conf.d/proj-4.8.0.conf
    添加以下内容
    /opt/proj-4.8.0/lib

    保存并退出vi
    执行以下命令,将proj4的so库的路径添加到系统中
    #ldconfig 

    2.安装geos
    #tar jxvf geos-3.3.7.tar.bz2

    #cd geos-3.3.7
    #./configure --prefix=/opt/geos-3.3.7
    #make
    #make install

    编辑文件/etc/ld.so.conf.d/geos-3.3.7.conf
    #vi /etc/ld.so.conf.d/geos-3.3.7.conf
    添加以下内容
    /opt/geos-3.3.7/lib
    保存并退出vi
    执行以下命令,将proj4的so库的路径添加到系统中
    #ldconfig

    3. 安装postgis

    #tar zxvf postgis-1.5.8.tar.gz
    #cd postgis-1.5.8
    #./configure --with-pgconfig=/opt/pgsql-9.1.7/bin/pg_config
                      --with-geosconfig=/opt/geos-3.3.7/bin/geos-config
                      --with-projdir=/opt/proj-4.8.0/

    #make 

    #make install
    postgis会安装到postgresql的目录下。
    例如:shp2pgsql安装到/opt/pgsql-9.1.7/bin目录下

    postgis的sql脚本安装在/opt/pgsql-9.1.7/share/contrib/postgis-1.5路径下

     至此,完成postgis的安装
     

    4.创建postgis数据库

    1) 启动postgresql数据库
    2) 切换到postgres用户
    #su - postgres
    3) 创建数据库postgis
    $createdb postgis

    创建完成后就可以通过下面的命令登录postgis数据库
    $psql -h 127.0.0.1 -d postgis -U postgres

    此时的postgis数据库只是一个普通的一个postgresql数据库,并没有用户表。

    4) 创建postgis空间数据库

    postgis空间数据库由一系列的postgis函数、数据类型、触发器等构成。
    postgis空间数据库的脚本路径为:/opt/pgsql-9.1.7/share/contrib/postgis-1.5/postgis.sql
    执行以下命令,在postgis数据库上创建postgis的函数、数据类型等资源
    $ psql -h 127.0.0.1 -d postgis -U postgres -f /opt/pgsql-9.1.7/share/contrib/postgis-1.5/postgis.sql

    可以看出postgis创建了一系列的函数

    5) 创建postgis空间数据库的空间参考表

    postgis空间数据库的空间参考表脚本路径为:/opt/pgsql-9.1.7/share/contrib/postgis-1.5/spatial_ref_sys.sql
    $psql -h 127.0.0.1 -d postgis -U postgres -f /opt/pgsql-9.1.7/share/contrib/postgis-1.5/spatial_ref_sys.sql
    该命令在postgis数据库中创建了spatial_ref_sys表,用于存放空间投影信息。

    至此,完成postgis空间数据库的创建。现在就可以向postgis数据库中导入shape图层文件,进行空间查询等操作。

    5.导入shape图层

    1) 启动"Shapefile and DBF Loader Exporter"

    2) 连接postgis数据库

       

    3) 点击"Add File"按钮,选择要导入的shapefile文件

     

    4) 点击"Import"按钮导入shape文件

     

    4) 导入完成后,可以在pgAdmin中看到刚刚导入的3个图层

    转自:http://www.cnblogs.com/marsprj/archive/2013/02/08/2909413.html

  • 相关阅读:
    矩阵的应用
    PyTorch工具
    python不同开根号速度对比
    GloVe损失函数的理解
    课程回顾-Convolutional Neural Networks
    课程回顾-Structuring Machine Learning Projects
    课程回顾-Improving Deep Neural Networks: Hyperparameter tuning, Regularization and Optimization
    课程回顾-Neural Network & Deep Learning
    使用GOOGLE COLAB训练深度学习模型
    如何使用Keras的Model visualization功能
  • 原文地址:https://www.cnblogs.com/geosky/p/install_postgis_linux.html
Copyright © 2020-2023  润新知