Using osmosis to convert POSTGIS Table to .OSM

久未见 提交于 2019-12-05 15:55:24

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

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"

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.

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"

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!