.osm Datei mittels Osm2pgsql | osmosis in die DB

hallo Forum,

mit

osm2pgsql -s -U postgres -W -d dbname Downloads/meinestadt-map.osm

habe ich versucht genannte Datei in mein PostgreSQL zu bekommen.
Dabei kam folgende Fehlermeldung:

osm2pgsql SVN version 0.70.5
Password:
Connection to database failed: FATAL:  Peer authentication failed for user "postgres"

Das Passwort habe ich heute erst angelegt und weil es auf meiner lokalen Maschine ist ist es auch recht einfach …kurz: ich habe es dann richtig eingegeben.

???

Dann habe ich es einfach mal mit osmosis versucht:

./osmosis –read-xml file=”/home/ich/Downloads/meinestadt-map.osm” –write-apidb host=”localhost” database=”dbname” user=”postgres” password=”mypasswd”

Da sagt es mir:

SEVERE: Thread for task 1-read-xml failed
org.openstreetmap.osmosis.core.OsmosisRuntimeException: Unable to create resultset.
	at org.openstreetmap.osmosis.apidb.common.DatabaseContext.executeQuery(DatabaseContext.java:429)

…was wohl bedeutet, daß die Datei nicht lesbar ist.
Die .osm Datei habe ich von www.openstreetmap.org als OSM-XML exportiert.

PostgreSQL ist mit pgAdmin III und postgis installiert. Meine Datenbank “dbname” hat postgis als Extension aktiviert.
Xubuntu 12.04

Laut den WikiSeiten mache ich doch alles richtig => Glaube ist Parent dieser Aussage.

Kann mir da einer weiter helfen?

wo hast du hier denn ein Password eingegeben? ich sehe zumindest keins.
ok, -W prompted. Dann könnte was in pg_hba.conf von postgresql noch was nicht stimmen.

–write-apidb ist definitiv nicht das, was du hier benötigst, sondern --write-pgsql Allerdings bezweifel ich, dass dir überhaupt klar ist, wo die generellen Unterschiede zwischen der osm2pgsql und der “osmosis-Lösung” liegen. Die sind absolut unterschiedlich und nicht mit einander zu vergleichen.
Das hängt hauptsächlich von deinen geplanten Aktivitäten ab. Darüber solltest du dir erst mal klar werden und die Absichten dann mal kurz schildern.

das reicht nicht bei der “osmosis-Lösung”; für die muß noch erheblich mehr vorbereitet werden. Da ich aber annehme, dass du eh den ersten Weg gehen wirst, spar ich mir das mal.

Gruss
walter

edit: korrigiert

Die Unterschiede zwischen osm2pgsql und osmosis kenne ich nicht wirklich. osmosis ist scheinbar “nebenbei” auch für das da was ich machen möchte.

Ja ok, ich möchte zuerst nur die .osm Datei in meine DB bekommen.

In der pg_hba.conf steht nicht viel drin. Dort steht in den vier nicht-auskommentierten Zeilen Zeilen nichts wo ich sagen würde es schränkt mich ein. Es fehlt etwas?!

# TYPE  DATABASE        USER            ADDRESS                 METHOD
local   all             postgres                                peer
local   all             all                                     peer
host    all             all             127.0.0.1/32            md5
host    all             all             ::1/128                 md5

Nach meiner geposteten Fehlermeldung würde ich denken, daß ich nicht über einen erlaubten Weg den Connect versuche?
Bin ich da auf dem Holzweg?
Was sagt Method->peer?

keene ahnung :wink: mach mal aus dem peer bei postgres trust, so funzt es bei mir. später kannst du das dann ja noch einschränken.

danke, das half.

dann hatte ich http://lists.openstreetmap.org/pipermail/dev/2011-June/022995.html
…und musste nur die Datei (/usr/share/osm2pgsql/default.style) an den richtigen Ort (/usr/share/default.style) schieben.

Aber jetzt bekomme ich noch das:

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
PREPARE get_way (int4) AS SELECT AsText(way) FROM planet_osm_point WHERE osm_id = $1;
 failed: ERROR:  function astext(geometry) does not exist
LINE 1: PREPARE get_way (int4) AS SELECT AsText(way) FROM planet_osm...
                                         ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

Error occurred, cleaning up

Der ERROR muß weg, die NOTICE können ja bleiben.

…welches wohl mit http://www.postgis.org/docs/PostGIS_FAQ.html#legacy_faq zu beheben ist.
Zitat:

Aber wo finde ich die legacy.sql?

edit:
Xubuntu 12.04 legacy.sql
/usr/share/postgresql/9.1/contrib/postgis-2.0/legacy.sql

psql -U postgres -d dbname -f /usr/share/postgresql/9.1/contrib/postgis-2.0/legacy.sql

…ausführen.

nächster ERROR (ganz unten):

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
Setting up table: planet_osm_line
NOTICE:  table "planet_osm_line" does not exist, skipping
NOTICE:  table "planet_osm_line_tmp" does not exist, skipping
Setting up table: planet_osm_polygon
NOTICE:  table "planet_osm_polygon" does not exist, skipping
NOTICE:  table "planet_osm_polygon_tmp" does not exist, skipping
Setting up table: planet_osm_roads
NOTICE:  table "planet_osm_roads" does not exist, skipping
NOTICE:  table "planet_osm_roads_tmp" does not exist, skipping
Mid: pgsql, scale=100, cache=800MB, maxblocks=102401*8192
Setting up table: planet_osm_nodes
*** WARNING: intarray contrib module not installed
*** The resulting database will not be usable for applying diffs.
NOTICE:  table "planet_osm_nodes" does not exist, skipping
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "planet_osm_nodes_pkey" for table "planet_osm_nodes"
Setting up table: planet_osm_ways
NOTICE:  table "planet_osm_ways" does not exist, skipping
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "planet_osm_ways_pkey" for table "planet_osm_ways"
Setting up table: planet_osm_rels
NOTICE:  table "planet_osm_rels" does not exist, skipping
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "planet_osm_rels_pkey" for table "planet_osm_rels"

Reading in file: /home/allapow/zeug/OSM_GIS/HagenZentrum-map.osm
WARNING: Found Out of order node 994740242 (3068578,18) - this will impact the cache efficiency
Processing: Node(34k) Way(6k) Relation(253)  parse time: 7s

Node stats: total(34945), max(2136197385)
Way stats: total(6840), max(222812607)
Relation stats: total(253), max(2825698)

Going over pending ways
processing way (4k)

Going over pending relations

node cache: stored: 25203(72.12%), storage efficiency: 1.29%, hit rate: 66.73%
Stopping table: planet_osm_nodes
Stopping table: planet_osm_ways
Stopping table: planet_osm_rels
Stopped table: planet_osm_nodes
Stopped table: planet_osm_rels
Committing transaction for planet_osm_point
Committing transaction for planet_osm_roads
Stopped table: planet_osm_ways
Sorting data and creating indexes for planet_osm_roads
Committing transaction for planet_osm_line
Committing transaction for planet_osm_polygon
Sorting data and creating indexes for planet_osm_point
Sorting data and creating indexes for planet_osm_polygon
Sorting data and creating indexes for planet_osm_line
CREATE INDEX planet_osm_roads_index ON planet_osm_roads USING GIST (way GIST_GEOMETRY_OPS) TABLESPACE pg_default;
 failed: ERROR:  operator class "gist_geometry_ops" does not exist for access method "gist"

Error occurred, cleaning up

…aber ich habe Daten in der Tabelle :slight_smile:

sorry, muß ich passen, da ich osm2pgsql nicht benutze. Aber es wird schon ein Kollege weiterwissen.

Gruss
walter

Suchen hilft manchmal: http://forum.openstreetmap.org/viewtopic.php?pid=293271

Steht auch in der FAQ, die du weiter oben schon verlinkt hast: http://www.postgis.org/docs/PostGIS_FAQ.html#legacy_faq_gist

hey, dank euch …ich bin alle ERRORS los.

PS: und danke auch wegen dem Tip mit dem Suchen :smiley:

Habe fast das gleiche Problem:

System:

Distributor ID:	Ubuntu
Description:	Ubuntu 12.04.3 LTS
Release:	12.04
Codename:	precise

Prozessor:
4 x

[...]
vendor_id	: GenuineIntel
cpu family	: 6
model		: 42
model name	: Intel(R) Core(TM) i5-2500 CPU @ 3.30GHz
stepping	: 7
microcode	: 0x14
cpu MHz		: 1600.000
cache size	: 6144 KB
[...]

PostgreSQL:

Package: postgresql
Status: install ok installed
Priority: optional
Section: database
Installed-Size: 63
Maintainer: Martin Pitt <martin.pitt@ubuntu.com>
Architecture: all
Source: postgresql-common (129ubuntu1)
Version: 9.1+129ubuntu1
Depends: postgresql-9.1

Postgis:


SELECT post_full_version();

"POSTGIS="2.0.1 r9979" GEOS="3.3.8-CAPI-1.7.8" PROJ="Rel. 4.8.0, 6 March 2012" GDAL="GDAL 1.9.2, released 2012/10/08" LIBXML="2.7.8" RASTER"
---
$ dpkg -s postgis

Package: postgis
Status: install ok installed
Priority: optional
Section: misc
Installed-Size: 2917
Maintainer: Debian GIS Project <pkg-grass-devel@lists.alioth.debian.org>
Architecture: amd64
Version: 2.0.1-2~precise3
Depends: libc6 (>= 2.14), libgdal1 (>= 1.9.0), libgeos-c1 (>= 3.3.3), libglib2.0-0 (>= 2.12.0), libgtk2.0-0 (>= 2.14.0), libpq5, postgresql-9.1-postgis

Hier der osm2pgsql Befehl

 Karten$ osm2pgsql -c -d OSM_Oberrhein -U postgres -H localhost -S ./default.style ./Oberrhein.osm
osm2pgsql SVN version 0.70.5

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
Setting up table: planet_osm_line
NOTICE:  table "planet_osm_line" does not exist, skipping
NOTICE:  table "planet_osm_line_tmp" does not exist, skipping
Setting up table: planet_osm_polygon
NOTICE:  table "planet_osm_polygon" does not exist, skipping
NOTICE:  table "planet_osm_polygon_tmp" does not exist, skipping
Setting up table: planet_osm_roads
NOTICE:  table "planet_osm_roads" does not exist, skipping
NOTICE:  table "planet_osm_roads_tmp" does not exist, skipping
Mid: Ram, scale=100

Reading in file: ./Oberrhein.osm
Processing: Node(28822k) Way(4530k) Relation(46570)  parse time: 2138s

Node stats: total(28822374), max(2147483645)
Way stats: total(4530516), max(238065157)
Relation stats: total(46570), max(3208127)

Writing way (4530k)

Writing relation (46457)
Committing transaction for planet_osm_roads
Committing transaction for planet_osm_point
Sorting data and creating indexes for planet_osm_roads
Sorting data and creating indexes for planet_osm_point
Committing transaction for planet_osm_line
Committing transaction for planet_osm_polygon
Sorting data and creating indexes for planet_osm_line
Sorting data and creating indexes for planet_osm_polygon
CREATE INDEX planet_osm_roads_index ON planet_osm_roads USING GIST (way GIST_GEOMETRY_OPS) TABLESPACE pg_default;
 failed: ERROR:  operator class "gist_geometry_ops" does not exist for access method "gist"

Error occurred, cleaning up
Speicherzugriffsfehler (Speicherabzug geschrieben)

Jedoch ist die Datenbank in die die Daten geladen werden noch leer, hat also keine Tabellen außer spatial_ref_sys, welche durch Create Extension postgis; erzeugt wurde. Demzufolge wüsste ich gerade nicht, wie ich http://www.postgis.org/docs/PostGIS_FAQ.html#legacy_faq_gist anwenden soll.

legacy.sql wurde bereits ausgeführt, legacy_gist.sql gibts nicht

Hier der Inhalt des Postgisverzeichnisses:

/usr/share/postgresql/9.1/contrib/postgis-2.0$ ls -l
insgesamt 5228
-rw-r--r-- 1 root root    2055 Dez  6  2012 legacy_minimal.sql
-rw-r--r-- 1 root root   53961 Dez  6  2012 legacy.sql
-rw-r--r-- 1 root root   64270 Dez  6  2012 postgis_comments.sql
-rwxr-xr-x 1 root root  146156 Dez  6  2012 postgis_restore.pl
-rw-r--r-- 1 root root  194675 Dez  6  2012 postgis.sql
-rw-r--r-- 1 root root  149790 Dez  6  2012 postgis_upgrade_20_minor.sql
-rw-r--r-- 1 root root   68850 Dez  6  2012 raster_comments.sql
-rw-r--r-- 1 root root    5195 Dez  6  2012 rtpostgis_legacy.sql
-rw-r--r-- 1 root root  183197 Dez  6  2012 rtpostgis.sql
-rw-r--r-- 1 root root  199364 Dez  6  2012 rtpostgis_upgrade_20_minor.sql
-rw-r--r-- 1 root root 3593936 Dez  6  2012 spatial_ref_sys.sql
-rw-r--r-- 1 root root   14036 Dez  6  2012 topology_comments.sql
-rw-r--r-- 1 root root  268175 Dez  6  2012 topology.sql
-rw-r--r-- 1 root root  267937 Dez  6  2012 topology_upgrade_20_minor.sql
-rw-r--r-- 1 root root   14314 Dez  6  2012 uninstall_legacy.sql
-rw-r--r-- 1 root root   36121 Dez  6  2012 uninstall_postgis.sql
-rw-r--r-- 1 root root   46839 Dez  6  2012 uninstall_rtpostgis.sql
-rw-r--r-- 1 root root   10189 Dez  6  2012 uninstall_topology.sql

Wäre sehr dankbar für ein wenig Hilfe.

Nee, das ist was ganz anderes - aber was?
Auf jeden Fall in der PostGis-Ecke, da fehlt was.

check mal das hier:

machst zwar kein django - was immer das ist- aber schaden kann es wohl nicht. ansonsten GIS-Installation checken.

Wenn du die Postgresql/Postgis platt machen kann, installiere alles mit dem neuen Installer von postgresql. Ist ne Gui, bei der dann nix fehlt. und natürlich 9.3

Gruss
walter