0

I have two gml files one contains linear data and the other one contains polygon data. I want to have the correct ogr command to merge the two gml files into one file.

I found this answer from 2012 that says ogr does not provide full support for gml data:

How to merge several GML files into one

I am wondering if it is possible in 2023 with ogr2ogr.

I already asked ChatGPT and it gave me few commands that throw error:

ogr2ogr -f "GML" merged.gml 1.gml -update -append 2.gml

that gave me this error:

ERROR 1: Unable to open existing output datasource `merged.gml'.

I also used this command:

ogr2ogr -f "GML" "C:\path\to\directory\merged.gml" 1.gml
ogr2ogr -f "GML" -update -append "C:\path\to\directory\merged.gml" 2.gml -nln merged_layer

that gave me this error:

ERROR 1: Unable to open existing output datasource `merged.gml'.

I also checked the access rights and it was ok I also ran the CMD as Admin.

Does anyone know the ogr command to merge 2 gml files?

1 Answer 1

1

Instead of asking a drunk friend (or chatGPT) why not look at the actual documentation

OGR has limited support for GML reading and writing. Update of existing files is not supported.

So it won't work.

5
  • :D thanks for the funny comment and answer
    – milad
    Jul 25, 2023 at 17:24
  • then, if ogr2ogr cannot merge GML files, what is the best way to merge two gml files? In QGIS I was not able to do it
    – milad
    Jul 25, 2023 at 18:02
  • 1
    you could merge them into say a geopackage and then export that as GML
    – Ian Turton
    Jul 26, 2023 at 7:59
  • Yes, finally I converted both of them to GeoPackage and them merged the GeoPckages using Ogr2ogr tool and then I converted the gpkg file to a gml with two layers using ogr2ogr. Finally, I imported them into PostGIS using ogr2ogr.
    – milad
    Jul 26, 2023 at 23:08
  • @milad - you could make that an answer and then accept it
    – Ian Turton
    Jul 27, 2023 at 7:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.