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]:
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.