postgresql PostGIS 错误:类型“地理”不存在

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7001447/
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-10-20 23:12:11  来源:igfitidea点击:

PostGIS Error: type "geography" does not exist

postgresqlpostgis

提问by Steph

I just upgraded my development machine to Windows 7 and am therefore reinstalling PostgreSQL and PostGIS. I used the Postgres Plus installer, as recommended on the Postgres website, and followed this tutorialfor installation. I created a database using the template_postgis and the application that I am currently developing was able to connect to the database with no problems.

我刚刚将我的开发机器升级到 Windows 7,因此我重新安装了 PostgreSQL 和 PostGIS。我按照 Postgres 网站上的推荐使用了Postgres Plus 安装程序,并按照本教程进行安装。我使用 template_postgis 创建了一个数据库,我目前正在开发的应用程序能够毫无问题地连接到数据库。

However, my old code is not able to create tables using the PostGIS Geographylike it used to. For example, when I try to create the following table:

但是,我的旧代码无法Geography像以前那样使用 PostGIS 创建表。例如,当我尝试创建下表时:

CREATE TABLE test_area (
    id SERIAL PRIMARY KEY,
    name VARCHAR(1000),
    area GEOGRAPHY(POLYGON, 4326),
    start_time DATE,
    end_time DATE
)

I get the following error:

我收到以下错误:

ERROR:  type "geography" does not exist
LINE 4:         area GEOGRAPHY(POLYGON, 4326),
                     ^

If I look under the database in the Object brower of pgAdmin III, I see a bunch of Geometryfunctions, so the installation seems to have run correctly. I'm not sure what my problem might be. Is it possible for the installer to only install PostGIS Geometry, but not Geography?

如果我在 pgAdmin III 的对象浏览器中查看数据库,我看到了一堆Geometry功能,因此安装似乎运行正确。我不确定我的问题可能是什么。安装程序可以只安装 PostGISGeometry而不是Geography吗?

采纳答案by Steph

I got my question answered over on the GIS site. I had PostGIS 1.4 installed, but Geographywas not added until PostGIS 1.5. So I had to uninstall what I had and re-install Postgres. I had great difficulty finding a version that included PostGIS 1.5, though. I was given the advice to not use the "Postgres Plus" proprietary software, though, since it takes EnterpriseDB time to port the most up-to-date add-ons and such. Instead I was redirected to the regular PostgreSQL download on the EnterpriseDB website, which is surprisingly tricky to find. Here it is. The 64-bit version did not come with PostGIS, so I had to use the 32-bit version instead, which worked. Finally!

我在GIS 站点上回答了我的问题。我安装了 PostGIS 1.4,但Geography直到 PostGIS 1.5 才添加。所以我不得不卸载我所拥有的并重新安装 Postgres。不过,我很难找到包含 PostGIS 1.5 的版本。不过,有人建议我不要使用“Postgres Plus”专有软件,因为 EnterpriseDB 需要时间来移植最新的附加组件等。相反,我被重定向到 EnterpriseDB 网站上的常规 PostgreSQL 下载,这出奇地难以找到。 在这里。64 位版本没有随 PostGIS 一起提供,所以我不得不改用 32 位版本,这很有效。最后!

回答by Harry Wang

I have experienced this issue before as well, but what helped me was not the answer on the GIS site.

我以前也遇到过这个问题,但对我有帮助的不是 GIS 站点上的答案。

I have Postgresql installed via Homebrew and I also have the Postgresql app installed. As for PostGIS, however, I installed it via Homebrew.

我通过 Homebrew 安装了 Postgresql,我还安装了 Postgresql 应用程序。但是,对于 PostGIS,我是通过 Homebrew 安装的。

When I encountered this problem, I was running the Postgresql app instead of running it in Terminal, so of course you'd get this PostGIS error because PostGIS was never installed on the Postgresql app. Once I started Postgresql in Terminal, it worked for me.

当我遇到这个问题时,我正在运行 Postgresql 应用程序而不是在终端中运行它,所以当然你会收到这个 PostGIS 错误,因为 PostGIS 从未安装在 Postgresql 应用程序上。一旦我在终端中启动了 Postgresql,它就对我有用。

Update 9/25/2014:

2014 年 9 月 25 日更新:

It's possible that you did not create the extension for PostGIS in your database:

您可能没有在数据库中为 PostGIS 创建扩展:

$ psql

psql> \c databaseName;

psql> CREATE EXTENSION Postgis;

回答by francs

Maybe ther are some problems with the postgis, first see if the type "geography" is exist? just as the follwing;

可能postgis有问题,先看看“geography”这个类型是否存在?就像下面一样;

db_lbs=> \dT geography

db_lbs=> \dT 地理

        List of data types
 Schema |   Name    | Description 
--------+-----------+-------------
 lbs    | geography | 
(1 row)

By the way, please take attention to the current search_path;

对了,请注意当前的search_path;

I guess the type "geography" is not exist in your schema, may it exists in public schema, So check it first。

我猜你的模式中不存在“geography”类型,它可能存在于公共模式中,所以先检查一下。

回答by PAC

I have experienced the same issue, I resolved it by un-installing postgres, postgis and reinstalled followed by the official installation documentation. For windows:

我遇到了同样的问题,我通过卸载 postgres、postgis 并重新安装了官方安装文档来解决它。对于窗户:

http://postgis.net/windows_downloads

http://postgis.net/windows_downloads

For Ubuntu & OSX:

对于 Ubuntu 和 OSX:

http://postgis.net/install

http://postgis.net/install