1 PostgreSQL 11.0安装及配置
软件下载入口
![71a94d0bbc8d93b4bc2aab8e85b48e35.png](https://img-blog.csdnimg.cn/img_convert/71a94d0bbc8d93b4bc2aab8e85b48e35.png)
![ba2402aed34dd63fe76c0349cb9c58f9.png](https://img-blog.csdnimg.cn/img_convert/ba2402aed34dd63fe76c0349cb9c58f9.png)
![0404a7bae51a2f1df726acd9e65d7db0.png](https://img-blog.csdnimg.cn/img_convert/0404a7bae51a2f1df726acd9e65d7db0.png)
![a62dd1ea5353c64caaade5e80c28de6d.png](https://img-blog.csdnimg.cn/img_convert/a62dd1ea5353c64caaade5e80c28de6d.png)
![52e087cd3002b851ff8ef33c41335735.png](https://img-blog.csdnimg.cn/img_convert/52e087cd3002b851ff8ef33c41335735.png)
![e59ff6cf54b817b10d9f38bdbadbe3d3.png](https://img-blog.csdnimg.cn/img_convert/e59ff6cf54b817b10d9f38bdbadbe3d3.png)
![deaa4ebc922d4e9f01cd123cb36faf94.png](https://img-blog.csdnimg.cn/img_convert/deaa4ebc922d4e9f01cd123cb36faf94.png)
![52f33c2adcaece1797aecc68f08fddb4.png](https://img-blog.csdnimg.cn/img_convert/52f33c2adcaece1797aecc68f08fddb4.png)
![78c54b02e676ddb9cb90840896c9ea12.png](https://img-blog.csdnimg.cn/img_convert/78c54b02e676ddb9cb90840896c9ea12.png)
![978c51cb3e2083f4e22612f06ff62dca.png](https://img-blog.csdnimg.cn/img_convert/978c51cb3e2083f4e22612f06ff62dca.png)
![a06043b0fc818910e16c488a90faddcc.png](https://img-blog.csdnimg.cn/img_convert/a06043b0fc818910e16c488a90faddcc.png)
![6d6bde324cf7e9c882822814259b8662.png](https://img-blog.csdnimg.cn/img_convert/6d6bde324cf7e9c882822814259b8662.png)
![7f6612b01b646c06ba9be140acc3d718.png](https://img-blog.csdnimg.cn/img_convert/7f6612b01b646c06ba9be140acc3d718.png)
![373305d69415f5d0a0589a6a7f6f8319.png](https://img-blog.csdnimg.cn/img_convert/373305d69415f5d0a0589a6a7f6f8319.png)
![d1c9d176b28513ddbad951950c9e8bee.png](https://img-blog.csdnimg.cn/img_convert/d1c9d176b28513ddbad951950c9e8bee.png)
![21c9524eb89d6b2d4dee643045ed4121.png](https://img-blog.csdnimg.cn/img_convert/21c9524eb89d6b2d4dee643045ed4121.png)
![0238ddb92bb1a52d07e0dd3c21943007.png](https://img-blog.csdnimg.cn/img_convert/0238ddb92bb1a52d07e0dd3c21943007.png)
2 psqlODBC安装及配置
![d39e5c7e1b379727302047e5fa1f80f2.png](https://img-blog.csdnimg.cn/img_convert/d39e5c7e1b379727302047e5fa1f80f2.png)
![7d295f94bfb6056ee316e79143386043.png](https://img-blog.csdnimg.cn/img_convert/7d295f94bfb6056ee316e79143386043.png)
3 PostGIS安装及配置
![2b16f1bd4be53f60379ffe77cddcbbb7.png](https://img-blog.csdnimg.cn/img_convert/2b16f1bd4be53f60379ffe77cddcbbb7.png)
![639332ff32ce20e2f85723842664a8af.png](https://img-blog.csdnimg.cn/img_convert/639332ff32ce20e2f85723842664a8af.png)
![83756411a3332340b5d45d618e3c766a.png](https://img-blog.csdnimg.cn/img_convert/83756411a3332340b5d45d618e3c766a.png)
![e2fc8b492eb3adbc79eb2c0ec54b4f78.png](https://img-blog.csdnimg.cn/img_convert/e2fc8b492eb3adbc79eb2c0ec54b4f78.png)
![477434987add96e1cc801fec380843d3.png](https://img-blog.csdnimg.cn/img_convert/477434987add96e1cc801fec380843d3.png)
![76c65d56f90d1779d12424d63f09878a.png](https://img-blog.csdnimg.cn/img_convert/76c65d56f90d1779d12424d63f09878a.png)
4 pgAdmin4使用入门
![1eb3db53f73db934f7c3beccd1c357f0.png](https://img-blog.csdnimg.cn/img_convert/1eb3db53f73db934f7c3beccd1c357f0.png)
![bc3f18fbb7257b2ab72b9cfce9c47926.png](https://img-blog.csdnimg.cn/img_convert/bc3f18fbb7257b2ab72b9cfce9c47926.png)
![c9894f51d2575f32c8a8d9e12c4f370b.png](https://img-blog.csdnimg.cn/img_convert/c9894f51d2575f32c8a8d9e12c4f370b.png)
![43e44e234fa6dc636758f5343b48f04e.png](https://img-blog.csdnimg.cn/img_convert/43e44e234fa6dc636758f5343b48f04e.png)
![525b1a2450085fc07a92c4471fddd52d.png](https://img-blog.csdnimg.cn/img_convert/525b1a2450085fc07a92c4471fddd52d.png)
![d00a0c402f3393c3d26b412c663990c3.png](https://img-blog.csdnimg.cn/img_convert/d00a0c402f3393c3d26b412c663990c3.png)
5 空间数据导入
5.1 将PostgreSQL的bin文件路径添加到系统环境变量
![a5408f7b48b0166bff991f754e25382a.png](https://img-blog.csdnimg.cn/img_convert/a5408f7b48b0166bff991f754e25382a.png)
5.2 栅格数据导入
1)raster2pgsql导入栅格数据
raster2pgsql -s 投影坐标系 -I -M -C shp文件路径 -t 切片大小 新建的数据表名 |psql -h localhost -p 5432 -U 数据库用户 -d 数据库名 -W
raster2pgsql -s 4326 -I -M -C D:rastert1.tif -t 256x256 public.t2 | psql -h localhost -p 5432 -U postgres -d ltest -W
![c3470107501ec27f0a029c15c2b176a0.png](https://img-blog.csdnimg.cn/img_convert/c3470107501ec27f0a029c15c2b176a0.png)
2)特别提示 raster2pgsql导入栅格数据,与在ArcGIS中直接将栅格数据存储到PostgreSQL,存在两种截然不同的数据存储方式,间接导致后一种方式存储的栅格数据,无法在geoserver中通过postgis发布影像服务。
![017b610f86ca8fb4d863ffac8b07c509.png](https://img-blog.csdnimg.cn/img_convert/017b610f86ca8fb4d863ffac8b07c509.png)
![338983ee857a17b7aa3eba9b0ee03ba4.png](https://img-blog.csdnimg.cn/img_convert/338983ee857a17b7aa3eba9b0ee03ba4.png)
5.3 矢量数据导入
1) PostGIS Shapefile Import / Export Manager
![b1049b4c5cf0a076cd14274517663a6c.png](https://img-blog.csdnimg.cn/img_convert/b1049b4c5cf0a076cd14274517663a6c.png)
2) shp2pgsql导入矢量数据
shp2pgsql -s 投影坐标系 shp文件路径 新建的数据表名 |psql -h localhost -p 5432 -U 数据库用户 -d 数据库名 -W 字体编码
shp2pgsql -s 4326 D:vectorT1.shp public.t1 | psql -h localhost -p 5432 -U postgres -d ltest -W GBK
![4436f28fe2c4940b274a58cf73c2ee76.png](https://img-blog.csdnimg.cn/img_convert/4436f28fe2c4940b274a58cf73c2ee76.png)
6 PostgreSQL卸载
6.1 自带卸载工具
![d4ab78ca73578dd9c586edae48995300.png](https://img-blog.csdnimg.cn/img_convert/d4ab78ca73578dd9c586edae48995300.png)
![e45f06d5c3f52263d798270fd96e3ef3.png](https://img-blog.csdnimg.cn/img_convert/e45f06d5c3f52263d798270fd96e3ef3.png)
6.2 Geek Uninstaller
1)下载完全卸载工具Geek Uninstaller
![c9f54646aa2e364df5b9859fcbfca960.png](https://img-blog.csdnimg.cn/img_convert/c9f54646aa2e364df5b9859fcbfca960.png)
2)点击完成卸载残留
![65d2afc43ec609fa6f96f5d5e67f2eb1.png](https://img-blog.csdnimg.cn/img_convert/65d2afc43ec609fa6f96f5d5e67f2eb1.png)
7 ArcGIS Desktop连接PostgreSQL
7.1 连接准备
1)ArcGIS 10.6及ArcGIS Pro支持的PostgreSQL可从官网帮助文档获取,也可直接查看安装文件DatabaseSupport
C:Program Files (x86)ArcGISDesktop10.6DatabaseSupportPostgreSQL
![3c2b285eda32aff90d0d91cd2f480760.png](https://img-blog.csdnimg.cn/img_convert/3c2b285eda32aff90d0d91cd2f480760.png)
2)参考本文第1-3章安装PostgreSQL 3) 将ArcGIS10.6中的pgsqlengine.dll
和st_geometry.dll
拷贝到PostgreSQL的lib
文件下
![22514351445fc2c7eabd0364ac56fcad.png](https://img-blog.csdnimg.cn/img_convert/22514351445fc2c7eabd0364ac56fcad.png)
![1e6228bcee316f04c73e32528390a53c.png](https://img-blog.csdnimg.cn/img_convert/1e6228bcee316f04c73e32528390a53c.png)
4)由于ArcGIS Desktop是32位程序,ArcGIS10.5之前的版本需要将32位PostgreSQL的客户端的 libeay32.dll
, libiconv-2.dll
,libintl-8.dll
, libpq.dll
和ssleay32.dll
文件拷贝到ArcGIS Desktop 安装目录的bin目录下,也从官网Binaries下载对应32位的客户端。然而,ArcGIS10.5及后续版本已经有这些文件,复制后反而可能导致无法连接。 5)配置PostgreSQL实现TCP/IP访问连接,修改pg_hba.conf
和pg_hba.conf
文件
![f39b0ef566818c95f6a7dae9aba11132.png](https://img-blog.csdnimg.cn/img_convert/f39b0ef566818c95f6a7dae9aba11132.png)
![c730d7c255abd2978e9e6b4b6c7db718.png](https://img-blog.csdnimg.cn/img_convert/c730d7c255abd2978e9e6b4b6c7db718.png)
![719e82c698a5c64e9fe7d91d5af5fb4c.png](https://img-blog.csdnimg.cn/img_convert/719e82c698a5c64e9fe7d91d5af5fb4c.png)
![0607459e16c8c1ab10dead2e26db926b.png](https://img-blog.csdnimg.cn/img_convert/0607459e16c8c1ab10dead2e26db926b.png)
7.2 ArcGIS数据库连接
注意:创建企业级地理数据库时,授权文件须为ecp文件,prvc可在授权终端通过在线或者邮件方式自助转换为ecp
7.2.1 ArcMap
1)普通连接
![51977cfb8ff32e1e9340b2b1fc65c7a2.png](https://img-blog.csdnimg.cn/img_convert/51977cfb8ff32e1e9340b2b1fc65c7a2.png)
2)企业地理数据库连接
![ec95592e1150d2c2269ad97bfa0ddcea.png](https://img-blog.csdnimg.cn/img_convert/ec95592e1150d2c2269ad97bfa0ddcea.png)
![26357fdcd69a342214ab2e4e1efcd626.png](https://img-blog.csdnimg.cn/img_convert/26357fdcd69a342214ab2e4e1efcd626.png)
![9f4fbba42e6b50c27ba2fd29b6e10879.png](https://img-blog.csdnimg.cn/img_convert/9f4fbba42e6b50c27ba2fd29b6e10879.png)
3)启用地理数据库
注意:企业地理数据库未启动前无法导入栅格数据
![2a1d4ef5fdd222534ca0519a986d0ba5.png](https://img-blog.csdnimg.cn/img_convert/2a1d4ef5fdd222534ca0519a986d0ba5.png)
![0a5c2bbb5ce0332186274a381eee6cfe.png](https://img-blog.csdnimg.cn/img_convert/0a5c2bbb5ce0332186274a381eee6cfe.png)
![633de96b2a1876938f10c4810c78e811.png](https://img-blog.csdnimg.cn/img_convert/633de96b2a1876938f10c4810c78e811.png)
![cb4ac2194ab7d7279cc05f1172a46dc7.png](https://img-blog.csdnimg.cn/img_convert/cb4ac2194ab7d7279cc05f1172a46dc7.png)
![8d90fd40043b6297241bca03b98dc762.png](https://img-blog.csdnimg.cn/img_convert/8d90fd40043b6297241bca03b98dc762.png)
7.2.2 ArcGIS Pro
1)普通连接
![e2ff15445f2239d4e2c06a1cadfaff1d.png](https://img-blog.csdnimg.cn/img_convert/e2ff15445f2239d4e2c06a1cadfaff1d.png)
2)企业地理数据库连接
![b878ba485b8365a444c8a7db1b3bd39f.png](https://img-blog.csdnimg.cn/img_convert/b878ba485b8365a444c8a7db1b3bd39f.png)
![79f9d4c3053bc533a87151fba0a4ccf7.png](https://img-blog.csdnimg.cn/img_convert/79f9d4c3053bc533a87151fba0a4ccf7.png)
7.3 注册数据库到ArcGIS Server
1)注册数据库
![3edebf0cfdd214bd9b0cff3f700aa6be.png](https://img-blog.csdnimg.cn/img_convert/3edebf0cfdd214bd9b0cff3f700aa6be.png)
2)验证数据库可用性
![2a66f9e1be0b095aa101266586d9a6af.png](https://img-blog.csdnimg.cn/img_convert/2a66f9e1be0b095aa101266586d9a6af.png)
![d5ca3df0be4e68e0f2455fc2d9e35a4a.png](https://img-blog.csdnimg.cn/img_convert/d5ca3df0be4e68e0f2455fc2d9e35a4a.png)