Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

osm2pgsql: Function AddGeometryColumn doesn't exist

I want to import OSM file into my PostgreSQL database (Windows, Postgres Version 9.2) using the tool Osm2pgsql.

When I run following command

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

I get the error

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

Translation from German:

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

How can I fix this?

like image 510
Dmitrii Pisarenko Avatar asked Oct 30 '12 04:10

Dmitrii Pisarenko


1 Answers

It looks like you haven't added PostGIS support to the database you're trying to use osm2pgsql.exe on. See the PostGIS installation documentation (2.0).

Since you are using PostGIS 2.0, you should be able to just CREATE EXTENSION postgis; to load PostGIS. This command must be run as a superuser - normally the user postgres. Use:

psql -U postgres mydbname

to connect as user postgres.

It appears that at least the Windows builds of osm2pgsql don't support PostGIS 2.0 - or didn't about six months ago, anyway. See this issue report on the OSM GitHub, and the instructions on how to set a PostGIS 2 database to be compatible with an osm2pgsql that expects PostGIS 1.x. Future readers should check that these steps are still actually required before proceeding; it's likely that osm2pgsql for Windows will be updated to support PostGIS 2 at some point.

like image 133
Craig Ringer Avatar answered Sep 24 '22 00:09

Craig Ringer