2011-07-01 24 views
8

使用工具osm2pgsql將phm文件作爲管理工具導入到postgres數據庫中。我只從osm下載了一個xml格式的小鎮,並且無法使用mac上的終端導入它。林有點小白在這個,所以任何幫助將不勝感激。我看了幾篇文章,但沒有提供我需要的清晰度以滿足我的需求。將osm文件導入postgres/postgis數據庫

感謝

即時得到這個錯誤可能是一些小的不知道..

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. 

回答

7

您需要將PostGIS的擴展安裝到你的Postgres數據庫。假設你有你的機器上安裝了PostGIS你需要做的是這樣的:

psql <database> < /usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql 

postgis.sql的確切路徑將取決於分配使用的是和它是如何打包的PostGIS。您可能還需要/不需要用這樣的命令來安裝的空間參考系統表:

psql <database> < /usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql 
+0

我執行這些sql文件,我現在有所有需要的功能。感謝那btw。即時通訊仍然不知道如何使用osm2pgsql進行導入。謝謝 – John

+0

當我嘗試執行'postgis.sql'時,出現錯誤'Type「球體」已存在「。我該如何解決它? –

+1

在postgresql 9和postgis 2版本中,這是通過以下方式完成的:CREATE EXTENSION postgis; CREATE EXTENSION postgis_topology; [更多信息](https://docs.djangoproject.com/en/dev/ref/contrib/gis/install/postgis/) –

0

這是一個示例命令:

osm2pgsql -c -d your_country -U Postgres的-W -H本地主機-P 5432 -s -k -x -p OSM -S default.style .. \ your_country.osm.bz2

以下是一些有用網絡鏈接: http://wiki.openstreetmap.org/wiki/Osm2pgsql http://www.gis.hsr.ch/ wiki/Osm2pgsql

-S。