1

Somehow I can't import OSM data to my database. I'm using Debian, PostgreSQL 9.1 and PostGIS 1.5. The user root has been granted all privileges for the database osm.

Input:

imposm -U root -d osm -m imposm-mapping.py --read --write --optimize sweden-latest.osm.pbf

Output:

Enabling Shapely speedups.
loading imposm-mapping.py as mapping
password for root at localhost:
[16:35:06] ## reading sweden-latest.osm.pbf
[16:35:07] coords: 11724k nodes: 234k ways: 1674k relations: 11k (estimated)
[16:39:56] coords: 17332k nodes: 75k ways: 1445k relations: 7k
[16:39:57] reading took 4 m 51s
[16:39:57] ## dropping/creating tables
Traceback (most recent call last):
  File "/usr/bin/imposm", line 9, in <module>
    load_entry_point('imposm==2.4.0', 'console_scripts', 'imposm')()
  File "/usr/lib/python2.7/dist-packages/imposm/app.py", line 231, in main
    db.create_tables(tag_mapping.mappings)
  File "/usr/lib/python2.7/dist-packages/imposm/db/postgis.py", line 129, in create_tables
    self.create_table(mapping)
  File "/usr/lib/python2.7/dist-packages/imposm/db/postgis.py", line 160, in create_table
    pg_geometry_type=mapping.geom_type))
psycopg2.ProgrammingError: permission denied for relation spatial_ref_sys
CONTEXT:  SQL statement "SELECT SRID         FROM spatial_ref_sys WHERE SRID = new_srid"
PL/pgSQL function "addgeometrycolumn" line 75 at SQL statement
SQL statement "SELECT AddGeometryColumn('',$1,$2,$3,$4,$5,$6)"
PL/pgSQL function "addgeometrycolumn" line 5 at SQL statement

EDIT:

And this is what I get when I use the user postgres instead:

[13:36:35] ## dropping/creating tables
[13:36:36] ## writing data
Traceback (most recent call last):
  File "/usr/bin/imposm", line 9, in <module>
    load_entry_point('imposm==2.4.0', 'console_scripts', 'imposm')()
  File "/usr/lib/python2.7/dist-packages/imposm/app.py", line 243, in main
    writer.relations()
  File "/usr/lib/python2.7/dist-packages/imposm/writer.py", line 52, in relation                                    s
    cache = self.cache.relations_cache()
  File "/usr/lib/python2.7/dist-packages/imposm/cache/osm.py", line 59, in relat                                    ions_cache
    return self._x_cache(self.relations_fname, RelationDB, mode, estimated_recor                                    ds)
  File "/usr/lib/python2.7/dist-packages/imposm/cache/osm.py", line 68, in _x_ca                                    che
    cache = x_class(x, mode, estimated_records=estimated_records)
  File "tc.pyx", line 104, in imposm.cache.tc.BDB.__init__ (imposm/cache/tc.c:12                                    63)
IOError: 3
3
  • Looks like you do not have the rights to change spatial_ref_sys. Commented Mar 25, 2013 at 18:58
  • How do I get those rights then? :-) I'm used to MySQL, so this is completely new to me. Commented Mar 26, 2013 at 13:42
  • I only know the way I could do that under Windos with pgAdminIII. In the osm database, under schema/public/tables, I see that the table spatial_ref_sys is not owned by the osm user, but by user postgres. Right-clicking on the table allows to change that in Settings. Commented Mar 26, 2013 at 16:03

2 Answers 2

1

Try importing your data using user postgres (-u postgres). Before you complain ;) you don't know the password for that user, do the following:

sudo su postgres
(type your password)
psql
ALTER USER postgres WITH PASSWORD 'set_your_pass_here';
\q
exit
1
  • I tested to use postgres as well, see my edit. :-) Commented Mar 26, 2013 at 13:40
0

IOError: 3 translates to 'No such process'.

That makes me believe that you might not have installed postgis correctly?

For postgis2.0 and above it's as simple as

 CREATE EXTENSION postgis;
 CREATE EXTENSION topology;

EDIT:

The error

...
File "tc.pyx", line 104, in imposm.cache.tc.BDB.__init__ (imposm/cache/tc.c:1263)`
IOError: 3

refers (I think) that it cannot find the Tokyo Cabinet Library.

At line 103-104 at tc.pyx the code does a check if the library is loaded. Maybe you haven't installed imposm dependencies correctly?

You can check more information about how you can do it here.

3
  • I'm using PostGIS 1.5, does that matter? Commented Mar 26, 2013 at 14:42
  • It should't. Check the edit Commented Mar 26, 2013 at 14:55
  • I removed imposm, reinstalled all dependencies and then installed imposm though pip instead of apt-get. That solved the problem! Thank you for the advice. :-) Commented Mar 28, 2013 at 16:38

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.