Storing styles and metadata in a GeoPackage

Or why it is so easy to share you data using a Geopackage.

There are many reasons to like the GeoPackage. One is that it makes it so easy to share your data, including symbology and other layer properties in one database file. And what makes this even better is that you can also store QGIS projects directly inside GeoPackage files. This gets you a totally self-contained GeoPackage that you can easily share.

Saving layer styles to a Geopackage

One way to include layer properties is to save them for individual layer to the GeoPackage. To do so, go to the Symbology tab in the Layer properties windows. Select 1 Style > save style and in the popup window, choose the option 2 In Database (Geopackage).

Optionally, select the option 3 Use as default style for this layer. This is especially convenient if you want to save more than one style for a layer.

One disadvantage is that it does not seem possible yet to save the symbology and other properties of raster layers. In addition, the layers metadata is not included. This is because the metadata is normally saved to the project file.

Saving metadata to a Geopackage

If you want to store the metadata of a layer together with the layer in a Geopackage, go to export > save as option in the layers context menu and make sure to select the option Persist layer metadata.

You can also use the Package layers function in the Processing toolbox to save multiple layers at once to a (new) GeoPackage. Here, you need to select the option Save layer metadata into Geopackage option.

For now it only seems possible to save the metadata of vector layers. That means that if you want to share the metadata of a raster layer, you need to save it as a QMD file. Or, see below how you can save a whole project, including the metadata of raster layers, in a GeoPackage.

Store a project to a Geopackage

Another option is to store QGIS projects directly inside a GeoPackage file. This way, you can create a completely self-contained GeoPackage with not only the data and accompanying styling, but also the project information and settings! Note that because the layer metadata is stored in the project file, this way you can also save the metadata of raster layers in your GeoPackage.

If you already have a project, all you have to do is to go open the Project menu and select Save to > GeoPackage option.

Now, to open the project later on, go to the Project menu and select the option Open From > Geopackage.

Note that you can store multiple projects in a GeoPackage. So you create different projects with for example different styles or with project settings that serve different purposes or audiences.

Also noteworthy, you can save projects to your PostgreSQL database as well. Either way, the ability to store data with accompanying metadata and styling in one place makes it a whole lot easier to store, handle and sharing data.

Paulo van Breugel
Paulo van Breugel
Lecturer & researcher

My interests range from biodiversity and ecology to spatial data analysis. I am also what one could describe as a lifelong learner; I enjoy to learn new things and widen my horizon, both professionally and personally.

comments powered by Disqus
Next
Previous