My question is about the basic structure of a .gpkg file. When I make a .gpkg file, they only ever contain one layer, and I cannot add additional layers to them. However, sometimes when I have added and then exported the vector layers as .qgz files and the completed map as .qgt files, all left in the same directory as the .qpkg file, they will show up in the layers or associations of the .gpkg file, IF I have saved the .gpkg file after performing all these operations.

As an example, following the above to create these files and saving them all in the same directory, would show two layers when I opened the .gpkg file: X.gpkg - contains polygons [layer 1] Y.gqz - contains points [layer 2] Y.gqt - contains themes for map made [not seen as layer, but accessible via SHOW LAYOUT MANAGER]

Is there a way that I could save all this so that it was just in one .gpkg file? Or instead is the .gpkg file always found with its corresponding layer files as separate files?

I've watched numerous videos on YouTube, read the documentation but am still fundamentally confused about this.


1 Answer 1


Geopackage is in fact a container format (like zip files). It as based on SQLite, thus it has database functionality. See more about Geopackage here: https://www.geopackage.org/

You can save several layers (vector and raster) as well as styles, QGIS projects etc. to the same Geopackage file.

To make an example (download the file):

  1. I loaded the pre-installed vector base-map (type world in the coordinates field at the very bottom of your QGIS window), than applied a style to it. With geomtry by expression, I created the centroid of the countries (point layer) and the boundary (line layer), applying different styles for each.

  2. Than I saved the first layer: right click layer / Export / Save Features As... and created a new Geopackage.

  3. Now, I saved the two other layers to the same Geopackage: right click layer / Export / Save Features As... an select the same Geopackage, but be sure to define another Layername in the dialog window so that the already existing layer will not be overwritten.

  4. Now, save the project to the same Geopackage: Menu Project / Save as [second entry] / Geopackage (see screenshot). In the dialog that opens, for connection select the same Geopackage file, give a name to the project and click OK. enter image description here

  5. Click the following link to download the Geopackage created this way. To open it, in your QGIS main window go to the Browser panel and navigate to the folder where you stored the Geopackage. You can expand the Geopackage entry to see what it contains - compare the screenshot: you see the different layers as well as the QGIS project (red arrow). Double click the project to open the whole project or one of the layers to open just this one. When opened, it should look like this (if you just open the Geopackage, e.g. by drag and drop, only the layers contained will be loaded, but not the project - thus settings in the project like styles will not be loaded):enter image description here

In this way, you can add additional layers etc. to the Geopackage. Click the curved double arrow icon at the top of the Browser panel to refresh the display of the Geopackage's content.

In this way, you can share whole projects, including the data by sending just a single file. However, be aware that many settings (project!) are QGIS-specific and may also vary from version to version of QGIS. So for long-term archiving, I would not recommend to save everything in one large Geopackage - it's also difficult to keep an overview of what you have and as a complex binary format, you need special software (like QGIS) to access Geopackages.

  • Thank you for this very detailed and helpful response. I will work through these steps after I'm doine teaching tomorrow.
    – Jeff Boggs
    Mar 31, 2021 at 22:58
  • And thank you for the edit :) In your answer, how did you get the directory/path for the commands to show in a grey box? Is that something you added in HTML here? Or was that some sort of native Mac feature for copying commands? Do you know if a PC will do this? I ask because this is a feature --- showing the command path in grey --- I would like to use in my tutorials for my students.
    – Jeff Boggs
    Apr 2, 2021 at 16:19
  • 1
    Format the text using {} icon above the text or pressing ctrl + K or manually enclosing the text with Grave accent: `. See for details about formating: gis.stackexchange.com/editing-help - Markdown (see: en.wikipedia.org/wiki/Markdown) is great for creating tutorials. I already used a GitLab Wiki (about.gitlab.com) to that end.
    – Babel
    Apr 3, 2021 at 20:20
  • I just wanted to say thank you again. This works! I do have two related questions I hope you might be able to answer: [1] can project files .qgz ever be saved in the .gpkg file? [2] If the answer to Q1 is NO, must .qgz files (if you want them to work correctly) always be placed in the same directory as the .gpkg they call for their layers, etc.?
    – Jeff Boggs
    Apr 9, 2021 at 17:50
  • 1
    1: yes, you can save projects directly to a Geopackage file (see step 4 in my answer above). 2: no, project files can be saved wherever you want. Just make sure the path to the data you use in the project is valid. If you move your project file to another folder, relative paths become invalid. Saving everything in one folder can be helpful if you want to send the project to someone else: you can use relative paths for the data (Geopackage) in the same folder as the project so this will work on the remote machine as well.
    – Babel
    Apr 17, 2021 at 8:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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