0

When running osm2psql on an existing database I get an error

osm2pgsql -v -d gis -a -s -G --flat-nodes ./nodes.cache --number-processes 8 ./thailand.osm.pbf

Output is :


Allocating memory for dense node cache
Allocating dense node cache in one big chunk
Allocating memory for sparse node cache
Sharing dense sparse
Node-cache: cache=800MB, maxblocks=12800*65536, allocation method=11
Mid: loading persistent node cache from ./nodes.cache
Mid: pgsql, cache=800
SQL command failed: ERROR:  relation "planet_osm_ways" does not exist
LINE 1: ...REPARE mark_ways_by_node(int8) AS  SELECT id FROM planet_osm...
                                                             ^

Full query: PREPARE mark_ways_by_node(int8) AS  SELECT id FROM planet_osm_ways    WHERE nodes && ARRAY[$1];
PREPARE mark_ways_by_rel(int8) AS  SELECT id FROM planet_osm_ways    WHERE id IN (      SELECT unnest(parts[way_off+1:rel_off])        FROM planet_osm_rels WHERE id = $1    );

node cache: stored: 0(0.00%), storage efficiency: 0.00% (dense blocks: 0, sparse nodes: 0), hit rate: 0.00%
Osm2pgsql failed due to ERROR: Executing SQL

Displaying current existing tables in postgres gives:

gis=# \dt
              List of relations
 Schema |        Name        | Type  | Owner 
--------+--------------------+-------+-------
 public | planet_osm_line    | table | osm
 public | planet_osm_point   | table | osm
 public | planet_osm_polygon | table | osm
 public | planet_osm_roads   | table | osm
 public | spatial_ref_sys    | table | osm
(5 rows)

As I understand it, the -s option (slim mode) is supposed to create 3 new tables : https://github.com/openstreetmap/osm2pgsql/blob/master/docs/pgsql.md#database-layout

planet_osm_nodes
planet_osm_ways
planet_osm_rels

It's like osm2psql tries to access those tables before creating them at first.

PS: I also tried without the flat-nodes option osm2pgsql -v -d gis -a -s -G -C 40000 --number-processes 8 ./thailand.osm.pbf with same result.

1

There are two issues.

First, to be able to append new data, you must have initially loaded the 1st dataset using the slim option.

Then you can't append an entire dataset, but only the diff file, that you either download (like the daily diff) or create.

2
  • All right, this is really unclear in the documentation. Is there a way to append a new dataset then ? I'm guessing the solution is to create my own diff file : osmconvert old.osm new.osm --diff -o=changefile.osc but will that work anyway if I didn't created with the slim option at first ? – Ruinaga Oct 22 '20 at 10:10
  • Yes, computing the difference and applying it is the option for appending data. No, it won't work if you didn't use slim the 1st time. It may be faster/easier to just replace the dataset instead of updating it – JGH Oct 22 '20 at 12:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.