PostgreSQL (shp2pgsql) AddGeometryColumn 给出“没有函数与给定名称匹配”
我正在使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
谢谢阿托雷斯757!你的回答在几分钟内解决了我的问题。我删除了数据库并创建了一个新数据库,并选择 template_postgis 作为我的模板。所有 shapefile 都可以通过我的 python 脚本正常导入,如下所示:
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:
因此,事实证明,仅仅在计算机上安装 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.
听起来数据库也需要在空间上启用。它抛出错误的原因是因为缺少该函数。这个资源有一个快速简单的答案和解决方案。
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.
此错误表明该函数无法识别(函数名称或参数类型不正确)
这是定义对于 v7.2 中的 AddGeometryColumn 在
我看来,您正在尝试使用第二个定义,尝试将其更改为使用第一个定义(无架构)并尝试取消引用 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
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...