PostgreSQL (shp2pgsql) AddGeometryColumn 给出“没有函数与给定名称匹配”

发布于 2024-12-03 14:30:22 字数 1234 浏览 6 评论 0原文

我正在使用 PADUS OBI 形状文件,并不是说那可能很重要。

我使用默认选项通过 shp2pgsql 运行形状文件,如下所示:

shp2pgsql PADUS_1_1_CBI_Edition.shp > PADUS.sql

然后我尝试通过以下操作将 SQL 导入 Postgres:

psql -d padusdb -f PADUS.sql

并收到以下错误:

psql:PADUS.sql:36: ERROR:  function addgeometrycolumn(unknown, unknown, unknown, unknown, unknown, integer) does not exist
LINE 1: SELECT AddGeometryColumn('','padus_1_1_cbi_edition','the_geo...
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

我安装了 PostGIS。

导致错误的 SQL 命令(被放入原本为空的数据库中)是:

SET CLIENT_ENCODING TO UTF8;
SET STANDARD_CONFORMING_STRINGS TO ON;
BEGIN;
CREATE TABLE "padus_1_1_cbi_edition" (gid serial PRIMARY KEY,
"us_id" int4,
"category" varchar(10),
"gis_acres" numeric,
...
BUNCH OF COLUMNS, none of which is called "the_geom"
...
"comments" varchar(200),
"shape_leng" numeric,
"shape_area" numeric);
SELECT AddGeometryColumn('','padus_1_1_cbi_edition','the_geom','-1','MULTIPOLYGON',2);
COMMIT;

对于这可能意味着什么以及如何解决问题有什么想法吗?

I'm working with the PADUS OBI shape file, not that that's probably important.

I'm running the shape file through shp2pgsql using the default options, as in:

shp2pgsql PADUS_1_1_CBI_Edition.shp > PADUS.sql

Then I'm trying to import the SQL into Postgres by doing:

psql -d padusdb -f PADUS.sql

And getting the following error:

psql:PADUS.sql:36: ERROR:  function addgeometrycolumn(unknown, unknown, unknown, unknown, unknown, integer) does not exist
LINE 1: SELECT AddGeometryColumn('','padus_1_1_cbi_edition','the_geo...
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

I have PostGIS installed.

The SQL commands leading to the error (being put into an otherwise empty database) are:

SET CLIENT_ENCODING TO UTF8;
SET STANDARD_CONFORMING_STRINGS TO ON;
BEGIN;
CREATE TABLE "padus_1_1_cbi_edition" (gid serial PRIMARY KEY,
"us_id" int4,
"category" varchar(10),
"gis_acres" numeric,
...
BUNCH OF COLUMNS, none of which is called "the_geom"
...
"comments" varchar(200),
"shape_leng" numeric,
"shape_area" numeric);
SELECT AddGeometryColumn('','padus_1_1_cbi_edition','the_geom','-1','MULTIPOLYGON',2);
COMMIT;

Any thoughts on what this might mean and how to resolve the problem?

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

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

发布评论

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

评论(4

笑叹一世浮沉 2024-12-10 14:30:23

谢谢阿托雷斯757!你的回答在几分钟内解决了我的问题。我删除了数据库并创建了一个新数据库,并选择 template_postgis 作为我的模板。所有 shapefile 都可以通过我的 python 脚本正常导入,如下所示:

对于 iList 中的 lyr:

<块引用>

os.system("shp2pgsql -c -s 4326 -k -I -W UTF-8 "+lyr[:-4]+" "+lyr[:-4]+" | psql -d AWM -p分段阅读_第 5432 章

Thanks atorres757! Your answer solved my problem in minutes. I deleted my database and created a new database and choose the template_postgis as my template. All shapefiles are importing fine with my python script like this:

for lyr in iList:

os.system("shp2pgsql -c -s 4326 -k -I -W UTF-8 "+lyr[:-4]+" "+lyr[:-4]+" | psql -d AWM -p 5432 -U postgres")

猫性小仙女 2024-12-10 14:30:22

因此,事实证明,仅仅在计算机上安装 PostGIS 是不够的。

最初,我在 Ubuntu 10.10 上选择了 sudo apt-get install postgresql postgis。这给我留下了 PostGRE 8.4 的工作版本,但没有 PostGIS 的迹象。

因此,我尝试了sudo apt-get install postgresql-8.4-postgis

但一个人的工作还没有结束!您需要设置 PostGIS 数据库。

这个< /a> 网站提供了有关执行此操作以及随后使用数据库的说明。

So, as it turns out, it is not enough to simply have installed PostGIS on one's machine.

Originally, I'd chosen sudo apt-get install postgresql postgis on Ubuntu 10.10. This left me with a working version of PostGRE 8.4, but no sign of PostGIS.

Therefore, I tried sudo apt-get install postgresql-8.4-postgis.

But one's work doesn't end there! You need to set up the PostGIS database.

This website provides instructions on doing this and using the database afterwards.

清风无影 2024-12-10 14:30:22

听起来数据库也需要在空间上启用。它抛出错误的原因是因为缺少该函数。这个资源有一个快速简单的答案和解决方案。

It also sounds like the database needs to be spatially enabled. The reason it's throwing that errors is because the function is missing. This resource has a quick and easy answer and solution.

迷荒 2024-12-10 14:30:22

此错误表明该函数无法识别(函数名称或参数类型不正确)

这是定义对于 v7.2 中的 AddGeometryColumn

text AddGeometryColumn(varchar table_name, varchar column_name, integer srid, varchar type, integer dimension);

text AddGeometryColumn(varchar schema_name, varchar table_name, varchar column_name, integer srid, varchar type, integer dimension);

text AddGeometryColumn(varchar catalog_name, varchar schema_name, varchar table_name, varchar column_name, integer srid, varchar type, integer dimension);

我看来,您正在尝试使用第二个定义,尝试将其更改为使用第一个定义(无架构)并尝试取消引用 srid (-1),因为它应作为整数传递。

您可能需要投射所有内容...

this error indicates that the function cannot be recognized (either function name or parameters types are incorrect)

this is the definitions for AddGeometryColumn in v7.2

text AddGeometryColumn(varchar table_name, varchar column_name, integer srid, varchar type, integer dimension);

text AddGeometryColumn(varchar schema_name, varchar table_name, varchar column_name, integer srid, varchar type, integer dimension);

text AddGeometryColumn(varchar catalog_name, varchar schema_name, varchar table_name, varchar column_name, integer srid, varchar type, integer dimension);

it looks to me like you're trying to use the 2nd definition, try changing it to use the first definition (no schema) and try unquote the srid (-1) since it should be passed as an integer.

You may need to cast everything...

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