This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

pull out osm file from postgres database

0

Hey, is it possible to pull out a .osm file from a postgres database. ive got osm data inputted inside a postgresql datbase on my linux server, is it now possible to pull that data out into an osm file Thanks in advance :)

asked 27 Jan '21, 13:02

shafi-as's gravatar image

shafi-as
107712
accept rate: 0%


One Answer:

1

If you have imported with osm2pgsql or imposm then the answer is no, you can never go back to the original OSM file because metadata has been lost. You could possibly write code to generate a "pseudo" OpenSteetMap XML but how you would do that, and how useful it would be, depends on the data structure in your PostgreSQL and on what you want to do with the resulting OSM file.

answered 27 Jan '21, 13:52

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

1

i have imported using osmosis API DB would it be possible with that

(27 Jan '21, 14:07) shafi-as
2
(27 Jan '21, 14:21) SK53 ♦

Thanks Frederik for the insight, Also SK53 solution has allowed me to create an osm file from an API DB, for anyone who is looking for a command

sudo osmosis --read-apidb-current host="localhost" database="openstreetmap" user="xxxx" password="xxx" validateSchemaVersion="no" --write-pbf file="file path of where you want it saved and the file type /home/export.osm.pbf"

(28 Jan '21, 09:40) shafi-as

Source code available on GitHub .