[GIS] How to merge several GML files into one

gmlogr

I have a folder of GML files that I want to be able to merge to create one GML file that I can then view.
I have tried this using the code described but searching for GML in this website without result.

The code I used was:

mkdir merged 
for %f in (*.gml) do (
if not exist merged\merged.gml (
ogr2ogr -f "GML" merged\merged.gml %f) 
else (
ogr2ogr -f "GML" -update -append merged\merged.gml %f -nln Merged )
)

For clarity the files are for the OS mastermap topography data.

Forgot to say I get the following error message several times when I run the code.

C:\OSMM_GMLS>(if not exist merged\merged.gml (ogr2ogr -f "GML"
merged\merged.gml M00001177-SX6590-5c296.gml ) else (ogr2ogr -f
"GML" -update -append merged\mer ged.gml M00001177-SX6590-5c296.gml
-nln Merged ) ) FAILURE: Unable to open existing output datasource `merged\merged.gml'.

Best Answer

I think I found the answer. The suggested solution (on my website) works great for shapefiles. However, .gml is a bit different, and according to this page, GML does not support the 'update' function. See the first line on that page:

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

Shaunak's solution may be best; convert to another format. You could always convert that back to GML when you are done.