Numberedheadings | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||
Queries in QGISQueries on layers can be used to filter the data to a smaller subset, select a subset of data for further processing, or simply to interrogate the data. QGIS uses specific terms for different actions:
FilterFilter a layer to see only the filtered features - any features which don’t meet the filter conditions will not be visible in QGIS. Apply a Filter
For example, in the screenshot below, wind turbines have been filtered to those where the STATUS field has the value 'Application permitted - no conditions'. SelectThe Select tools are grouped together in the Attributes toolbar, and additional tools are in the Attribute Table toolbar, shown in the second row below. You can Select features:
Selection
IdentifyUse Identify to click on individual features on the map and get their attribute values, and derived data such as area and length. Identify
The Field CalculatorThe Field Calculator creates new fields, or amends the values of existing ones by using expressions - for example, you could create a new field which totals the values of two existing fields. Field Calculator
As examples, you can use the Field Calculator to: Rename a field: create a new field with the same type and length as the source field, with a new name, and populate the new field with data from the old field Change data type: use a data type conversion (under Conversions) such as to_int to change a data type from string to numeric, for example
Spatial Selections and FiltersThe queries and expressions we have been looking at until now work by using the attribute values of layers rather than their geography. There are a number of options for running spatially-based queries in QGIS, addressing Spatial queries answer questions such as:
Two approaches are covered here:
Spatial queriesThere are many types of spatial queries - use the search box at the left of the information bar to look for others. Select by LocationThis tool creates a new selection of features in a layer, based on a spatial relationship between the layer and another layer (or even the same layer). For example you might want to use it to:
To select points in a polygon: Select the polygon you want to make the selection within - in this instance we have selected a parish within which we want to identify crimes In the search box, search for Select by location, then double-click on it to bring up the dialog In the Select by location dialog, complete the options in a similar way to the screenshot below Note that:
Click OK to run the selection - the result will be a map which looks something like this: Note that only crimes within the selected parish have been selected, and are highlighted Join Attributes by LocationThis tool carries out a similar operation to the one above, but instead of making the result a selection, it adds the attribute values of the second layer to the first, target layer, so that each feature which satisfies the criteria in the spatial analysis takes on the attributes of the feature it is within (in this case). So for example, you could this to add a column to the crimes data, showing the parish that the crime took place in. As in the previous example, select a polygon you want to make a selection with In the search box, search for Join attributes by location Open the dialog, and complete in a similar way to the screenshot below: When the process is run a new Joined layer will be created and added to the map, comprising the original crime layer with, for each feature, the attributes from the parish it is within This layer can then be retained as a temporary layer in the project, or saved as a new layer Identify FeaturesThe Identify Features tool is used to display the attribute values, and some derived properties, of a map feature. Click the layer of interest in the layer list The feature will be highlighted, and the Identify Results panel box will appear, showing the values of all the attributes for the feature Derived InformationThe Derived section in the panel includes measurements derived from the geometry of the feature such as length, area and perimeter (depending on the geometry type). Multiple FeaturesIf you click close to feature boundaries, multiple features are identified, and these will be listed as separate items in the Identify Results hierarchy. Browse the tree to see the data for each feature. Feature AttributesTo view the attributes for a feature in a form dialog, click the View feature form button at the top of the Identify Results panel . This makes it easier to view the data, and if the layer is in edit mode, to edit it.To open the form automatically whenever Identify Results is used, check the Auto open form box at the bottom of the panel. Identify Features from Multiple LayersIf you click on a location where there are features from multiple layers, you will be able to choose which layers to use in populating the Identify Results panel (including all of them). To show results for a single selected layer, select Current layer from the Mode dropdown at the bottom of the Identify Results panel. Copy to clipbboardThe Copy Selected Feature to clipboard button copies the data from the clicked feature to the clipboard as tab delimited text - you can then paste it to a text editor or directly into a spreadsheet.
|
Page Comparison
Manage space
Manage content
Integrations