postgresql - osm2pgsql : Function AddGeometryColumn doesn't exist

标签 postgresql postgis openstreetmap postgresql-9.2

我要导入OSM file使用工具 Osm2pgsql 进入我的 PostgreSQL 数据库(Windows,Postgres 版本 9.2) .

当我运行以下命令时

osm2pgsql.exe --create -d mydb artyom.xml -U myuser -W --style default.style

我得到了错误

SELECT AddGeometryColumn('planet_osm_point', 'way', 900913, 'POINT', 2 );
 failed: FEHLER:  Funktion addgeometrycolumn(unknown, unknown, integer, unknown,
 integer) existiert nicht
LINE 1: SELECT AddGeometryColumn('planet_osm_point', 'way', 900913, ...
               ^
HINT:  Keine Funktion stimmt mit dem angegebenen Namen und den Argumenttypen ├╝b
erein. Sie m├╝ssen m├Âglicherweise ausdr├╝ckliche Typumwandlungen hinzuf├╝gen.

Error occurred, cleaning up

德语翻译:

SELECT AddGeometryColumn('planet_osm_point', 'way', 900913, 'POINT', 2 );
 failed: ERROR:  Function addgeometrycolumn(unknown, unknown, integer, unknown,
 integer) doesn't exist
LINE 1: SELECT AddGeometryColumn('planet_osm_point', 'way', 900913, ...
               ^
HINT: No function matches the specified name and argument types. Maybe you need
to make explicit casts.

Error occurred, cleaning up

我该如何解决这个问题?

最佳答案

看起来您还没有将 PostGIS 支持添加到您尝试使用 osm2pgsql.exe 的数据库中。参见 the PostGIS installation documentation (2.0) .

由于您使用的是 PostGIS 2.0,因此您应该能够CREATE EXTENSION postgis; 来加载 PostGIS。此命令必须以 super 用户身份运行 - 通常是用户 postgres。使用:

psql -U postgres mydbname

以用户 postgres 身份连接。

看起来至少 osm2pgsql 的 Windows 构建不支持 PostGIS 2.0 - 或者至少在六个月前不支持。参见 this issue report在 OSM GitHub 上,以及 instructions on how to set a PostGIS 2 database to be compatible with an osm2pgsql that expects PostGIS 1.x . future 的读者应该在继续之前检查这些步骤是否确实需要; Windows 的 osm2pgsql 可能会在某个时候更新以支持 PostGIS 2。

关于postgresql - osm2pgsql : Function AddGeometryColumn doesn't exist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13132649/

相关文章:

android - 为 mapsforge 项目正确设置 M2_repo 类路径变量

multithreading - Postgres 中的并发查询

postgresql - 自动化 postgresql 数据迁移,最好是 fabric 任务

postgresql - 在 Mac 上安装 PostGIS for PostgreSQL 时出错

performance - 带有 GiST PostGIS 空间索引的 PostgreSQL point_ops

javascript - 简单的 Leaflet.js 标记放置

ruby-on-rails-3 - 如何清除模型的 :has_many associations without writing to the database in ActiveRecord?

node.js - 如何使用 sequelize v6 在 ES6 语法中关联模型

postgresql - 如何从无效的线串中构建区域(或防止错误)

javascript - 在隐藏的 div 中加载 OpenStreetMap