Fede
Fede

Reputation: 41

Using osmosis to convert POSTGIS Table to .OSM

I am using osmosis 0.42 and PostGIS 2.0.1 and I'm trying to export some postGIS tables to .OSM xml files.

I am using the --read-pgsql command to read from postgis (instead of --read-apidb as it throws an error while connecting to the DB )..

Unfortunately running:

osmosis --read-pgsql host="x" database="x" user="x" password="x" --write-xml file="myfile.osm"

produce the following error:

Task 2-write-xml does not support data provided by default pipe stored at level 1 in the default pipe stack

Any ideas?

Thanks a lot!

Fede

Upvotes: 4

Views: 2867

Answers (4)

Mesa
Mesa

Reputation: 309

The problem is that --read-pgsql produces a dataset, but --write-xml expects an entity stream.

Use --dataset-dump between these two steps to convert the dataset to an entity stream:

osmosis --read-pgsql host="x" database="x" user="x" password="x" --dataset-dump --write-xml file="myfile.osm"

Upvotes: 4

TimSC
TimSC

Reputation: 1539

To get a limited area:

osmosis --read-pgsql database=egypt-osm user=gisuser password='test0199' outPipe.0=pg --dataset-bounding-box inPipe.0=pg top=30.1332509 left=31.1400604 bottom=29.9400604 right=31.3220215 outPipe.0=dd --write-xml inPipe.0=dd file=- | bzip2 > cairo.osm.bz2

To get everything:

osmosis --read-pgsql database=egypt-osm user=gisuser password='test0199' outPipe.0=pg --dd inPipe.0=pg outPipe.0=dd --write-xml inPipe.0=dd file=- | bzip2 > everything.osm.bz2

Remember to use an up to date osmosis if you get errors like "java.util.HashMap cannot be cast to org.openstreetmap.osmosis.hstore.PGHStore"

Upvotes: 0

Bvbever
Bvbever

Reputation: 13

I have not found a solution despite the fact that my data in postgis has the "snapshot" schema.

I have found a solution on http://marcusjenkins.com/maps/plumbing-with-openstreetmap-osmosis/

The solution is: osmosis --read-pgsql host="localhost" database="foo" user="foo" password="foo" outPipe.0=pg --dd inPipe.0=pg outPipe.0=dd --write-pbf inPipe.0=dd file=wherever_munged.osm.pbf

Upvotes: 1

Shaun McDonald
Shaun McDonald

Reputation: 6581

The problem is that your database isn't in a format that Osmosis understands. There's only a couple of schemas that Osmosis supports, thus you'll need to write a custom exporter.

Upvotes: 1

Related Questions