I'm trying to load a directory of shapefiles into a geodatabase with ogr2ogr. It works fine if I specify a single shapefile, but can't open the datasources if I specify a wildcard. Is there a wildcard I can use to import all of the shapefiles in the directory?
this works:
ogr2ogr -f 'FileGDB' -update -append allroads.gdb roads.shp
This fails and errors with:
"Unable to open datasource `roads.shp' with the following drivers."
ogr2ogr -f 'FileGDB' -update -append allroads.gdb *.shp
Best Answer
OGR treats a folder as a data source with shapefiles in the folder as layers. If you add the folder using
ogr2ogr
then it will add all the shapefiles to the output data source. For example to create a GML file with one layer for every shapefile in the foldershapes
, do:which should work for any OGR output data format, including your File GDB.
Note that it might add any geographic data files in
./shapes/
, so if there's KML or GML in there they might get added too.