A Spatial Query is one made on the spatial element of the
database. Unlike a query based on attributes, it is the feature's topology (relationship with other objects in the same geographic
extent) of the object that is queried.
Task
This demonstration
illustrates the spatial query to be carried out on feature layers in QGIS in order to resolve customer
complaints to a Utility Company. The Utility Company has a Tariff Map
that delineates areas within a city into High, Medium and Low Tariff
Blocks (red boxed).
Subsequently,
Customer complaints from Parcels-543,435 and 378 (as seen above) have
reached the Company Office about abnormally high utility bills. In order
to save time and money, the Company GIS team will analyze the
complaints so as to forward the viable complaints to the ground teams.
Steps
Three spatial queries were performed.
- Spatial query to know which Parcels fall within the Low Tariff Block.
- Spatial query to know which Parcels fall within the High Tariff Block.
- And a third Spatial query to ascertain whether there are Parcels that overlap between the Low and High Tariff Blocks.
Procedure
1. Go to Vector >Spatial Query >Spatial Query
2.
In the Spatial Query dialog box, we first want to determine which
parcels are completely within the Low Tariff Block especially in respect
to the complaint from Parcel 543. We Select Source features- PARCELS
that are WITHIN target or reference feature- LOW TARIFF BLOCK. Two
parcels are highlighted- 302 and 304 but 543 is not highlighted but it
falls within the Low Tariff Block. But also note that Parcels 435 and
378 are not highlighted.
3. Right Click on the Parcels layer >Open Attribute Table to see that the Selected Parcels were highlighted.
4. See the Selection of our Spatial Query highlighted in blue.
5.
We run another spatial query to ascertain which Parcels are within the
High Tariff Block. The result shows that Parcels- 435 and 378 fall
within the High Tariff block. Parcel 543 again is not within the High
Tariff Block.

6.
To further filter the data, we run a third spatial query selecting the
Parcels that overlap into the High Tariff Block. Viola! Parcel 543 is
selected.
Results of the Spatial Query
- for Customer Complaints from Parcels- 543, 435 and 378. Read brown box.

- Hope you enjoyed the post.
Keep practicing so we can share your experience.