将osm文件导入postgres/postgis数据库

Joh*_*ohn 8 postgresql phppgadmin postgis openstreetmap

我使用工具osm2pgsql使用phppgadmin作为管理工具将osm文件导入postgres数据库.我只是以xml格式从osm下载了一个小镇,我在使用mac终端导入时遇到了麻烦.我有点像这样的菜鸟所以任何帮助将不胜感激.我看过几篇文章,但没有提供我需要的清晰度以满足我的需求.

谢谢

我得到这个错误可能是一些小不确定..

Using projection SRS 900913 (Spherical Mercator)
Setting up table: planet_osm_point
NOTICE:  table "planet_osm_point" does not exist, skipping
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.
Run Code Online (Sandbox Code Playgroud)

Tom*_*omH 7

您需要将postgis扩展安装到postgres数据库中.假设您的机器上安装了postgis,您需要执行以下操作:

psql <database> < /usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql
Run Code Online (Sandbox Code Playgroud)

确切的路径postgis.sql取决于您使用的分发以及它如何打包postgis.您可能还需要/需要使用如下命令安装空间参考系统表:

psql <database> < /usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql
Run Code Online (Sandbox Code Playgroud)