2

From windows command shell how might I merge a single layer from multiple file-gdb's into another file-gdb using ogr2ogr? All input gdb's have identically named feature classes and attribute structures.

pseudo example:

ogr2ogr {input layername} D:\output.gdb x:\incoming\*.gdb

it's the layername part I'm having trouble with.

asked Mar 26, 2015 at 23:07
1
  • maybe -lco FEATURE_DATASET=NAME? Commented Mar 26, 2015 at 23:17

1 Answer 1

6

In windows command line you could:

FOR /D /R %g IN (*.gdb) DO ogr2ogr -update -append -f FileGBD D:\output.gdb x:\incoming\%g input_layername

Just place the input_layername after the input dataset.

/D tells FOR to search for directories and /R asks it to do it recursively.

In a .bat file, replace the '%' with '%%', so %g> %%g

Extended batch file example using a) gdb's wrapped in zipfiles as data source, b) projecting to a new coordinate system, and c) selecting multiple input feature classes:

set ogropt=-f FileGBD --config FGDB_BULK_LOAD YES -t_srs EPSG:3579
set layers=Layer_1 Layer_2 Layer_3
for /r %%g in (x:\incoming\*gdb.zip) do (
 ogr2ogr %ogropt% -update -append output.gdb %%g %layers%
 )
matt wilkie
28.3k35 gold badges150 silver badges286 bronze badges
answered Mar 26, 2015 at 23:35
1
  • This works. Where I went astray was thinking multiple input files were allowed, similar to gdal_merge. Also, much to my delight, input gdb-in-zipfiles work, although with hundreds of apparently harmless Recode UTF-8 errors. Commented Mar 27, 2015 at 17:25

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.