Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

07 Ras5.Functions

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Ras.5.

Functions
In this exercise, we’ll explore a range of map algebra functions, organized by their spatial scope
of operations, from local to global. With few exceptions, these functions can also be accessed as
tools in ArcToolbox.

If you’re starting ArcMap up again, remember to set the Working Directory to the correct path.
In this section, we'll explore the various classes of spatial analyst/raster functions:
1. local functions (apply on a cell-by-cell basis)
2. focal functions (cell influenced by neighboring cells)
3. block functions (focal-like functions that generalizes to blocks)
4. zonal functions (works with each unique value as a zone)
5. global functions (values of cells a function of all cells)

Local Functions
Local functions process on a cell-by-cell basis. For example the output cell in row 15 column 12
is determined from the values of input rasters at row 15 column 12, and so forth (assuming the
rasters exactly overlay, so actually it would be better to say the processing is based only on the
location of the output raster cells). We've actually already been looking at local functions when
we were exploring the Con, SetNull, IsNull and many other functions that simply apply a
function to each cell -- including arithmetic functions (abs, int, float, etc.), logarithms,
trigonometric functions, and others.

Reclassify
Reclassify is by far the most important local function, and one of the most important of all
functions. As the name implies, this function reclassifies values into other values, and these new
values are written out to the output raster. Reclassify can be accessed via the Spatial
Analyst/Reclassify… menu choice, which brings up the Reclassify window.

™ First you should understand something about USGS Anderson Land Use Codes. They
are hierarchical, with multiple levels coded by a digit. At the first level, the categories
are 1 urban or built-up, 2 agricultural, 3 rangeland, 4 forest, 5 water,
6 wetland, 7 barren land, 8 tundra, 9 perennial snow or ice. At the second level each
category is subdivided, such as urban subcategories 11 residential, 12 commercial &
services, 13 industrial, 14 transportation, communication, utilities, 15 industrial &
commercial complexes, 16 mixed urban or built-up, 17 other urban or built-up.

7-1
¾ Create a level 1 landuse raster by reclassifying landuse codes into level 1 classifications
based on the first digit . With your landuse raster selected, use the Spatial Analyst menu to go
to Reclassify.. Select a range of old values by selecting one then using the shift key to select
the last. There is no 18 or 19, so select 11 through 17. Then right-click the blue area and use
Group Entries (as shown in the figure) to group them, and assign 1 as the new value. Then
do the same with 21 through 24, assigning 2 as the new value. Before continuing, change the
Output raster to lu1 so you’ll have a permanent raster.

 Put your level 1 landuse raster map, with explanatory text, into your report for this exercise.
Call it ras5.doc, and eventually you’ll create ras5.pdf and save it in your Reports folder.

7-2
Focal Functions
The focal functions derive values using the neighborhood of the cells -- you specify how far out
to look, and there are many shapes you can use, including a simple 3x3 square area, a rectangle,
a circle, an annulus, a wedge, and a user-defined neighborhood.
Most of the focal functions derive a summary statistic for the neighborhood:
FOCALFLOW() FOCALMAJORITY() FOCALMAX() FOCALMEAN()
FOCALMEDIAN() FOCALMIN() FOCALRANGE() FOCALSTD()
FOCALSUM() FOCALVARIETY()

In fact all but focalflow return a summary statistic to the cell.


The usage for each of these statistical functions is similar for all the statistics, for instance for
focalmean:

Focalmean(<raster>, {DATA | NODATA})


Focalmean(<raster>, <RECTANGLE>, <width>, <height>, …)
Focalmean(<raster>, <CIRCLE>, <radius>, …)
Focalmean(<raster>, <ANNULUS>, <inner_radius>, <outer_radius>, …)
Focalmean(<raster>, <WEDGE>, <radius>, <start_angle>, <end_angle>, …)
Focalmean(<raster>, <IRREGULAR>, <kernel_file>, …})
FocalMean(<raster>, <WEIGHT>, <kernel_file>, …)

Choice of neighborhood: The first choice uses the default 3x3 neighborhood. Rectangle,
circle, annulus and wedge define a geometric neighborhood of specified dimensions (width &
height for rectangle, radius for circle, etc.).
Data/Nodata: The three dots represent the {DATA
| NODATA} choice. This option specifies what to
do if a nodata cell exists in the neighborhood being
evaluated. The default is DATA, which means to
ignore any nodata cells and derive the statistic for
the remainder. If NODATA is specified, any
nodata cells in the neighborhood will assign nodata
to the output cell.
These functions can be used as part of a raster
statement, or interactively via the Neighborhood
Statistics menu.
¾ Make sure that the elev is in the data frame, and
start by creating a slope raster via Surface
Analysis in the Spatial Analyst menu.
¾ Use Neighborhood Statistics with this slope
raster to create a mean slope raster using a 3x3
rectangular neighborhood.

7-3
The result should be a generalized slope map – each cell is a moving-window average of slope
values.
¾ Compare the result with the slope raster, first visually by displaying their raster layers in the
view, then by using the histogram tool.

? What happens to the maximum slope?

Focal Variety is an interesting way to see how many different classes surround a given cell.
¾ Use this same method to determine the
number of different geologic types
within 10 cells (600 m) of each cell.
The settings should be statistic =
variety, neighborhood = circle, radius
= 10 cells. (You’ll need to add the
geology raster first. You may also
have to redisplay the result as
classified instead of unique values.)
? What does this show you?

? If we used a vegetation raster and used it instead, what would it show you?

¾ Use the Majority choice to generalize the geology raster, and show the dominant rock type
within the same radius, with the same circle neighborhood you used above.
¾ To help you know what the rock types are, add the geology attribute table and join it to the
attribute table of the layer you just created, using "value" as the join field. Then use the
legend editor to change the values field to "material".

? What does this show you?

7-4
Now let's do this with the Raster Calculator. Remember that we would want to use this method
in a longer process that we might record as a script.

gdiv = focalmajority(geology, circle, 10)

? Is there any difference?


Before you answer this question, think about the difference between ArcMap’s rendering or
symbology of a dataset, and the actual underlying data source. What raster calculator expression
could you use to actually determine the difference (hint hint) between the two results:

_____________________________________________________________________

Investigate the results. The answer should be simplified, except for one minor complication.
Consider what cell values are displayed as transparent by default (____________), and how
other layers underneath may show through. After you’ve done this, answer the question.

? Is there any difference, and how do you know?

 Put your favorite focal result map, with explanatory text, into your report for this exercise.

7-5
Block Functions
The block functions are similar to the focal functions, except that you end up with neighborhoods
considered as a whole, ending up with the same value. This is definitely a generalizing class of
functions. The GRID names differ only by replacing FOCAL with BLOCK; the Spatial Analyst
names are similar: BlockStats replaces FocalStats -- there is no BlockFlow -- and all
enumerations are the same.
One difference in usage – there is no support for block functions in the menu system similar to
the Neighbor Statistics method for focal functions.
¾ Use BlockVariety to create rectangular areas depicting the diversity of rock types in those
areas. Use 10x10 cell (600 x 600 m) neighborhoods, with the following expression:

gdiv2 = blockvariety(geology, rectangle, 10, 10)


¾ Now use the Majority method to find the predominant rock type in these 600 x 600 m areas.
600m is the same as 10 cells for this raster.
geolmaj2 = blockmajority(geology, rectangle, 10, 10)
Join the attribute table for geology to the attribute table for the new Raster Calculation raster,
using the Value field in each for the join. Then change the legend for the Raster Calculation
raster to show "Material" descriptions rather than numbers.
? What two types of rock (not water) are the most dominant?

? What happens if there's a tie?

 Put your favorite block result, with explanatory text, into your report for this exercise.

7-6
Zonal Functions
There are quite a few zonal functions in GRID:
ZONALAREA() ZONALCENTROID() ZONALFILL() ZONALGEOMETRY()
ZONALMAJORITY() ZONALMAX() ZONALMEAN() ZONALMEDIAN()
ZONALMIN() ZONALPERIMETER() ZONALRANGE() ZONALSTATS()
ZONALSTD() ZONALSUM() ZONALTHICKNESS() ZONALVARIETY()

As with the focal functions, these are reduced to a smaller number of functions in Spatial
Analyst., as you can see using the help system using "Zonal" entries in the index.

¾ Create an output raster LUELEV that stores for each landuse zone in landuse, the mean
elevation that occurs in that zone:
luelev = zonalmean(landuse, elev)

Two of the functions, ZONALSTATS and ZONALGEOMETRY, return INFO data files.
¾ Create an output INFO file that records the count, mean, minimum and maximum values of
elevation for each landuse zone:
lustats.dat = zonalstats(landuse, elev)

¾ In the table created, add a field RANGE, and calculate it to equal max – min.
? What land use code has the greatest range of elevation values?

ZonalGeometry is very interesting, in that it can detect geometric shapes or sizes of contiguous
cells (zones).
¾ Use it to find the areas of each of the public lands areas
1. Add the newpub raster you created earlier -- it should be in the hmbarea directory. It will
work better than pub because it has non-public lands as nodata.
2. Use Raster Calculator with the following expression
Pubarea.dat = Zonalgeometry([newpub], area)

 Put your pubarea.dat table, with explanatory text, into your report for this exercise.

7-7
Global Functions
Global functions work with the entire raster, and come in three categories:
Euclidean distance functions (each of the following is in terms of Euclidean distance)
Eucallocation identity of the closest source cell
Eucdistance distance to the closest source cell
Weighted distance function (each of the following is in terms of cost distance)
Costdistance accumulated cost to the closest source cell
Costpath records the least cost path to the closest source cell
Other
Regiongroup records the identity of the contiguous cells of equal value
Slice classifies the input raster by dividing the range

(Non-distance) global functions


Slice
¾ Use the help system index to see what parameters Slice needs, and what kinds of
enumerations it supports.
¾ Use Slice to create five elevation equal-interval classes as zones:
Slice(Elev, eqinterval, 5)

¾ Then try it with eqarea as the class type.

What’s the difference (for instance, look at the difference in class 1)?

RegionGroup
¾ Use the help system to investigate RegionGroup.
¾ Use RegionGroup to create spatially contiguous zones of the water bodies:

RegionGroup(Watergrd, #, EIGHT, WITHIN)

? How might you use the above result?

End of Exercise 5 (7). As before, create a report from the results of the exercise.

7-8

You might also like