7.4.1. Spatial query and select by location
Similar to ArcGIS (section 6.4.1.), different functions exist to obtain information for defined locations: The Identify Features button is the same as the Identify tool of ArcGIS (see section 6.4.1.) and is used to obtain information about specific pixel values within a raster image or to look at the attribute values of a vector feature. Before applying the Identify Features tool, it is necessary to activate and select the appropriate layer in the Map Legend. In addition, various spatial operations are provided within the main menu Vector. Of particular interest is the function Spatial Query that allows more advanced queries by using vector geometries. To demonstrate this functionality with QGIS we will ask for all communes that contain at least one honey bee colony.
- Choose Vector from the main menu.
- Select Spatial Query (a dialog window will appear).
- Select the layer commune_boundary_FR.shp as Source Features and the point vector file with the honey bee colonies as Reference Features.
- Choose the operator Contains to be applied between these two features.
- Choose to create a New Selection (alternatively, it could be added to or removed from an existing selection).
- Click Apply and close the
dialog, if the result looks similar to Fig. 81.
Intersection operations can also be applied with the help of the function Select by location:
- Go to Vector.
- Choose Research Tools.
- Select Select by location.
- Choose the settings according to Fig. 82 to achieve similar results as
displayed in Fig. 81.
In practice, spatial selection operations are frequently used to assign attributes of one layer to another layer and for raster calculation tasks or modelling tasks.
Fig. 81. Result after performing a spatial query: The honey bee colonies are located within 11 different administrative districts around the city of Fribourg. The orange polygon represents the first in the Result Feature ID’s list. Reproduced with permission of Swisstopo (BA13016).
Fig. 82. Result after performing a spatial query: The honey bee colonies are located within 11 different administrative districts around the city of Fribourg.