如何将 PostGIS 添加到 PostgreSQL pgAdmin?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24981784/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 00:46:00  来源:igfitidea点击:

How do I add PostGIS to PostgreSQL pgAdmin?

postgresqlpostgispgadmin

提问by CodyBugstein

I've got PostgreSQL and pgAdmin installed, but I want to add a PostGIS server so I could work on a Geographic Informations System project.

我已经安装了 PostgreSQL 和 pgAdmin,但我想添加一个 PostGIS 服务器,以便我可以处理地理信息系统项目。

I'm following this tutorial, which assumes PostGIS is set up. In the previous page of the tutorial, it instructs you to download their software package which includes PostgreSQL and pgAdmin. I already have those installed, so I would like to just add PostGISbut I don't see any way to do so.

我正在关注本教程该教程假定 PostGIS 已设置。在教程的上一页,它指示您下载他们的软件包,其中包括 PostgreSQL 和 pgAdmin。我已经安装了这些,所以我想添加,PostGIS但我看不到任何方法。

Any ideas?

有任何想法吗?

pgAdmin screenshot

pgAdmin 截图

回答by jwd630

Connect to the database using a superuser account (most often the user named postgres but in more recent versions the id of the user who installed the application.) Then issue the following SQL commands to enable PostGIS functionality.

使用超级用户帐户连接到数据库(通常是名为 postgres 的用户,但在最近的版本中是安装应用程序的用户的 ID。)然后发出以下 SQL 命令以启用 PostGIS 功能。

 CREATE EXTENSION postgis;
 CREATE EXTENSION postgis_topology;

You can do this from within pgAdmin or via psql -U [superuser] [database]from a command line.

您可以在 pgAdmin 中或通过psql -U [superuser] [database]命令行执行此操作。

Alternately for the command adverse; as a superuser; from within pgAdmin right click on your database's Extensions and select New Extension. Then in the drop down associated with Name select the postgis* extensions needed.

交替为命令不利;作为超级用户;在 pgAdmin 中右键单击数据库的扩展并选择新建扩展。然后在与名称关联的下拉列表中选择需要的 postgis* 扩展。

回答by aashish

Before adding PostGIS extension to Postgres. You first need to install PostGIS on Ubuntu 14.04

在将 PostGIS 扩展添加到 Postgres 之前。您首先需要在 Ubuntu 14.04 上安装 PostGIS

Add PPA from terminal

从终端添加 PPA

$ sudo add-apt-repository ppa:ubuntugis/ppa
$ sudo apt-get update

Install PostGIS with apt-get

使用 apt-get 安装 PostGIS

$ sudo apt-get install postgis

After successful installation open psql

安装成功后打开psql

$ sudo -u postgres psql

List all databases

列出所有数据库

postgres=# \l

Connect to specific database

连接到特定的数据库

postgres=# \c DATABASE_NAME

Run the following to add PostGIS extension to Postgres

运行以下命令将 PostGIS 扩展添加到 Postgres

CREATE EXTENSION postgis;
CREATE EXTENSION postgis_topology;

Exit from psql

退出 psql

postgres=# \q

Thank you

谢谢

回答by John Powell

You don't install it to pgAdmin, it is an extension to Postgres itself. Once it is installed, you add it to a particular database, and its functions, nearly 1000, a few views and the spatial_ref_sys table, will appear in pgAdmin in that db. You can also install it to the template1 db, and then it will be automatically included in any other database that you subsequently create. You can get a binary install from http://postgis.net/install/

您不必将它安装到 pgAdmin,它是 Postgres 本身的扩展。安装后,将其添加到特定数据库中,其功能(近 1000 个)、一些视图和 spatial_ref_sys 表将出现在该数据库的 pgAdmin 中。您也可以将它安装到 template1 数据库中,然后它将自动包含在您随后创建的任何其他数据库中。您可以从http://postgis.net/install/获得二进制安装