Using the QspatiaLite plugin
Sometimes, you may not need to load a whole layer into QGIS, but only some subset of it, or perform some calculations on the fly. In such situations, the ability to run complex SQL queries and display their results in QGIS will be very useful.
This recipe shows you how to execute SQL code with the QspatiaLite plugin and load data in QGIS.
Getting ready
To follow this recipe, you need to create connection to the cookbook.db
database created in the Loading vector layers into SpatiaLite recipe in Chapter 1, Data Input and Output. Alternatively, you can use your own SpatiaLite database, but be aware that you might have to alter some of the following SQL statements to match your tables.
Additionally, install the QspatiaLite plugin from Plugin Manager.
How to do it…
Make sure that you created a connection to cookbook.db
. Start the QspatiaLite plugin by navigating to Database | SpatiaLite | QspatiaLite:
To execute the SQL query, perform the following steps:
- Select database...