What is DuckDB?
DuckDB is an open source relational database system (under MIT license). DuckDB databases are portable (like SQLite or GeoPackage, for example), which make them easy to use: no need for “heavy” installation, just install a library in your favorite language (Python, Rust, R, C++). A CLI is also available.
Finally, to conclude this brief introduction to the solution, it’s worth noting that DuckDB has the particularity of using a column-based processing system (and not row-based as in conventional DBMSs), which reduces calculation times for certain operations. Another advantage of this solution is its ability to read and convert data in Parquet or GeoParquet format.
DuckDB has an extension for using spatial data which is not activated by default. The disadvantage of this spatial extension is that it does not currently support projection systems. Most of these spatial functions are taken from the GEOS library. All the classic spatial functions are included, as well as support for many spatial data formats such as Shapefile, GeoJSON and KML.
Thanks to funding from IFREMER, we have developed a QGIS plugin that can display spatial data contained in a DuckDB database.
At a time when DuckDB is making the headlines on the various networks, it’s important that an open source GIS software as important as QGIS should be able to read geographic data from this source.
Having reached the end of the first phase of QDuckDB development, we are proud to announce the availability of QDuckDB, which enables you to load a geographic data layer from a DuckDB database into QGIS.
The main developments in QDuckDB are as follows:
- Addition of a data provider for reading a DuckDB database
- Creation of a user interface to use the provider
- Creation of a Windows package to include DuckDB dependencies in the plugin
Under the hood
A specific data provider integrated into QGIS
To add support for a new data source in QGIS, you need to create a new provider. By default, the QGIS core includes a number of providers, such as PostgreSQL or GeoPackage, while others can be implemented in plugins. In the QGIS context, a provider is the implementation of interfaces that define a data provider that will enable QGIS to obtain the information it needs to build a layer (columns, geometry, structure, metadata, projection, primary key, etc.). The creation of a layer is by far the most important and voluminous part of this project.
We decided to implement this new provider via a QGIS plugin (and not in the core). Firstly, because the technology is new and still evolving rapidly, and secondly, because it’s easier to maintain a plugin than a core development.
The provider doesn’t yet allow you to edit data; it is currently “read only” and only works with tables containing a single type of geometry (Point, Line or Polygon).
The following features are already identified. You can make them a reality through funding :
- Layer editing (modify data, add/delete columns, create/delete entities, etc.)
- Importing a spatial layer from QGIS directly into a DuckDB database
- Better integration of DuckDB in QGIS
- Support for tables with multiple geometry types
- If you have any development requests, please don’t hesitate to contact us: email@example.com