An open format for geospatial information

GeoPackage is a compact, portable, self-descriptive and open,
standards-based, platform independent and allowing geospatial information transfer
format.

The GeoPackage standard is composed of a set of conventions to store in
a SQLite database the following items:

  • vector entities
  • matrixes from images and rasters tiles with different scales
  • attributes (non-spatial data)
  • extensions

To put it clearly, a GeoPackage is the SQLite container and the encodingstandard, GeoPackage governs the rules and requirements of the content stored in a GeoPackage container. The GeoPackage standard defines the diagram of a GeoPackage including table definitions, assertions of integrity, format limitations and content constraints. Thecontent required and taken in charge of a GeoPackage is entirely defined in thestandard. These features are reframed on a common basis and the extension mechanism provides to the developers a way to include additional features in their GeoPackages.

Since GeoPackage is a database container, it takes in charge its direct
use by different GIS software. This means that the GeoPackage data can be
consulted and updated in a “native” storage format without intermediate format conversion.
The GeoPackages complies with the requirements of the standard without having
to implement specific extensions from the seller are interoperable in all
environments IT corporate and personal. The GeoPackages are particularly useful
for mobile devices such as mobile phones and tablets in the communication
environments where connectivity and bandwidth are limited .

Geopackage in QGis

If you are, already, using data bases Spatialite in QGis you will wonder
what novelty does Geopackage bring: basically the ability to store rasters in a
SQLite database.

If, on the other hand, you are used to work with shapefiles (SHP), we
have already published several articles that explain the benefits of working
with SQLite

The Geopackage format behaves exactly as Spatialite and QGis by giving you
new possibilities .

Therefore, if you change from shapefiles to SQLite, opt for Geopackage rather
than Spatialite.

How to create a Geopackage with QGis 3.4

GeoPackage is a standard OGC data package that can store different types
of spatial data types such as points, polylines and polygons. We can save
several layers in just one GeoPackage ( .gpkg ) file. It is an excellent way to
store and organize your spatial data with QGIS. When you save your spatial files
to GeoPackage format you can easily find them without having to browse and to
dig in all your records.

Using Geopackage to store our spatial data has many advantages. Our data
will be placed in a centralized location. By using this method we can reduce
the cluttering that occurs when we are dealing with hundreds of files. It is
easier to transfer huge amounts of layers in a single geopackage .

To create a géopackage layer in QGIS it will do just to:

1-Open QGIS
2-Go to Layer | Create a layer | New geopackage layer  

3-
Type the name of the new GeoPackage layer, give a name to the table and
possibly select a geometry in the list.   

If you expect to import existing layers in your Geopackage, you can
click OK. Your Geopackage will be created and empty, well, almost. You will have
this empty table but with the possibility of erasing it at any time.

If, on the other hand, you want to start creating a true working layer,
you will use the block   “New field” from the window to define your table columns.

Your Geopackage file is created. In order to use
it in QGis you must connect to this new database:

The
new database appears in the explorer as follows:

How to fill a Geopackage database

You have three methods for adding layers to a Geopackage file:

Creation from scratch

You will add an empty table by defining the
fields (columns) manually. You will repeat the steps described above when
creating the Geopackage (Layer menu> Create a layer -> New Geopackage layer).
Once the creation window opens, use the … button to point the geopackage file
where you want to create a new layer:  

Fill
in the necessary fields (table name, geometry , … ) as well as the definition
of your columns . When you click OK you will get the following message:   

Click
Add a new layer, this layer will then added to the list of layers of your
geopackage file.  

Saving from an existing layer

You can export to a geopackage file an alreadyexisting layer. You will select your layer in the panel “Layers” andExport ->SaveAs …entities

In
the opening window, in the formats list, select Geopackage

In
File Name, click the … button and point to your Geopackage file.   

Fill in the necessary fields and click OK. The layer is imported to
your Geopackage .

Importing an existing layer with DB Manager

The DB Manager allows you to totally manage your data and databases.

To open Database-> DB Manager

In the DB Manager window, to import an existing layer in your geopackage
file,

  • click in the panel Data providers on your Geopackage file
  • click on the Layer / file import tool

fill in the
fields for   Importalayervector window 

Important! Check the SRC source and SCR target boxes and verify
that the CBC corresponds to what you wish . Check the Create a spatial index
box if you in want one. If you fail to add this information in this step , it
will be very , very complicated to catch up …

Si cet article vous a intéressé et que vous pensez qu'il pourrait bénéficier à d'autres personnes, n'hésitez pas à le partager sur vos réseaux sociaux en utilisant les boutons ci-dessous. Votre partage est apprécié !

4 thoughts on “Geopackage format and QGis 3

  1. Hi, do you know what happens to text put into the “description” field in the save to geopackage dialogues. Seens very useful to be able to add a layer description, but whatever I type there just seems to vanish, I can’t find any way to read it once saved, assuming it actually does get saved.

    1. You will not see these fields in the Database Manager if you open your geopackage with the “geopackage option”.Open your geopackage using the “Spatialite” option. You will then see the gpkg tables and in particular gpkg_contents.Your description text is saved there.But you’re right. Right now you can’t reuse it. Maybe in future versions….

      1. Thanks, good to see that it really does get saved into the geopackage. I’ve posted a feature request to make it easier to see.
        issues.qgis.org/issues/21293

Leave a Reply to Michael Dufty Cancel reply

Your email address will not be published. Required fields are marked *