今天本地要测试使用postgresql的gis,网上都是些 乱七八糟的 ,搜了半天总结了一下:
首先去下面这个地址下载postgis安装包
postgis安装地址
因为我是pg11,所以这里我选择最后一个 postgis-bundle-pg11x64-setup-3.0.0-3.exe
双击安装
安装的时候只改一个安装地址,安装地址选择你的postgresql目录,比如我的postgresql安装在D盘中就是: D:\PostgreSQL
安装最后有跳出三个弹窗全部选 是:
postgis would you like us to register the GDAL_DATA environment variable for you,needed for raster transformation to work properly? this will overwrite existing settings if you have them.
您希望我们为您注册GDAL_DATA环境变量,以便光栅转换正常工作吗?这将覆盖现有的设置,如果你有它们。选择“是”,用于光栅转换:
Raster drivers are disabled by default. To change you need to set POSTGIS_GDAL_ENABLE_DRIVERS environment variable and will need to restart your PostgreSQL service for changes to take effect. Set POSTGIS_ENABLED_DRIVERS to common drivers GTiff, PNG, JPEG, XYZ, DTED, USGSDEM, AAIGrid?
默认情况下,光栅驱动器被禁用。要更改,需要设置POSTGIS_GDAL_ENABLE_DRIVERS环境变量,并且需要重新启动PostgreSQL服务以使更改生效。设置PasgsIsEnabLED驱动程序给普通驱动程序GTIFF、PNG、JPEG、XYZ、DTD、UGSDEM、AAIGrid?
Raster out of db is disabled by default. To enable POSTGIS_ENABLE_OUTDB_RASTERS environment variable needs to be set to 1. Enable out db rasters?
缺省情况下禁用DB光栅。要启用PasgsIsEnabLeOutBuxRasts环境变量,需要将其设置为1。启用DB光栅?
–校验
create DATABASE djys_test;
–添加支持
CREATE EXTENSION postgis;
CREATE EXTENSION pgrouting;
CREATE EXTENSION postgis_topology;
CREATE EXTENSION fuzzystrmatch;
CREATE EXTENSION postgis_tiger_geocoder;
–查看postgresql版本
show server_version;
–查看postgis版本
SELECT PostGIS_full_version();
–查看pgrouting版本
select pgr_version();
–postgis 空间数据创建和查询(线)
create table EDGES (ID SERIAL not null,geometry geography(LINESTRINGZ, 4326) null);
insert into edges(geometry) values(ST_GeographyFromText(‘SRID=4326; LINESTRING(-110 30 40,11 22 33)’));
select ST_AsText(geometry) from edges;