## Map Algebra

Map algebra manipulates geographic raster data sets to produce new map layers.  They can work on a single layer (grid), or combine multiple layers.  Tomlinson is credited with the concept.  In many ways map algebra works like matrix manipulations in Matlab.

The map algebra transformations can use different spatial neighborhoods:

• Local operations works on individual raster cells. An example would be converting elevations from meters to feet, or taking the log of the elevations to spread out the use of color.
• Focal operations work on cells and their neighbors. Examples include  Slope,  Reflectance (or hillshade), and Filtering.  For this type of operation, missing values for any of the points in the neighborhood can lead to a missing value in the output layer.
• Global operations work on the entire layer.
• Zonal operations work on areas of cells that share the same value.   This can for example be used to reclassify all cells with one value, or a range of values, to another value.

Single layer operations can add a constant, take a log or sin, filter the raster, or compute the slope.  This can operate on the grid in question in memory, provided you take care not to the overwrite the original layer unless you want to do that.

Multiple layer operations can include addition/subtraction, multiplication/division, ratios, or statistics like mean or standard deviation. This often requires creating a new grid, because if you replace values in the original grid, that will affect the computation of its neighbors not yet done. Focal operations must create a new grid, since the values depend on the neighborhood which cannot be overwritten.

Some operations may require several steps in succession.  For example, with a noisy DEM, it might be best to Filter before computing Curvature because as a second derivative, curvature can be very sensitive to minor noise in the input DEM.

You can often combine many operations into one step, but often the intermediate grids will be helpful to help you see the effects of each layer.  If you have five criteria and their result is no acceptable locations, it helps to look at each layer so you can decide which one to change, or to know why there are no acceptable locations.  The ability of the analyst to see the spatial patterns can provide insights the software cannot.

Examples:

• Sand dune migration.
• You have grids with the locations of sand dunes at three time periods (T1, T2, and T3).
• Reclassify them to 1, 2, and 4 respectively for dune locations, and 0 for non dune.  Note that if you think in terms of computer bits, you are setting three bits, one for each of the time periods.
• Sum the three reclassified grids.
• You will have potential values of  0, 1, 2, 3, 4, 5, 6, and 7.  From the value you can determine when a dune occurred at each point in the grid: a 0 was never a dune, a 3 was a dune during T1 and T2, and a 7 was a dune at all three time periods.
• Find  a location for a helicopter landing zone, with three input grids.
• DEM derived slope grid.  You want the slope in the landing zone to be less than 5%.
• NLCD.  You want the categories 31 or 72.
• Tiger roads.  You want to be within 100 m of a road.
• Some approaches:
• Reclassify slope grid, to make > 5% 0, and less < 5% 1.
• Reclassify NLCD to 1 for classes 31 or 72, and 0 for the remainder.
• Make a buffer for the roads, insure it is a grid, and reclassify so that points close to the road are 1 and those too far away are 0.
• Operate on the three grids, with several possibilities
• Multiply the three grids.  If any layer is a 0, unacceptable, it will make the result 0. If the value is 0, it is unacceptable; if it is 1, it meets all three criteria.
•  Sum the three grids.  The value will be the number of criteria met.  You want the 3, but if there are not enough points, you could consider those with a score of 2, or you could go back and adjust the criteria--maybe another NLCD category is acceptable, or you can land on a steeper slope.
• Use  boolean operators like (Slope < 5),  (NLCD=31) or (NLCD=72), which will create grids with 0 (false, failed the condition) or 1 (true, met the condition) which you could name Good_slope and Good_NLCD, and then combine to a new grid with Good_slope and Good_NLCD and Good_roads.
• Make all the unacceptable points missing data.  Then you could start with a clean grid, and successively mask out all the missing data in the other grids.  Whatever was left would be acceptable.

In MICRODEM, map algebra operations are available:

Last revision 11/23/2017