In a GIS project, there are so many data formats one can use for their analysis. Depending on the data available for your project, one can leverage the power of QGIS to extract meaningful pieces of data for their analysis. As defined in the QGIS documentation, virtual layers in QGIS are created as a result of a query using the SQL language, simple or complex. This query can be conducted on various vector layers that are supported in QGIS (or basically can be opened in QGIS).
Virtual layers are basically views representing other layers in a GIS. You will manage to open the attribute tables, carry out geoprocessing on them, and export them without limitations.
One other thing to note with virtual layers in QGIS; virtual layers persist after the project closes. Unlike the temporary scratch layers, these layers persist.
Practical Examples
As shown in the figure below, a virtual layer has been created from the polygon dataset (Ken_Adm2) to represent one of the regions within the country (virtual_layer_rift_valley).
In the image above, the highlighted region exists as a separate layer which is a result of an SQL query.
In QGIS, just like any other vector layer, the outputs of the SQL query(the virtual layer) can be used for analysis. In the example shown below; creating a virtual layer from schools using the first virtual layer as the overlay area.
As shown in the image above, a filter has been applied to the schools layer. All schools that fall within the area shown above have been filtered. When creating virtual layers in QGIS, there are quite a number of functions that one can utilize in writing queries. Since spatial queries are just like any other database queries, it makes them easy to write and implement.
Tutorial
To explore more about creating virtual layers in QGIS, here’s a quick tutorial.
For questions, leave a comment below.
Great Tutorial! I’m looking for datasets focused on Kenya, for use in QGIS. Do you have any data/urls you could share?
Basically, post codes, provinces, neighborhoods, etc.
Any advice is greatly appreciated.
Hi Splints,
Nice. Mostly, I get data from https://data.humdata.org/
For Kenya its more of County – Sub County – Wards