暂无图片
暂无图片
1
暂无图片
暂无图片
暂无图片

PostgreSQL插件PostGIS安装

原创 多米爸比 2020-02-12
5816

参考官网 http://postgis.net/
PostGis版本2.5.3

1.安装libxml2

# yum install libxml2 libxml2-devel

2.安装json-c

# tar zxvf json-c-json-c-0.13.1-20180305.tar.gz
# cd json-c-json-c-0.13.1-20180305
# ./configure && make && make install

3.安装protobuf-c

# tar zxvf protobuf-3.9.2.tar.gz
# cd protobuf-3.9.2
# ./autogen.sh
# ./configure && make && make install

# /usr/local/bin/protoc --version 
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

# tar zxvf protobuf-c-1.3.2.tar.gz
# cd protobuf-c-1.3.2
# ./configure && make && make install

4.安装proj

# tar zxvf sqlite-autoconf-3290000.tar.gz
# cd sqlite-autoconf-3290000
# ./configure && make && make install

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

# tar zxvf proj-6.2.0.tar.gz
# cd proj-6.2.0
# ./configure && make && make install

5.安装geos

# tar zxvf geos-3.7.2.tar.gz
# cd geos-3.7.2
# ./autogen.sh
# ./configure
# make && make install

6.安装gdal

# tar zxvf gdal-3.0.1.tar.gz
# cd gdal-3.0.1
# ./configure && make && make install

7.安装postgis

# tar zxvf postgis-2.5.3.tar.gz
# cd postgis-2.5.3
# ./configure \
--with-geosconfig=/usr/local/bin/geos-config \
--with-projdir=/usr/local/ \
--with-gdalconfig=/usr/local/bin/gdal-config
# make && make install

确认postgis组间已安装
$ ll /pgdata/postgres/share/extension/postgis*

8.使用postgis

使用超级用户创建扩展
$ psql -Upostgres postgres
create extension postgis;
create extension postgis_topology;
create extension fuzzystrmatch;
create extension postgis_tiger_geocoder;

--测试SQL
CREATE TABLE gtest ( gid serial primary key, name varchar(20));
SELECT AddGeometryColumn ('gtest', 'geom', 4326,'LINESTRING', 2);
select DropGeometryColumn('gtest','geom');
SELECT AddGeometryColumn ('gtest', 'geom', 0,'LINESTRING', 2);
INSERT INTO gtest (GID, NAME, GEOM)
VALUES (1, 'First Geometry',ST_GeomFromText('LINESTRING(2 3,4 5,6 5,7 8)'));

源码编译比较慢,大约需要几个小时不等,如果只是测试使用建议使用docker安装

保持联系

从2019年12月开始写第一篇文章,分享的初心一直在坚持,本人现在组建了一个PG乐知乐享交流群,欢迎关注我文章的小伙伴进群吹牛唠嗑,交流技术,互赞文章。

123.png

如果群二维码失效可以加我微信。

456.png

最后修改时间:2022-10-23 10:23:23
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

文章被以下合辑收录

评论