Selection by attribute conditions

Introduction

It is also possible to select features by using selection conditions on feature attributes. These conditions are formulated in SQL (if the attribute data reside in a relational database) or in a software-specific language (if the data reside in the GIS itself). This type of selection answers questions like “Where are the features with …?”

Explanation

Figure 1 shows an example of selection by attribute condition. The query expression is Area < 400,000, which can be interpreted as “Select all areas of land use of which the size is less than 400,000.” The polygons in blue are the selected areas; their associated records are also highlighted in blue.

Figure 1: Spatial selection using the attribute condition Area < 400,000 on land use areas in Dar es Salaam. Spatial features on the left, associated attribute data (in part) on the right.

We can use a set of features already selected as the basis for further selection. For instance, if we are interested in land use areas of size less than 400,000 that are of land use type 80, the selected features of Figure 1 are subjected to a further condition, Land Use = 80. The result is illustrated in Figure 2.

Figure 2: Further spatial selection from the features already selected in the previous Figure using the additional condition Land Use = 80 on land use areas. Note that fewer features are now selected.

Combining attribute conditions

The combination of conditions just dealt with in the previous subsection is fairly common in practice.

When multiple criteria have to be used for selection, we need to carefully express all of these in a single composite condition. The tools for this come from a field of mathematical logic known as propositional calculus.

The example of the previous subsection made use of simple atomic conditions such as Area < 400,000 and Land Use = 80. Atomic conditions use a predicate symbol, such as < (less than) or = (equals). Other possibilities are <= (less than or equal), > (greater than), >= (greater than or equal) and <> (does not equal). Any of these symbols is combined with an expression on the left and one on the right. For instance, Land Use <> 80 can be used to select all areas with a land use class different from 80. Expressions are either constants like 400,000 and 80, attribute names like Area and Land Use, or possibly composite arithmetic expressions like 0.15×Area, which would compute 15% of the area size.

Atomic conditions can be combined into composite conditions using logical connectives. The most important ones are AND, OR, NOT and the bracket pair (…). If we write a composite condition such as Area < 400,000 AND Land Use = 80, we can use it to select areas for which both atomic conditions hold true. This is the meaning of the AND connective. If we had written Area < 400,000 OR Land Use = 80 instead, the condition would have selected areas for which either condition holds, so effectively those with an area size less than 400,000, but also those with land use class 80. (Included, of course, will be areas for which both conditions hold.)

The NOT connective can be used to negate a condition. For instance, the condition NOT (Land Use = 80) would select all areas with a different land use class than 80. (Clearly, the same selection can be obtained by writing Land Use  <> 80 but this is not the point.) Finally, brackets can be applied to force grouping amongst atomic parts of a composite condition . For instance, the condition (Area < 30,000 AND Land Use = 70) OR (Area < 400,000 AND Land Use = 80) will select areas of class 70 less than 30,000 in size, as well as class 80 areas less than 400,000 in size.

Learning outcomes

  • 11 - Spatial analysis: classes of functions

    Classify and explain spatial analysis functions (measurements, classification, overlay, neighbourhood and connectivity) in a raster and vector environment (level 1 and 2).

Prior knowledge

Outgoing relations

  • Selection by attribute conditions is a kind of Query