importing osm file into a postgres/postgis database

天涯浪子 提交于 2019-12-21 11:43:19

问题


Im using the tool osm2pgsql to import an osm file into a postgres database using phppgadmin as the administrative tool. i have only downloaded a small town from osm in xml format and im having trouble importing it using the terminal on mac. Im a bit of a noob at this so any help would be greatly appreciated. Ive looked at several articles but none provide the clarity i need in order to fulfill my needs.

Thanks

im getting this error could be something small not sure..

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.

回答1:


You need to install the postgis extensions into your postgres database. Assuming that you have postgis installed on your machine you need to do something like:

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

The exact path to postgis.sql will depend on the distribution you are using and how it has packaged postgis. You may also want/need to install the spatial reference systems table with a command like this:

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



回答2:


This is an example command:

osm2pgsql -c -d your_country -U postgres -W -H localhost -P 5432 -s -k -x -p osm -S default.style ..\your_country.osm.bz2

Here are some useful weblinks: http://wiki.openstreetmap.org/wiki/Osm2pgsql http://www.gis.hsr.ch/wiki/Osm2pgsql

-S.



来源:https://stackoverflow.com/questions/6546373/importing-osm-file-into-a-postgres-postgis-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!