Convert multiple GML files to postgres tables using ogr2ogr

by Theo F   Last Updated November 16, 2018 17:06 PM

I have a folder with 150 .gml files I need to upload to my postgis/postgres database. After the first gml is uploaded, the rest will be appended to it to form a single table. However I don't know how to make ogr2ogr iterate through each file... currently I'm having to upload/append each cml induvidually.

My code to convert the first gml:

ogr2ogr -update -append -f "PostgreSQL" PG:"host=localhost port=5432 dbname=testdb user=admin password=password" -lco SCHEMA=test_schema "D:\path to folder\File1.gml" -progress -lco OVERWRITE=YES

and my code to append each subsequent gml to the first:

ogr2ogr -update -append -f "PostgreSQL" PG:"host=localhost port=5432 dbname=testdb user=admin password=password active_schema=test_schema" "D:\path to folder\File2.gml" -progress

This works fine but I don't want to do this another 148 times, changing File2 to File3 each time etc....

Related Questions

Add Shapefile loader plugin to PgAdminPortable

Updated June 24, 2016 08:02 AM

postgres 9.2 and PostGis 2.0: How can I join it

Updated January 12, 2018 14:06 PM