PostGIS 错误:输入“地理”不存在

发布于 2024-11-28 21:09:59 字数 947 浏览 4 评论 0原文

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

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

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

我收到以下错误:

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

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

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 tutorial for 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.

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

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 Geometry functions, 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

感情旳空白 2024-12-05 21:09:59

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

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

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

更新 9/25/2014:

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

$ psql

psql> \c databaseName;

psql> CREATE EXTENSION Postgis;

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

I have Postgresql installed via Homebrew and I also have the Postgresql app installed. As for PostGIS, however, I installed it via 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.

Update 9/25/2014:

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

$ psql

psql> \c databaseName;

psql> CREATE EXTENSION Postgis;
狼性发作 2024-12-05 21:09:59

也许postgis有问题,首先看看“geography”类型是否存在?
如下;

db_lbs=>; \dT geography

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

顺便请注意一下当前的search_path;

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

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

db_lbs=> \dT geography

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

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

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

帅的被狗咬 2024-12-05 21:09:59

I got my question answered over on the GIS site. I had PostGIS 1.4 installed, but Geography was 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!

温柔少女心 2024-12-05 21:09:59

我也遇到过同样的问题,我通过卸载postgres、postgis并重新安装然后按照官方安装文档解决了这个问题。
对于 Windows:

http://postgis.net/windows_downloads

对于 Ubuntu 和 Linux OSX:

http://postgis.net/install

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

http://postgis.net/windows_downloads

For Ubuntu & OSX:

http://postgis.net/install

冰葑 2024-12-05 21:09:59

如果有人在连接到使用 Qurkus 编写的 Heroku 应用程序时遇到相同的错误,修复方法如下 - 需要将 ?currentSchema=YOUR_CURRENT_SCHEMA 附加到 JDBC URI

If somebody experience the same error while connecting to the Heroku application, written using Qurkus, the fix is the following -- there is need to appedn ?currentSchema=YOUR_CURRENT_SCHEMA to the JDBC URI

画离情绘悲伤 2024-12-05 21:09:59

我在这里为 Supabase 用户声明这一点。
在发布本文时,Supabase 文档告诉您可以将扩展添加到不同的模式,例如 gis。默认情况下这对我不起作用,我收到了上面提到的错误。

@miso01 在下面指出,他能够通过在更改表以添加新列时引用架构名称来解决该问题。
sql ALTER TABLE public.spot 添加列点 postgis.geography;
如果您使用此方法,您将需要引用以您安装扩展的架构名称开头的任何 postgis 函数或类型的所有实例。例如,如果我创建了与 postgis 扩展一起安装的模式“postgis”,则每当我需要调用函数或类型时,我都需要引用 postgis.GEOMETRY 或 postgis.[在此处插入函数/类型]。

我最初只是将模式保留为“扩展”,这将允许您使用 postgis 数据类型创建表。
尽管supabase 文档不推荐这样做。它可能会引入命名空间污染并使用户访问限制变得复杂。

I'm stating this here for Supabase users.
At the time of this posting, the Supabase docs tell you you can add the extension to a different schema such as gis. This did not work for me by default and I got the mentioned error above.

@miso01 points out below he was able to solve the issue by referencing the schema name when altering a table to add the new column.
sql ALTER TABLE public.spot ADD COLUMN POINT postgis.geography;
If you use this method you will need to reference all instances of any postgis functions or types prefaced with the schema name you installed the extension on. Example if I created the schema 'postgis' installed with the postgis extension, anytime I need to call a function or type I would need to reference postgis.GEOMETRY or postgis.[insert function/type here].

I originally just left the schema as "extensions" which will allow you to create tables with postgis datatypes.
Though this is not recommended by supabase docs. It could potentially introduce namespace pollution and complicate user access restrictions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文