0

I'm trying to figure out if it's possible to only show the structure (layer names, field names and types, constraints, etc) of a GeoPackage which has no data record using GDAL/OGR (ogrinfo).

Is it possible?

If not, do you know any other open source solution to achieve the same task on Ubuntu?

I currently have:

# ogrinfo mydata.gpkg 
INFO: Open of `mydata.gpkg'
      using driver `GPKG' successful.

with: GDAL 3.9.0dev-336811c7257a31f59b4f11292fa4691716bb8ace, released 2024/01/26

3
  • 1
    Did you try -so -al -ro as arguments to ogrinfo?
    – Ian Turton
    Apr 5 at 17:57
  • Yes, e.g. with -ro I'm facing: FAILURE: Unable to open datasource 'mydata.gpkg' with the following drivers. Apr 5 at 20:07
  • Odd, just the other 2 then
    – Ian Turton
    Apr 6 at 8:58

1 Answer 1

1

According to https://www.geopackage.org/guidance/getting-started.html :

A GeoPackage is an SQLite Database file with a .gpkg extension. If you are unsure whether a file is an SQLite database, you can use a binary or text editor to view the starting bytes of the file and see if they state SQLite format 3.

So, using the sqlite3 CLI one can run:

  • sqlite3 file.gpkg to log into the database

Now, from the sqlite3 console one can list database, tables and schemas as follow:

  • .databases # list databases
  • .tables ?TABLE? # List names of tables matching LIKE pattern TABLE
  • .schema ?PATTERN? # Show the CREATE statements matching PATTERN

More with .help

Exit sqlite3 with .exit

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.