Postgis (or geojson) to .osm file

I have a big postgres table that I would to to see exported as an .osm file.
So far I have succeeded in exporting a part of this table to geojson (with ogr2ogr) and then converting this file via JOSM to an .osm file (save as). I can export the entire table als geojson but it is way to big for JOSM. So I am looking for a way to export postgis to .osm and possibly via geojson.

The reason for this is because I am trying to create an Osmand map of public Dutch geodata. OsmAndMapCreator accepts .osm files. Any suggestions?

If you are just exporting points and ways you can try GitHub - simonpoole/geojson2osm: Small java tool to convert GeoJSON to OSM data to convert from geojson to OSM. See the caveats, if there is a specific issue I might be motivated enough to fix it if you open an issue :slight_smile:

Thanks. Currently my data has only polygons and multipolygons so I guess that would not work.

I found ogr2osm but since I am on windows this seems a bit too complicated for me. :frowning_face:

You should be able to relatively easily get python3 running on windows. The main issue is that you will need to have a lot of memory if the dataset is large, but that is the same essentially for all current tools.

For ogr2osm you mean? Yes I have python3.9 installed but the things is … I lack knowledge on how to get all these tools running together. To me it seems there are some many things to do before everythings runs properly that I just give up. But maybe I will give it an other try this time.

Recently, I created a tool that convert postgis directly to .osm file. It is simple to use. It is working on Linux Debian, but I’m not sure about others Operating Systems.

So far, it has some limitation as described in the section “To-do”, but I plan to improve the code.

Check it out on GitHub - santamariense/postgis_to_osm: postgis_to_osm converts a PostgreSQL + PostGIS table into an .osm file.