GeoPackage vs. PostGIS

Gispo Ltd.
4 min readJun 6, 2024

--

Okay okay, the comparison between GeoPackage and PostGIS might be seen as a bit odd, since GeoPackage is a data format, whereas PostGIS is an extension of a relational database. However, you might run into an occasion where you need to consider whether to save your spatial thingy as a GeoPackage or to save it in a PostGIS database? Let’s explore when one might excel over the other.

GeoPackage is great. It’s a neat format for storing spatial data, as one (1) file. If we go technical, it’s actually a SQLite database container with a set of conventions, set by The GeoPackage Encoding Standard, defined by the Open Geospatial Consortium (OGC). Woah, that was a lot of words. Anyway, one brilliance of the GeoPackage is the container, since it allows you to use it directly. No need to set anything up, and still, it works very much like a database. You can, for instance, use SQL to query the GeoPackage. Just like you do with a relational database.

PostGIS is a spatial extension of the relational database management system PostgreSQL. So PostgreSQL handles the non-spatial things, whereas PostGIS enables you to work with spatial features. You can have a (spatial) database set up locally, but the real benefits usually come in when it’s set up on a remote server. Then you (and your team) can work with the data from anywhere, together.

The choice between GeoPackage or PostGIS depends on a number of things. Here are a few things to consider.

Working locally

If you are mostly working on your local machine with data that runs smoothly, then your first choice would be GeoPackage. If you need to share the data, ask yourself, is it small enough to fit in an email? Do you need to send data back and forth between people or is it mostly just you sending data to Dave about squirrel habitats? If there’s no real collaboration needed, use GeoPackage.

Working together

If you are working on something together with others, PostGIS might be the way to go. With PostGIS you have the opportunity to create roles and restrictions for different users, so that you can prevent your careless friend Dave from deleting all your squirrel habitat data. You’ll also be completely sure that everyone has the same data (and not Dave’s personal version of the data, that also contains an extra point where his favorite pizza place is located).

Working with a lot of stuff

If you have a lot of layers, let’s say you have many layers of squirrel habitats, then PostGIS sounds like a deal. When you are using PostGIS it’s easy to handle every layer in a similar manner. You can perform the same operations for multiple layers and automate all kinds of things. You could of course work with a very big GeoPackage, but at some point you might want to switch to PostGIS. It is, after all, designed for working with massive amounts of data.

Another awesome thing about PostGIS is the support of indices. There’s plenty to choose from, and you can for example use a clustered GiST (Generalized Search Tree) index to speed up your queries.

Working with complex analyses

Need to do some complex analyses on a huge dataset of all the world’s squirrel habitats? Then you should probably do it in PostGIS. It will probably be faster and more efficient. PostGIS can take advantage of parallel processing to speed up spatial queries even more!

Working with styles

Do you have some cool squirrel-shaped symbols for your layer symbology? But when you send it to Dave, he just sees some boring round points. Well, you need to save the symbology as well. This can easily be done with a GeoPackage, whereas PostGIS doesn’t really care about your rodent-related symbols.

Working with spatial and non-spatial

If spatial data is just one piece of your data puzzle, then you’ll be happy to know that with PostGIS, you can have all your non-spatial data stored right beside your spatial data, since it’s already a PostgreSQL database.

Working on a mobile device

If you are working with spatial data on a mobile device, it’s good to know that GeoPackage actually was developed with mobile use in mind. So if you are developing this crazy popular squirrel habitat map app, let’s call it FluffyTailFinder, then you might want to have your data stored in a GeoPackage.

So to sum up, without any odd references to squirrels, GeoPackage and PostGIS are both things you might need to consider when working with spatial data. Depending on your needs, you might need one or the other, or perhaps both.

Test your knowledge:
Where can one save rodent-related symbols together with data?

This article was initially published at www.gispo.fi by Emil Ehnström (Gispo Ltd.).

--

--

Gispo Ltd.
Gispo Ltd.

Written by Gispo Ltd.

A team of 25 GIS artisans from Finland. We solve spatial problems with open source solutions. https://www.gispo.fi/en

Responses (3)