Map algebra can also be used to convert the units or range of units in which data is represented (e.g., changing an elevation data layer's units from feet to meters by multiplying the elevation value in each pixel or attribute record by 0.3048).
The Map Algebra tools will typically provide three different kinds of operations:
1. the ability to arithmetically modify attribute data values by a constant (i.e., scalar arithmetic, Figure 2) such as when we divide all of the distance values in a raster or attribute table by 1000 to convert distance attributes in meters to new distance values in units of kilometers;
2. the ability to mathematically transform attribute data values by a standard operation (e.g., the trigonometric functions, log transformations and so on, Figure 3) such as when we create a new data layer or attribute field by taking the cosine of all of the slope value attributes because this is required by our particular analysis;
3. the ability to mathematically combine (such as add, subtract, multiply, divide) different data layers to produce a result (Figure 4). Perhaps we have an equation that is the result of a regression analysis. To apply that equation to a set of variable layers, we would use map algebra. If we have an equation which relates the amount of rainfall and the elevation of an area to biomass productivity, we could use a digital elevation model and a rainfall map as variables in a map algebra equation to derive an estimated biomass productivity data layer.
This third operation is simply another form of overlay - mathematical overlay, as opposed to the logical (Boolean) overlay of database query.
In a raster GIS, the input and output layers all have the same geometry, (e.g., number of rows/columns, spatial extent represented, pixel size/resolution) but the attribute values for some or all of the cells in the output raster are altered by the transformation applied.
In a Vector GIS, transformation of data values by a scalar or function is typically performed directly in the attribute database or wherever the feature attributes are stored. Data layer combination generally involves creation of a new data layer in which the number and shapes of features differ from those in the input data layers. This is often accompanied by the addition or removal of features in the attribute data storage location.
Although it may be obvious, we might note for completeness that application of Map Algebra between images requires that the images used coincide with respect to projection, spatial extent, and, in addition for raster layers, pixel size.
Three operations which use Map Algebra techniques, but which are discussed more fully in other units are:
1) recoding of data values. For example, if Missing Data is coded with
a pixel value (raster system) or an attribute value (vector system) of
-99999 and, for the purpose of an analysis, attributes for Missing Data
should be recoded to zero (or some other value), then every attribute value
of -99999 in the raster or attribute table can be replaced by zero (or
the appropriate value). (Unit 40 - Using Reclassification Operators). This
process is related to Map Algebra because attribute values in the output
image are determined by applying a transformation to each input image value.
In this case the transformation is to replace the input feature attribute
value with another in the output layer whenever the input value satisfies
a particular mathematical condition. In this case, when the input feature
attribute value equals -99999, it is replaced by zero.
In this raster data layer, areas for which data is missing, i.e., the elevation is unknown, have an attribute value of -99999.
In this raster data layer, everywhere the attribute value was -99999 in the previous image, the attribute value is now zero.
2) scaling of data values for output or display. For example, if one has a digital elevation data layer, rather than to designate a different color to each discrete elevation value, a data set might be easier to visually interpret if the range of elevation values is divided into equal portions and each portion assigned a different numeric value (or color for display). If elevations range from 100m to 300m, then all features or pixels in the elevation range from 100m to 140m could be designated with a new attribute value of 1 (which we will designate as dark blue for display), 140m to 180m as new attribute value of 2 (medium dark blue), 180m to 220m as value 3 (medium blue), and so forth. Sometimes this scaling process is performed by creating a new data layer containing the new values (raster system) or a new attribute field in the database (vector system). Alternatively, such value scaling can sometimes be performed in computer memory only for display or printing without altering or creating new attribute data. (Unit 48 - Designing Products for Printing).
The scaling of data values, or reclassification, as described here is a form of map algebra because a transformation of each feature's attribute value is based on the attribute value. In the example described above, if a feature in the input data layer has an elevation attribute value of 184 meters, then that feature will be reassigned a new attribute value of 3 in the output data layer.
In this digital elevation model, the raster cells have attribute values which range from 12 (meters above sea level) to 972 (meters).
In this raster data layer, the elevation attribute values in the digital elevation model above have been reclassified into 10 elevation categories. All cells in the digital elevation model which had an attribute value of 12 (meters, the minimum value present) to 100 (meters) now have an attribute value of one. All cells with a value of 101 to 200 in the digital elevation model now have a value of two, and so forth.
3) masking out areas in a data set which should be excluded from analysis. In a GIS, if a first data layer is multiplied by a second data layer which contains only zeroes and ones, the result is a data layer in which attributes are unchanged in areas where the second layer attribute is one, and zero in areas where the second layer attribute is zero. This is a way to "mask" data, thereby limiting analysis to areas of interest. (Unit 41 - Using Boolean Search Techniques). Masking can be used to isolate areas based on attribute characteristics (e.g., we mask out all features except those with an attribute value of 17, 18, or 25) or based on spatial characteristics (e.g., we mask out all features outside a country boundary polygon to restrict our analysis to that country's features).
One use of masking is to isolate a feature of interest by changing pixels belonging to all other features to zero. In this example we are interested in the district which is colored dark blue near the center of the image.
We have reclassified the pixels in the feature of interest, in this case a municipal district, to have a value of one; all other pixels have been reclassified to have a value of zero. This is a mask image.
We can overlay-multiply our mask image by our original image to produce an image in which pixels in our feature of interest retain their original attribute values and all other pixels are changed to background (zero). Note that this image is displayed using a different palette; background values of zero are displayed using a gray color instead of black.
We can use the mask we just created to mask out the district of interest from a digital elevation model of the same area (assuming the image parameters are the same, e.g., number of rows/columns, projection, resolution, etc.) Here is a digital elevation model of the study area. For reference, a vector file showing the boundaries of the districts has been superimposed:
By multiplying our digital elevation model by the mask image, we create an image in which only the topography in the district of concern is shown.
Masking of features can be applied, as we just saw, to isolate a single feature of interest. This technique can also be applied to isolate sets of features. This raster data layer contains eleven land use/land cover classes.
Suppose that for our analysis we only wish to be working with those pixels which represent forest areas. We can change all non-forest pixels to a background value of zero in two steps.
Step 1: Reclassify all pixels of Forested Wetland, Deciduous Forest, and Coniferous Forest to a new attribute value of one. At the same time, reclassify all other pixels to a new attribute value of zero. This procedure produces this image which contains only ones and zeroes:
Step 2: Perform an overlay-multiply operation between the mask image created in Step 1 and the original land use/land cover data layer. For each pixel representing a forested area, the value of one in the mask image will be multiplied to leave the land use/land cover attribute unchanged. Wherever a non-forest pixel is present, it will be multiplied by a zero-attribute-value pixel in the mask image to produce an attribute value of zero in the corresponding cell in the raster layer created by this overlay step. As you can see, this produces a raster data layer in which the three forest classifications remain unchanged and all other land use categories have been converted to background (zero).