linux下postgis安装
// 安装EPEL源
# rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
// 安装PostGIS9.4
# yum install -y postgis24_94
// 安装PostGIS10+postgresql10
# yum install -y postgis24_10
提示:还有一些系统的,可以在上级目录找到(http://dl.fedoraproject.org/pub/epel/)
# CentOS 7, RHEL 7 64-bit:
# rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
# CentOS 6, RHEL 6 64-bit:(这里根据自已的系统版本作选择)
# rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
开启PostgreSQL的PostGIS扩展并验证
// 开启插件
# su postgres
# psql
// 开启pgsql的插件
postgres=# create extension postgis;
postgres=# create extension postgis_topology;
postgres=# create extension fuzzystrmatch;
postgres=# create extension address_standardizer;
postgres=# create extension address_standardizer_data_us;
postgres=# create extension postgis_tiger_geocoder;
// 测试验证
-- 创建表
postgres=# create table mytable (
id serial primary key,
geom geometry(point, 26910),
name varchar(128)
);
-- 添加索引
postgres=# create index mytable_gix
on mytable
using gist (geom);
-- 添加一条数据
postgres=# insert into mytable (geom) values (
st_geomfromtext('point(0 0)', 26910)
);
-- 测试查询,正常能查出一条数据
postgres=# select id, name
from mytable
where st_dwithin(
geom,
st_geomfromtext('point(0 0)', 26910),
1000
);
window下postgis安装
postgis9.3/9.4 对应的要安装postgresql9.3/9.4的数据库版本
9.4版本
postgis-bundle-pg94x64-setup-2.3.2-1.exe
postgresql-9.4.17-1-windows-x64.exe
9.3版本
postgis-bundle-pg93x64-setup-2.2.3-1.exe
postgresql-9.3.17-1-windows-x64.exe
对已安装好的postgis组件
打开一个新创建的postgresql数据库执行如下命令可扩展为postgis空间数据库
create extension postgis;
然后可以用QGIS软件导入shp文件到postgis空间数据库中
arcgis 10.3下安装postgresql支持
64位机
1、安装postgresql9.3.x
2、安装arcgis 10.3桌面版
3、安装arcsde 10.2 for postgresql
4、将PostgreSQL\9.3\Windows64下的st_geometry.dll、libst_raster_pg.dll文件复制到postgresql\9.3\lib\下
5、将postgresql\9.3\bin\下的libeay32.dll、libintl-8.dll、libpq.dll、iconv.dll、ssleay32.dll复制到arcgis\bin下
postgresql数据库开放本地模式为互联模式
需要修改postgresql安装目录下文件:
D:\PostgreSQL\9.3\data\pg_hba.conf
在# IPv4 local connections:下添加如下一行
host all all 0.0.0.0/0 trust
完整文件内容:D:\PostgreSQL\9.3\data\pg_hba.conf
# PostgreSQL Client Authentication Configuration File
# ===================================================
#
# Refer to the "Client Authentication" section in the PostgreSQL
# documentation for a complete description of this file. A short
# synopsis follows.
#
# This file controls: which hosts are allowed to connect, how clients
# are authenticated, which PostgreSQL user names they can use, which
# databases they can access. Records take one of these forms:
#
# local DATABASE USER METHOD [OPTIONS]
# host DATABASE USER ADDRESS METHOD [OPTIONS]
# hostssl DATABASE USER ADDRESS METHOD [OPTIONS]
# hostnossl DATABASE USER ADDRESS METHOD [OPTIONS]
#
# (The uppercase items must be replaced by actual values.)
#
# The first field is the connection type: "local" is a Unix-domain
# socket, "host" is either a plain or SSL-encrypted TCP/IP socket,
# "hostssl" is an SSL-encrypted TCP/IP socket, and "hostnossl" is a
# plain TCP/IP socket.
#
# DATABASE can be "all", "sameuser", "samerole", "replication", a
# database name, or a comma-separated list thereof. The "all"
# keyword does not match "replication". Access to replication
# must be enabled in a separate record (see example below).
#
# USER can be "all", a user name, a group name prefixed with "+", or a
# comma-separated list thereof. In both the DATABASE and USER fields
# you can also write a file name prefixed with "@" to include names
# from a separate file.
#
# ADDRESS specifies the set of hosts the record matches. It can be a
# host name, or it is made up of an IP address and a CIDR mask that is
# an integer (between 0 and 32 (IPv4) or 128 (IPv6) inclusive) that
# specifies the number of significant bits in the mask. A host name
# that starts with a dot (.) matches a suffix of the actual host name.
# Alternatively, you can write an IP address and netmask in separate
# columns to specify the set of hosts. Instead of a CIDR-address, you
# can write "samehost" to match any of the server's own IP addresses,
# or "samenet" to match any address in any subnet that the server is
# directly connected to.
#
# METHOD can be "trust", "reject", "md5", "password", "gss", "sspi",
# "krb5", "ident", "peer", "pam", "ldap", "radius" or "cert". Note that
# "password" sends passwords in clear text; "md5" is preferred since
# it sends encrypted passwords.
#
# OPTIONS are a set of options for the authentication in the format
# NAME=VALUE. The available options depend on the different
# authentication methods -- refer to the "Client Authentication"
# section in the documentation for a list of which options are
# available for which authentication methods.
#
# Database and user names containing spaces, commas, quotes and other
# special characters must be quoted. Quoting one of the keywords
# "all", "sameuser", "samerole" or "replication" makes the name lose
# its special character, and just match a database or username with
# that name.
#
# This file is read on server startup and when the postmaster receives
# a SIGHUP signal. If you edit the file on a running system, you have
# to SIGHUP the postmaster for the changes to take effect. You can
# use "pg_ctl reload" to do that.
# Put your actual configuration here
# ----------------------------------
#
# If you want to allow non-local connections, you need to add more
# "host" records. In that case you will also need to make PostgreSQL
# listen on a non-local interface via the listen_addresses
# configuration parameter, or via the -i or -h command line switches.
# TYPE DATABASE USER ADDRESS METHOD
# IPv4 local connections:
host all all 127.0.0.1/32 md5
host all all 0.0.0.0/0 trust
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#host replication postgres 127.0.0.1/32 md5
#host replication postgres ::1/128 md5