将osm文件导入postgres数据库时出错

时间:2014-02-23 22:15:19

标签: postgresql openstreetmap postgis tilemill

我使用osm2psql使用以下命令将osm文件导入postgres数据库:

osm2pgsql -cGs -d osm -S /usr/local/share/osm2pgsql/default.style ~/Downloads/your_file.osm.pbf

当我在终端中运行时,我收到以下错误:

Jonathans-MacBook-Pro:Downloads rjth$ osm2pgsql -cGs -d osm -S
/usr/local/share/osm2pgsql/default.style ~/Downloads/vienna-bratislava.osm.pbf
osm2pgsql SVN version 0.84.0 (64bit id space)
Using projection SRS 900913 (Spherical Mercator)
Setting up table: planet_osm_point
NOTICE:  table "planet_osm_point" does not exist, skippin
NOTICE:  table "planet_osm_point_tmp" does not exist, skipping
SELECT AddGeometryColumn('planet_osm_point', 'way', 900913, 'POINT', 2 );
failed: ERROR:  function addgeometrycolumn(unknown, unknown, integer, unknown, integer) does not exist
LINE 1: SELECT AddGeometryColumn('planet_osm_point', 'way', 900913, ...
           ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
Error occurred, cleaning up

我已经针对类似的问题尝试了TomH suggested,我已经按照official tilemill documentation的每一步进行了操作。对于postgis的安装选项我安装了postgresapp

1 个答案:

答案 0 :(得分:1)

我遇到了同样的问题。

如果create extension postgis已完成,那么它不是数据库osm

您需要在osm数据库中添加扩展名。

rjth$ psql osm
osm=# create extension postgis;

然后运行您的命令来访问osm.pbf文件,它应该工作。