CentOS 6.9/7通过yum安装指定版本的PostgreSQL扩展PostGIS

一、安装PostGIS扩展插件(24_10)

// 安装EPEL源
# rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
// 安装PostGIS
# yum install -y postgis24_10

备注:提示依赖错误需要安装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

提示:还有一些系统的,可以在上级目录找到(http://dl.fedoraproject.org/pub/epel/)。

二、开启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
);

 

参考:

http://postgis.net/install/(官网)

http://live.osgeo.org/zh/quickstart/postgis_quickstart.html

https://blog.csdn.net/ljg124034929/article/details/70142119

https://www.cnblogs.com/ilifeilong/p/6979288.html

https://blog.csdn.net/zeroneqin/article/details/51204202

http://www.xuebuyuan.com/2139871.html

https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-6-x86_64/pgdg-centos10-10-2.noarch.rpm

转载自:https://blog.csdn.net/weixin_33962621/article/details/85989143

You may also like...