I have a Python script that creates hundreds of individual shapefiles and in the end, merges them iteratively to one big geodatabase using ogr2ogr.

I want one geodatabase output with a single feature class and all of the polygons from the input shapefiles in that feature class, but that is not what is happening and I cannot figure out why.

This is what I am doing:

# if output.gdb does not exist:
ogr2ogr -nln output -a_srs EPSG:4326 -t_srs EPSG:4326 -f "FileGDB" output.gdb input1.shp

# if output.gdb does exist (i.e. not on the first iteration):
ogr2ogr -nln output -a_srs EPSG:4326 -t_srs EPSG:4326 -update -append -f "FileGDB" output.gdb input2.shp

# And repeat the second command for each inputX.shp (in my case, 109 shapefiles, 66959 total points)

Please note that the names have been changed for readability. The input shapefiles are not numbered like that, so the feature class names in the resulting output.gdb are not a result of the input names.

This is what the output (with the names again changed to be more readable and consistent with the above) looks like when I run ogrinfo on output.gdb [broken up into 2 screenshots]:

screenshot1 screenshot2

When viewing the individual feature classes in Arc, it appears that each represents one of the inputs. What am I doing wrong here? What is with all the feature classes, their names, and why are there only 100 of them as opposed to 109? How can I rectify this to get my desired end result?


I wanted to check and be sure the field names were consistent throughout. I compared the field names from 2 random input shapefiles, and they were the same (as I would expect for all of them). Then I checked against the output geodatabase and discovered all of my columns from the shapefiles that began with a number were different in the gdb (they all had been changed to have an underscore before them). I found out the gdb's cannot have field names that begin with a number. Could this be why the above commands did not want to merge the shapefiles into the same feature class within the output geodatabase? I will run a test to see.


I ran 2 tests: one merging the 3 shapefiles with some columns beginning with a number, and another merging the 3 shapefiles where those columns had been changed to begin with a letter. The resulting gdb of the latter test had field names that matched the input shapefiles exactly, but both tests resulted in the same issue where the output gdb had 3 feature classes instead of the results being in one single feature class. So that was not the problem.


Tried a bunch of suggestions from this answer, and still same issue. I also tried ogrmerge.py and I can't write to a gdb in update mode. At a loss.

  • Test the ogr2ogr side by using GeoPackage as outputformat. It that works the issue is related to FileGDB. If same happens with GeoPackage it is still easier to investigate for those who do not have GDAL with FileGDB driver.
    – user30184
    Apr 24, 2020 at 7:26
  • I tried your suggestion @user30184. It appears that the result of running the same exact commands (I am working with just two shapefiles to test now) but with -f GPKG results in one layer as desired (with 321+10 = 331 total features). So your theory is then that something is wrong with the FileGDB driver? Any suggestions with how to go about rectifying that? Converting to GDB after the fact seems to have worked but would like a better solution if one exists (I did not build the system so know nothing about how they may have messed up the driver install or whatever). Thanks!
    – user20408
    Apr 27, 2020 at 20:42
  • Sorry, I do not know anything about the internals of the FileGDB driver. All I know is that it is using the SDK from ESRI and therefore GDAL developers cannot control totally what is happening. It does not mean that the error is in the SDK, it can happen on the GDAL side as well. Perhaps you would get served though the gdal-dev mailing list.
    – user30184
    Apr 27, 2020 at 21:13

1 Answer 1


If you want a single file/db, maybe what you can use is ogr_merge https://gdal.org/programs/ogrmerge.html. That scripts combines all layers you pass

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.