I have multiple shapefiles. When it becomes one layer (one shapefile) the volume of shapefile gets over the limit of its capacity (I believe 4GB? is the limit of *.shp can have)

Therefore, I need to save them into FGDB using ogr2ogr

this is the code I came out with so far.

for %f in (*disp_line.shp) do (if not exist test.gdb (ogr2ogr -progress --config shape_encoding "UTF-8" -f "filegdb" test.gdb %f -lco encoding="UTF-8") Else (ogr2ogr --config shape_encoding "UTF-8" -progress -f "filegdb" -update -append test.gdb %f -nln test_layer -lco encoding="UTF-8"))

when I see the result.. I get two layers. enter image description here

t_sc1disp_line feture class has 20 rows and test_line has 286 rows it is supposed to be 306 rows (20+286)..

What it means is that I have to merge the layers once again using QGIS or ArcGIS GUI tools.

Could you fix my weird OGR2OGR command?

  • Add -nln test_line to the first command of the loop as well. Now you create first layer with the default name and only after that append the rest of the layers into "test_line". Did you really use -nln test_layer and got test_lineas a result?
    – user30184
    May 24, 2018 at 7:26
  • @user30184 you are right just adding -nln test_line at the first loop solved the issue. thanks a lot. and of course i didn't use -nln test_layer for my command. i made up with the -nln tag the example above.
    – Pil Kwon
    May 24, 2018 at 7:35
  • The shapefile limit is 2Gb, not 4Gb, for each file.
    – Vince
    May 24, 2018 at 18:20
  • I am trying to do the same as OP. I am using the same value for -nln in both the first iteration command and all others (the only difference in the command used for all other iterations is the addition of "-update" and "-append" flags). And yet ogr2ogr is still placing each shapefile in a separate feature class, instead of a single feature class, within the gdb. Per this answer, it seems that what I am seeing is not correct behavior from ogr2ogr, is that correct? gis.stackexchange.com/questions/359377/…
    – user20408
    Apr 27, 2020 at 20:35

1 Answer 1


base on on @user30184 the code should be changed to

for %f in (*disp_line.shp) do (if not exist test.gdb (ogr2ogr -progress --config shape_encoding "UTF-8" -f "filegdb" test.gdb %f -nln test_line -lco encoding="UTF-8") Else (ogr2ogr --config shape_encoding "UTF-8" -progress -f "filegdb" -update -append test.gdb %f -nln test_line -lco encoding="UTF-8"))

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.