6

I am trying to merge many shapefiles into a single gpkg using ogr2ogr (version 3.0.2).

The command I am using is:

ogr2ogr dst.gpkg src.shp -nln layerOne
ogr2ogr dst.gpkg src.shp -nln layerTwo

BUT when I run ogrinfo it says my dst.gpkg has only layerTwo.

10

You are overwriting dst.gpkg every time you run ogr2ogr. From the geopackage documentation:

For adding new layers into existing geopackage run ogr2ogr with -update.

So do:

ogr2ogr -f GPKG dst.gpkg src.shp -nln layerOne
ogr2ogr -f GPKG -update dst.gpkg src.shp -nln layerTwo

Or if all source shapefiles are in a single directory:

Translation of a directory of shapefiles into a GeoPackage. Each file will end up as a new table within the GPKG file. The file filename.gpkg must not already exist, as it will be created.

    ogr2ogr -f GPKG filename.gpkg /path/to/dir
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.