I would like to upload a specific table (i.e. U2018_CLC2012_V2020_20u1 (Multi Polygon)) from a Geopackage file to a PostGIS database from the command line. I tried:

ogr2ogr -f "PostgreSQL" "PG:database" \
    -t_srs EPSG:3035 -overwrite -lco GEOMETRY_NAME=geom -nln "corine.corine12_vec" \

However, I just realized, the Geopackage contains multiple tables and only (the wrong) one (i.e. U2018_CLC2012_V2020_20u1_FR_MYT (Multi Polygon)) is uploaded.

Q: How can I upload a specific table or all tables?

Output of ogrinfo U2018_CLC2012_V2020_20u1.gpkg:

INFO: Open of `U2018_CLC2012_V2020_20u1.gpkg'
      using driver `GPKG' successful.
1: U2018_CLC2012_V2020_20u1 (Multi Polygon)
2: U2018_CLC2012_V2020_20u1_FR_REU (Multi Polygon)
3: U2018_CLC2012_V2020_20u1_FR_GLP (Multi Polygon)
4: U2018_CLC2012_V2020_20u1_FR_GUF (Multi Polygon)
5: U2018_CLC2012_V2020_20u1_FR_MTQ (Multi Polygon)
6: U2018_CLC2012_V2020_20u1_FR_MYT (Multi Polygon)

1 Answer 1


You can specify the name of the tale inside a Geopackage:

ogr2ogr -f "PostgreSQL" "PG:database" -t_srs EPSG:3035 -overwrite -lco \
    GEOMETRY_NAME=geom -nln "corine.corine12_vec" \
    U2018_CLC2012_V2020_20u1.gpkg NAME_OF_LAYER

So for example for the U2018_CLC2012_V2020_20u1 layer:

ogr2ogr -f "PostgreSQL" "PG:database" -t_srs EPSG:3035 -overwrite -lco \
    GEOMETRY_NAME=geom -nln "corine.corine12_vec" \
    U2018_CLC2012_V2020_20u1.gpkg U2018_CLC2012_V2020_20u1

For all tables if you do not need to rename the layers (from @user30184 in the comments), you can run:

ogr2ogr -f "PostgreSQL" "PG:database" -t_srs EPSG:3035 -overwrite \
    -lco GEOMETRY_NAME=geom -lco SCHEMA=corine U2018_CLC2012_V2020_20u1.gpkg

This will use the layer name from the Geopackage, and uses the -lco SCHEMA= tag for specifying a schema.

  • 3
    Single command is enough for all tables if there is no need to rename the tables. ogr2ogr -f "PostgreSQL" "PG:database" -t_srs EPSG:3035 -overwrite -lco GEOMETRY_NAME=geom U2018_CLC2012_V2020_20u1.gpkg" should convert everything.
    – user30184
    Commented Feb 18, 2021 at 16:12
  • 1
    @user30184 thanks, I updated the answer. Commented Feb 18, 2021 at 16:49

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.