PostGIS的安装与建库(Windows)
安装PostgreSQL
首先,以管理员身份运行 postgresql-13.5-1-windows-x64。(下面是安装包下载链接)
链接:https://pan.baidu.com/s/1vr6_zwOzW4UW6zwf6wnUWw?pwd=1234
提取码:1234
- 进入安装首页,按向导进行安装,用户密码都是“postgres” 。
![](https://img-blog.csdnimg.cn/5d3816c317264efa8a3e10529930de1b.png)
![](https://img-blog.csdnimg.cn/9aeedf8eeb914552887b2293a221357d.png)
![](https://img-blog.csdnimg.cn/317fa9a965cd4d2d87a16c9f18651adf.png)
![](https://img-blog.csdnimg.cn/d9366130f8774240903c6065dc3ddf88.png)
![](https://img-blog.csdnimg.cn/5781548917804340b2858d26bfa78dc2.png)
![](https://img-blog.csdnimg.cn/f99c09b102074cd2aac43e6e0d26061c.png)
![](https://i-blog.csdnimg.cn/blog_migrate/ff17126a7d7e9865fbf89db44898b108.png)
![](https://i-blog.csdnimg.cn/blog_migrate/4867cf0c466aa29a44bdd13fb81654cd.png)
安装PostGIS
PostGIS 在对象关系型数据库 PostgreSQL 上增加了存储管理空间数据的能力,相当于 Oracle 的 spatial 部分,下面介绍 PostGIS 安装步骤。
- 以管理员身份运行postgis-bundle-pg13x64-setup-3.1.4-1。
![](https://i-blog.csdnimg.cn/blog_migrate/650bc39e33bf33d038b2ed561e4b1dc0.png)
- 进入安装首页,按向导进行安装。
![](https://i-blog.csdnimg.cn/blog_migrate/67030168b3179aec511a1ab77d1f4062.png)
![](https://i-blog.csdnimg.cn/blog_migrate/80c956990e34641e468d66f08eb58e65.png)
![](https://i-blog.csdnimg.cn/blog_migrate/5ba281ab481a16d371e928aca8cd0d12.png)
- 密码输入“postgres”。
![](https://i-blog.csdnimg.cn/blog_migrate/36856a39eeec5664e2c98900e497441f.png)
![](https://i-blog.csdnimg.cn/blog_migrate/515b71e9ead36074ff3518964fd48672.png)
- 对安装弹出框点击“是(Y)”按钮。
![](https://i-blog.csdnimg.cn/blog_migrate/4738aa1f4af4cad8c6bd269650b2faf3.png)
- 点击【colse】完成PostGIS安装 。
![](https://i-blog.csdnimg.cn/blog_migrate/894ee2501542e5afa70dde490f081cad.png)
构建空间数据库
- 在客户端点击【开始】菜单,选择【pgAdmin 4】。
![](https://i-blog.csdnimg.cn/blog_migrate/3497b8e41eabc4313abcb8a6cae72a23.png)
![](https://i-blog.csdnimg.cn/blog_migrate/b96c5563160063fdebdd3a68ac75d584.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e210a2e495d58e68f6ff90bb08b86280.gif)
- 选择Connection选项,填写数据库的连接信息,数据库的实例名、用户、密码请统一为postgres,点击【Save】按钮,创建数据库连接成功,双击即可进入该连接。
![](https://i-blog.csdnimg.cn/blog_migrate/bd51e843feade2c41de8f9e967f5c476.png)
![](https://i-blog.csdnimg.cn/blog_migrate/306f5d4ba9612cf50a719f9f937d6f6b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/0b65dcc3617d4f67710eb7f9f6a23b02.png)
- 展开服务,点击【Databases】右键选择【Create】,点击【Database】。 弹出【Create-Database】对话框,Database填写“db_xxxx”,Owner 选择“postgres”。
![](https://i-blog.csdnimg.cn/blog_migrate/ade9b674e0d57410608c5b96f09601bd.gif)
- 选择Definition选项卡,填写参数,点击【Save】保存新建数据库。
![](https://i-blog.csdnimg.cn/blog_migrate/bbb4ed1cb4d055fb721b3875377af610.gif)
- 展开新建数据库的-“Extensions”,新增Extension, 点击【Extensions】-【Create】选择Extension。弹出Create-Extension对话框,选择Postgis相关组件,只有安装了PostGIS才会有相关组件进行选择,添加“postgis”与“postgis _topology”, 只能一个一个的添加,点击【Save】保存即可。
![](https://i-blog.csdnimg.cn/blog_migrate/bfea96e42e73e61feb9f74387c824489.gif)
- 添加成功后可在db_xxxx数据库下的Extensions列表中进行查看。
![](https://i-blog.csdnimg.cn/blog_migrate/19b03a660a4101a56372ca7b16d1bf20.png)
这样一个流程就完成了PostGIS的安装与建库。