• Blog posts

    Bio

    By David Crowther

    QGIS___Save_to_GeoPackage_Project_-_1.PNG

    QGIS 3.8 Zanzibar was released in August 2019 and the full change log can be viewed here:

    https://qgis.org/en/site/forusers/visualchangelog38/index.html

    Haven’t replaced your Shapefiles with GeoPackage yet? Well here’s another reason why you should….

    In QGIS 3.8, they have added the ability to store QGIS projects directly inside GeoPackage files! This means that you can create a totally self-contained GeoPackage which embeds a QGIS Project AND all the data used by the project.

    Saving to GeoPackage Projects

    Step 1 - Firstly, if you haven’t already got any you will need to create a GeoPackage file.

    In QGIS I have opened 3 Shapefiles for 3 roads layers – ARoads, Broads and Mways.

    QGIS___Save_to_GeoPackage_Project_-_2.PNG

    Using the GeoPackage Layers tool you can select your 3 individual Shapefiles and save them into ONE GeoPackage file. Ensure you set the Destination GeoPackage to a name and location that you will remember – here I have chosen to name the GeoPackage – AllRoads.gpkg.

    QGIS___Save_to_GeoPackage_Project_-_3.PNG

    Note - This is what a GeoPackage file looks like in Windows Explorer.

    QGIS___Save_to_GeoPackage_Project_-_4.PNG

    Step 2 - Once the GeoPackage file has been created, to test that the GeoPackage opens you will need to create a NEW Connection to the GeoPackage file using Data Source Manager. Here we have made a connection to the AllRoads GeoPackage file and called the connection AllRoads.

    QGIS___Save_to_GeoPackage_Project_-_5.PNG

    Selecting all three layers in the Table window and then choosing Add will open each of the 3 datasets in the AllRoads GeoPackage into QGIS…. displaying the 3 individual layers.

    QGIS___Save_to_GeoPackage_Project_-_6.PNG

    Step 3 – Using the enhancement to QGIS we can now choose the Project – Save to GeoPackage option to create a Project file within the GeoPackage file.

    QGIS___Save_to_GeoPackage_Project_-_7.PNG

    However, before we do that we will undertake some styling, labelling and add a basemap to our project.. as per the example below.

    QGIS___Save_to_GeoPackage_Project_-_8.PNG

    Having now started to build a Project, we can choose to save the project settings into the GeoPackage file.

    From the Project menu choose Save to GeoPackage. Choose the Connection to be the GeoPackage file that we created in Step 1, and enter a Project Name e.g. All UK Roads Styled and then press OK.

    QGIS___Save_to_GeoPackage_Project_-_9.PNG

    To test that the Project has been saved in the GeoPackage file, close and re-open QGIS and then from the Project menu choose Open FromGeoPackage.

    QGIS___Save_to_GeoPackage_Project_-_10.PNG

    Choose from the list of Connections for GeoPackage files that you may have previously created, in this case we will choose the AllRoads.gpkg file.

    Then finally from the Project list choose the All Roads Styled project and then press OK.

    QGIS___Save_to_GeoPackage_Project_-_11.PNG

    Note – One GPKG file may contain more than one Project, which means you can style the data as many ways as required and store those settings in multiple different Projects.

    QGIS will now open the Project stored within the GeoPackage file… remembering all the style changes and additional data sources e.g. OSM that were saved into the Project.

    QGIS___Save_to_GeoPackage_Project_-_12.PNG

    Yet another reason to ditch those Shapefiles and go truly Open Source!