Creating Spatial Databases
This chapter covers the creation and editing of spatial databases. While there are many spatial database types that QGIS can connect to, such as Oracle SDO, MySQL, SQL Server, and of course PostGIS, for ease of use, we're going to concentrate on a spatial database type that requires no installation and that can be easily shared. SpatiaLite (.sqlite) and GeoPackage (.gpkg) are the most common portable databases.
GeoPackage is being pushed as the replacement for the Industry Standard GIS file type, the SHP file, and you may notice as you start to use QGIS more that it crops up as the first choice of file type to open or export to.
In this chapter, we will touch on the core concepts of databases but moreover explore the following topics:
- Fundamental database concepts
- Creating a spatial database (GeoPackage)
- Connecting to a GeoPackage
- Importing data into a GeoPackage
- Working with tables
- Exporting tables out of a GeoPackage
- Creating queries and views
As of QGIS 3.6, it is not possible to import rasters into a GeoPackage, just vectors. We are not going to cover how to import rasters into GeoPackages in this book. However, if you are interested in this, we suggest looking at the GDAL library for further reference ( https://www.gdal.org/drv_geopackage_raster.html).