Lab 4 Exercise 1: Converting Feet To Meters Using Raster Calculator
Lab 4 Exercise 1: Converting Feet To Meters Using Raster Calculator
Select OK. A new layer named rastercalc is added to the Table of Contents. Each cell value in
rastercalc contains the value of the corresponding cell in the elevation grid, multiplied by 0.3048.
Because the multiplier contained decimal points, the new grid is a floating-point grid. The name
rastercalc followed by a number is assigned to your output if you do not choose a name. The grid
may or may not be temporary depending on the Geoprocessing Options. To see if a layer is
temporary or permanent, open the Layer Properties for the layer and click the Source tab. Notice
the output grid was written to your scratch directory with a generic name (e.g., rastercalc), it is
floating point. You'll convert these values to integer in the next step.
1
Raster Calculator outputs permanently in your Scratch Workspace, click on the Geoprocessing
menu and select Geoprocessing Options. At the bottom, uncheck the box next to “Results are
temporary by default.” Your outputs will now be permanent by default. Open the Raster
Calculator and enter the following expression: Int("elevation" *0.3048)
For the Output Raster change the name to NewElev. Click OK. A new permanent layer Named
NewElev appears in your working directory. You can keep this map open for the next exercise.
Key points
• You can build expressions in the Raster Calculator by typing directly into the expression
box, selecting layers in the Layers list, and selecting buttons on the keypad. When you
select an element it is added to the expression in the expression box.
• Map Algebra operators are case sensitive. Be sure to type them correctly or select them
from the menu to the right in Raster Calculator to prevent errors.
• Output rasters are either permanent or temporary by default and will be stored in your
scratch workspace unless another location is specified in Raster Calculator. To select
whether rasters are temporary or permanent, open the Geoprocessing options and check
or uncheck the box next to “Results are temporary by default.”
• Output grids are either integer or floating point, depending on the expression.
For the Output Raster change the name to GoodOwn. Click OK. The Equal To operator has
returned values of 1 for Forest Service lands and values of 0 for all other ownerships. Turn off
the Ownership and GoodOwn layers. Next you will make a layer for suitable elevations. You'll
use the relational greater-than operator (>) to test the Elevation layer for values that are greater
than 2,400 meters above sea level. Open the Raster Calculator and enter the following Map
Algebra expression: "NewElev" > 2400
For the Output Raster change the name to GoodElev. Click OK. The Greater Than operator
returns values of 1 for all cells whose elevation is greater than 2,400 meters, and 0 for all other
elevations.
2
Step 2: Use Boolean operators
While your tree farm model has identified areas of proper land ownership and areas of adequate
elevation, the results remain in separate layers. You need to put them together to find only those
areas that are both the right ownership and elevation. Open the Raster Calculator and enter the
following Map Algebra expression: "GoodOwn" & "GoodElev"
For the Output Raster change the name to GoodFarm. Click OK. The new GoodFarm layer has
values of 1 (true) for cells that have both good ownership and elevations. Note: The whole model
could have been done with this one Map Algebra expression: ("ownership" == 200) &
("NewElev" > 2400)
Models of this type could consider dozens of variables (raster layers).
For the Output Raster change the name to FarmSoil. Click OK. The effect of the
CombinatorialAnd operator is not immediately obvious; you must examine the attribute table of
the FarmSoil layer to understand the result. Right-click FarmSoil and click Open Attribute Table.
These are the different soils that are found in the GoodFarm sites.
For the Output Raster change the name to NewLand. Click OK. The Over operator has replaced
the landcover cells with the non-zero cells from GoodFarm. In reality, you would want to
reclassify the GoodFarm layer before doing the update, replacing the cell values of "1" with an
actual land cover code.
The Diff operator finds the differences between two rasters. For cells where both inputs are
different, it returns the value from the first input. Where they are the same, it returns zero. Diff is
especially useful for performing time-series studies, like finding those places where land use has
changed between 1980 and 1990. You will now use it to find where your NewLand and
3
landcover layers are different. Open the Raster Calculator and enter the following Map Algebra
expression: Diff("landcover", "NewLand")
For the Output Raster change the name to LandDiff. Click OK. The Diff operator has returned
the landcover values where they differ from the NewLand values. All other cells are set to zero.
Not only can you see where the layers are different, you see how they are different.
The InList operator is useful for "selecting" cells based on their values and writing them to a new
raster. This operator specifies to compare the input values to those in the provided list and, if
there is a match, return the value to the output cell, or otherwise return NoData. For the purposes
of this step, assume that soil codes of 201 ("Loam, Cobbly") and 204 ("Loamy Sand, Coarse And
Stony") are best for growing fir and pine trees. You will now use the InList operator to create a
new raster layer for just those cells. Open the Raster Calculator and enter the following Map
Algebra expression: InList("soil",[201, 204])
For the Output Raster change the name to GoodSoil. Click OK. The InList operator has returned
the cells whose values were in the list (201 and 204). All other cells were set to NoData. The
InList operator provides a quick way to create a processing mask. You can also use the Con,
SetNull, and Pick functions.
Key points
• Relational operators compare two numbers and return a 1 if the comparison is true and 0
if it is false.
• Boolean operators take logical (true or false) inputs and create a logical output of 1 for
true or 0 for false.
• Combinatorial operators assign new output values corresponding to various combinations
of input values.
• Logical operators take two inputs and assign values based on a logical comparison of the
two.
4
input rasters. All of the pixels that did change, converted to a land use value of 1. We can
consider this the tree farm area. You can easily derive the number of pixels from the area by
dividing the raster resolution (default cell size) by the tabulated area.
Po is the proportion of cells (area) not changed (sum all of the diagonal values divided by the
total number of cells). Pe is the expected change due to chance. For each land cover category
multiple the total row by the total column and divide by the square of the overall total. Sum these
for each category and you get Pe.
Key points
• Spatial analyst has a tool cross-tabulate between two rasters.
• You can pull the table out of ArcMap to make further calculations on the tabulated data.
• Kappa is a statistic that tells you how different two rasters are.
For the Output Raster change the name to Aspect. Click OK. You created an aspect grid, just as
if you had chosen Aspect from the Surface Analysis menu. The only difference is that the menu
choice gives you a predefined legend.
Now you'll try the Slope function, which has a couple more arguments. The Syntax for the
SLOPE function is: Slope(<grid>, {DEGREE | PERCENTRISE}, {z_factor}) Open the Raster
Calculator and build the following expression:
Slope("NewElev", "PERCENT_RISE", 1)
For the Output Raster change the name to Slope. Click OK.
Now you'll try the Hillshade function. The Syntax for the HILLSHADE function is:
HILLSHADE(<grid>, {azimuth}, {altitude}, {NO_SHADOWS | SHADOWS}, {z_factor})
5
Open the Raster Calculator and enter the following expression: Hillshade("NewElev")
For the Output Raster change the name to Hillshade. Click OK. Notice the symbology may not
be appropriate for a hillshade. Double-click Hillshade to open the Layer Properties dialog. Click
the Symbology tab, and from the Show list choose Stretched. The color ramp should default to
Black to White. Click OK.
Now you're ready to calculate the hillshade for these six months, starting with November. Open
the Raster Calculator and enter the following Map Algebra expression:
Hillshade("NewElev",186.6,37.2)
For the Output Raster change the name to November. Click OK. The November hillshade looks
inverted because the sun was positioned in the south, casting shadows at the top of the
mountains.
6
based on the six input months. Turn off all layers except Elevation and close their legends.
Open the Raster Calculator and enter the following Map Algebra expression:
CellStatistics(["November", "December", "January", "February", "March", "April"],
"MEAN")
For the Output Raster change the name to SunExposure. Click OK. The new SunExposure layer
now shows the average sun exposure over a six-month period. In your ski resort model, you
would give more weight to slopes with lower sun exposure than those with high sun exposure.
Key points
• Most of the functions available from ArcToolbox are also available as Map Algebra
functions.
These expressions may be simple, like a single value or raster, or complex expressions made up
of multiple nested functions—including other Con functions. If the optional false expression is
left blank and the condition evaluates to false, then Con returns NoData. Open the Raster
7
Calculator and build the following Map Algebra expression: Con("dambasin" & ("damelev"
<= 790), 790)
For the Output Raster change the name to Reservoir. Click OK. This Con statement translates as
"IF the cell is inside the basin AND its elevation is less than or equal to 790 meters, THEN
return a value of 790; ELSE return NoData". For the part about "inside the basin", recall that
Map Algebra considers any non-zero, non-NoData value to be a logical true. By omitting the last
Con argument (the False case), you are setting cells that don’t pass the test to NoData. Change
the color of the Reservoir symbol to a shade of blue. Turn off the dambasin layer. Examine the
Reservoir layer and note the extent of the reservoir.
Click the Identify tool and click within the map. Move the Identify Results dialog so you can see
the map. In the Identify Results dialog, click the Layers dropdown arrow and choose damelev.
Now click several times within the Reservoir, examining the returned values. The values should
all be less than 790 meters.
For the Output Raster change the name to NewDamElev. Click OK. This Con statement
translates as "If a cell within Reservoir contains NoData, return the original elevation layer, or
else return the value 790." If you want to see the new lake better, create a hillshade of the
NewDamElev layer.
Key points
• You can use the Con function to control the flow of operations based on the evaluation of
one or more conditions.
• You can use the IsNull function to test for the presence of NoData. Con and IsNull are
often used together to replace NoData values with another value.
• You can calculate descriptive statistics within the attributes table.
8
the {false_expression} argument in the Con function. There are many others, like the SetNull
function. In this exercise, you'll use SetNull to create a mask where non-Forest Service land and
water bodies are set to NoData, and then use the mask to clip the soil layer.
For the Output Raster change the name to Mask. Click OK. The expression set non-forest service
land and water to NoData.
Key points
• The SetNull function assigns the value NoData to cells that meet a certain condition,
otherwise it returns a user specified value.
• The SetNull functions can be used to create a mask.
Assignment Questions
1. Show the cross tabulation table from Exercise 3. Please label rows and columns with land
cover categories.
2. What is the value of Kappa you calculated from Exercise 3? Does Kappa change if you
use number of pixels instead of area?
3. Using data from Exercise 4, how many pixels in the study area are at elevations higher
than 1500 meters and less than an average sun exposure of 135 between the months of
November and April?
4. What is the mean and standard deviation in meters of the elevation within the reservoir in
Exercise 5? How many cubic meters of water will the reservoir hold (this question is
designed for you to figure out without step by step instructions)?
5. What is the area of rock outcrop in square meters within the Forest Service lands in
Exercise 6?