Creating views in SpatiaLite
In a database, view is a stored query. Every time you open it, the query is run and fresh results are generated. To use views as layers in QGIS takes a couple of steps.
Getting ready
For this recipe, you'll need a query that returns results containing a geometry. The example that we'll use is the query from the Joining tables in databases recipe (the previous recipe) where attributes were joined 1:1 between the census polygons and the population CSV. The QSpatiaLite plugin is recommended for this recipe.
How to do it…
The GUI method is described as follows:
- Using the QspatiaLite plugin (which is in the Database menu, if you've activated it) place the following in the query:
SELECT * FROM census_wake2000 as a JOIN census_wake2000_pop as b ON a.stfid = b.stfid;
- From the Option dropdown, select the last choice, Create Spatial View & Load in QGIS, and set the Geometry field box value to the name of your geometry field from your spatial layer....