
Introduction to
Geographic Information Systems in Forest Resources |
Exercise: Raster Analysis
I
- Clean out your removable disk
- Open an existing project
- Add a grid theme to a view
- Convert between floating-point grid and integer grid
theme types
- Alter the display of a grid theme
- Query a grid theme
- Create a histogram
- Reclassify a grid theme
- Perform a map query on a grid theme
- Perform a map calculation on a grid theme
- Set analysis properties
Masking
Cell size and analysis extent
- Examine projection properties
- Copy a grid theme to another location in the file
system
Clean out your removable disk
Because grid data sets take up a lot of space, you should delete any unnecessary
files from your removable disk. Delete everything from your removable disk before starting
the exercise. If you have been creating PDF files for your assignments and saving
them on your removable disk, these (as well as any old *.prn files) can be deleted.
Open an existing project
Download the project r_an1.apr, and save it
on your removable disk.
When the project opens, it should contain the Pack Forest Stands theme,
as well as the Pack Forest Streams theme.
Before doing anything else, set your working directory to the
removable disk.
Add a grid theme to a view
- Add the theme dem from the packgis\forest directory on the
CD.

You will need to add this as a grid theme, but you will notice that the only
data source types are Feature Data Source and Image Data Source.
If you choose Image Data Source, you will notice that the dem
theme is listed. However, you do not want to load this theme as an
image. Why? If the dem theme is loaded as an image, we will be able
to view it and alter its display properties, but we will not be able to perform
any raster analysis.
- Cancel the Add Theme dialog.
- Enable the Spatial Analyst Extension.
- Click the Add Theme button.
- Select Grid Data Source from the Data Source Types dropdown
list.
Now you will see the dem theme listed.

- Add the dem grid theme to the view.
- Make sure that Dem is the first theme to draw, or it will obscure
your other data.

The grid theme Dem will be displayed in 10 classes with a Color Ramp
of a random shade.
- Change the Dem theme's legend so that the No Data class appears
with no color. You will notice how much faster the view draws, because a large
number of cells do not need to be displayed.
You have just loaded a grid theme to a view. Make sure that you have the Spatial
Analyst extension loaded before you try to add grid themes, or you may
end up loading the image theme, which will be useless for analysis.
Alter the display of a grid theme
When grid themes are loaded, they are loaded in 10 classes (9 data classes,
and 1 No Data class) with a random color ramp scheme. The No Data class often
appears as a solid black fill. You may want to alter the color ramps for the
display of different types of data.
- Open the Legend Editor for the Dem theme.
- Change the number of classes to 30.
- Alter the color fill symbol of three different values. Note you do not need
to specifically alter class 15, just somewhere near class 15 for display purposes.
| Class Value |
Color |
| class 1 (471.223 - 523.676) |
green |
| ~class 15 (1205.567 - 1258.021) |
yellow |
| class 30 (1992.365 - 2044.818) |
red |
| No Data |
blank ("X") |
You may need to click the white symbol before clicking the "X" symbol
if the symbol does not update.
- Click the Color Ramp button
and then Apply
the change. This will smooth the transition between the three index colors,
and cause the No Data cells to appear transparent. Setting the No Data cells
to transparent will also speed up drawing.
- Turn off the Stands theme.

Now you are viewing your elevation data with a more continuous-color legend,
which allows you to see the variation in elevation easily.
- To make the table of contents more readable (so that you can see other theme
legends), select Theme > Hide/Show Legend from the menu. You should
take advantage of this, especially when you have many grid themes with large
numbers of classes, otherwise you will waste a lot of time scrolling up and
down through your table of contents.
- Alter the Classification of the legend to display Standard Deviation
classes by 1/2 steps. Note that the only types of classification available
for this floating-point grid are Equal Interval and Standard Deviation. Standard
Deviation classification will show cells of mean value in white, with cells
of values above or below the mean in other colors.

- Select the Green to Red Dichromatic Color Ramp, then alter the legend
text labels as below.

- Click the Null Values button
, and uncheck the
Include No Data Class in Legend checkbox, OK the Null Values
dialog, and apply the change to the Legend Editor. Dismiss the Legend Editor.

- Make sure the dem grid is the active theme, and from the Theme
menu, select Hide/Show Legend to turn the legend back on.
Now the grid is displayed with 1/2 step standard deviation classes around
the mean elevation. There may actually not exist cells of the exact mean value,
but the mean elevation contour will follow the border between the lightest
red and lightest green zones.
The legend gives you an idea of the statistical spread of your data, and the
view shows you where the different classes are.
There are generally fewer options for altering display of grid themes than
for feature themes. Integer grids have the same classification methods as vector
data, but floating-point grids do not have as many different types of classifications.
Grids cannot be displayed with hatched symbols, only with solid filled colors.
Convert between floating-point grid and integer grid theme types
Regular tabular queries can only be performed on integer grids with fewer than
1 million classes. Conversion from floating-point to integer value is necessary
to create a grid theme with a VAT.
- Attempt to open the theme table for the dem theme. You will find
that this is not possible. As a floating-point grid, the theme has no VAT.
- Select Analysis > Map Calculator from the menu.
- Double-click on Dem in the Layers field, which places it in
the expression.
- Select the Arithmetic choice in the pulldown.
- Click the Int button, which specifies that the Dem grid should
be converted to an integer grid, called Map Calculation 1.
- Make sure that your calculation is formatted
( [Dem].Int )
as shown below.
- Click the Evaluate button.

The expression means "take the Dem grid, create a new grid called Map
Calculation 1 based on the Dem grid, but convert the floating-point
values to integer values."
After a minute or two (depending on the computer's speed and RAM), the calculation
will complete and a new theme, Map Calculation 1, will be added to
the view. This is a temporary grid theme. Close the Map Calculator.
- Make the Map Calculation 1 theme active, and select Theme >
Save Data Set, and save the grid as dem_int in your working directory.
This converts the temporary grid theme to a permanent grid.
- From the Edit menu, select and accept the Delete Themes choice.
This deletes the temporary grid theme from the view, as well as deleting the
temporary grid data source from the hard drive.
- Add the dem_int grid theme from the working directory. Now you have
a grid that is named correctly (the grid theme is shown by true name rather
than by the ambiguous name Map Calculation X.

- Notice that the values listed are integer rather than floating-point. Now
you should be able to open the theme table for this new integer theme.
You have just converted from floating-point to integer value. Be aware that
this conversion may incur a loss of information. Be very careful when converting
floating-point to integer value, especially if your original values are between
0 and 1. You will lose most of your information content. If your data represent
values for which decimal places contain important information and you convert
to integer values, you will lose that important information.
A common technique to handle this problem is to first multiply the floating
point grid by a 1 or more orders of magnitude, which brings all values above
1, and then convert to integer value. However, you will need to remember that
the values you now have are not the original values.
Query a grid theme
- With the new Dem_int theme active, make a query using the Query
Builder
to select cells in
the range from 1000 to 1500.

This query is possible only because the grid theme Dem_int has a theme
table. Queries on grid themes that do not have VATs must be done using the Map
Query function in the Analysis menu. Map queries are not the same
as standard queries.
Create a histogram
Histograms graphically display the spread of cell value data within the selected
cells of a grid theme.
- Change the number of classes displayed in the Dem_int theme to 30,
keeping the Green Monochromatic Color Ramp.
- Click the Histogram button
.
After a minute or two, the histogram for all cells in the theme will be displayed.
The number of columns in the histogram is the same as the number of classes
in the grid theme's legend.

Note that the histogram displays all classes, not just those selected. This
is different from most charts in ArcView 3.x, where the chart shows data markers
only for selected records. Also note that the entire histogram legend is not
displayed, due to the size if the window. If you resize the window, you will
see the entire legend.
The histogram shows elevation classes on the X axis and the number of cells
within those classes on the Y axis.
- Using the Identify tool
, click the data markers
for the two largest classes in the histogram. You will see the values for
these classes in the Identify Results dialog.


The Class-label shows the range of values in that class (which is the
same thing shown on the legend for the X axis) and the count of cells in that
class (which is the same thing shown on the Y axis).
Where are these classes on the map? To find out, it will be necessary to reclassify
the grid, which we will do next.
Histograms are useful for browsing the range and distribution of data in a
grid. Do the values of a grid follow a normal distribution, or is there some
other type of pattern? What might that tell you about your data, and what implications
does it have for further analysis?
Reclassify a grid theme
- Dismiss the Identify Results dialog, and with the chart active, select
Chart > Properties from the menu. The chart has its source in a
table. That table's file name is displayed in the Chart Properties
dialog. Write down (or remember) the file name for the Table that is
the source for this chart. In this example, the table is temp1.dbf
in the current working directory.

- Add the table identified in step 1 to the project. The tabular data source
will be located in your current working directory.
- Turn off the Dem and Dem_int themes.
- Make the Pack Forest View document active. Make sure that the Dem_int
theme is active with the previously defined selected set.
- From the Analysis menu, select Reclassify....
- Classify the Value field in 30 Equal Interval classes.


The output data set will be placed in the view as Reclass of Dem_int.
This grid theme's Value field contains the corresponding values for
the Class field in the chart's source table from step 1.
- Shade the new theme with Graduated Colors in the Red Monochromatic
Color Ramp, using the Value field so you will be able to clearly see
the class breaks.
- Turn on the Reclass of Dem_int theme.
- Next, link the histogram table with the new theme table.
- Open the theme table for Reclass of Dem_int, and make the Value
field active.
- Make the table active that you identified in step
1 of this section, then make the Class field active, and select
Table > Link from the menu. You need to make the link so that
you can look at and select the elevation range in the linked table, but
see the cells selected in the grid theme. This is important because the
reclassified grid theme table no longer contains elevation values, only
arbitrary zone numbers. Making the link allows you to make a selection
based on elevation values rather than on the class number.
- Click on the largest peak in the Histogram chart with the Identify
tool
. Make a mental note of the class
number or the elevation range reported in the Identify Results window.
This tells us the class number of the zone, and the elevation range, but it
does not display where the zone is.
- Select the corresponding record in the table from step 1. You will see the
linked/selected records in the tables and a zone selected in the view.
You can investigate other patterns in the data if you like.
Reclassification of a grid theme assigns new output values to groups of input
cells. In this case, we created a new grid from the selected set of the Dem_int
grid theme. Reclassification is a technique that can make data more understandable,
but always includes a loss of original information (the original values are
lost). The other problem with reclassification is that the resultant grid theme
table does not have descriptive values, only class numbers.
Perform a map query on a grid theme
Many grid analytical operations are performed by using the Map Query
and Map Calculator tools. Grid analysis will be covered in greater depth
in the next lecture, but this section serves as an introduction to these tools.
Because the Dem theme is stored floating-point, a normal query is not
possible; instead, a Map Query must be performed to view a subset of
cells.
- Make the Pack Forest View active.
- From the Analysis menu, choose Map Query.
- Double-click on Dem in the Layers field.
- Click the Greater Than button
.
- Type in 500.
- Click the And button.
- Double-click on Dem in the Layers field.
- Click the Less Than button
.
- Key in 1000.
Your Map Query should look like this:

This means "create a new grid where cells that have value within 500
and 1000 are coded 1 and any other cell values are coded 0."
- Click Evaluate. The new theme will look like this:

The zone colored red represents all cells whose elevation is between 500 and
1000. Be aware that there are also cells with a value of 0, but these are
shown in a transparent color.
A map query is similar to a normal feature theme query, but can be performed
on either floating-point or integer grid themes. A map query is similar to a
feature theme query, but the output is always a new grid, rather than a selected
set within an existing table. The output is a Boolean entity, in which output
cells are coded True (1) (meeting the query criteria), False (0) (not
meeting the query criteria), or No Data.
Map queries, unlike feature queries, are not limited to single themes. Because
individual cell values are referenced to their spatial position only, map queries
can select cells that match a broad range of criteria, including multiple grid
themes. The query above could just as easily have asked to identify cells matching
multiple criteria for any of the grid themes within the view.
For example, it is possible to select a group of cells whose values are within
a range of bathymetry in an bathymetry grid and whose values are
within a range of slope in a slope grid, and whose values are within
a range of salinity values in a salinity grid with an expression like
([depth] < 20) and ([slope] > 5) and ([slope] < 10) and ([salinity]
< 0.015)
In a typical tabular query, the query is performed on a single table. In the
case presented above, it a query that simultaneously finds cells that match
the value of several grids (not just values in a single table). The cell locations
are determined by the spatial referencing framework, but the values are
determined by different values across multiple grids.
Perform a map calculation on a grid theme
This example will find the sine of the aspect for each cell in the Dem_int
grid. Generating sine and cosine of aspect would be the first step to take if
you needed to perform particular analyses modeling surface terrain. We won't
do anything further with this example, but you should be aware that trigonometric
and other mathematical functions exist for grid map calculations.
- Make Dem_int the active theme.
- From the Surface menu, select Derive Aspect. This creates
a new grid, Aspect of Dem_int. For those of you who don't know what
aspect is, it is the compass direction of the steepest downward descent from
a cell center. Imagine dropping a bowling ball and taking the compass bearing
of its downward path.
- Select Map Calculator from the Analysis menu in the View GUI.
- Put the [Aspect of Dem_int] grid in the Map Calculator.
- Use the trigonometry functions to build a calculation by selecting the Trigonometry
value in the dropdown.
- Type or build (or copy and paste from the web browser to the calculation
entry control in the Map Calculator) the following calculation:
(([Aspect of Dem_int] * 3.14159 / 180 ).Sin)
Note: Although building calculations and queries is made easier
with the GUI, you can alternatively simply type in the calculation without
using the GUI, assuming you know how to use the proper syntax. Be especially
careful of the location of parentheses.
This converts the aspect measurement of aspect, which is in degrees, to radians,
and then calculates the sine of the radian measure.

The output is stored in a new temporary grid called Map Calculation 1.
The values range from -1 to 1, which is what we should expect for values of
sine.

- Delete the grid theme Map Calculation 1, which will also delete the
grid from the disk (unless you have saved the project or the data set since
it was created).
The Map Calculator provides more functionality than the Map Query tool. The
Map Calculator is used to create new data sets based on logarithmic, arithmetic,
Boolean, exponential, relational, and trigonometric functions. Like Map Queries,
the functions can be performed on individual grids or combinations of grids.
In addition to the listed operators and functions, Avenue grid class requests
can be performed using the Map Calculation dialog. The output of Map Calculations
is a grid where each cell value is the result of mathematical or other grid
functions performed on the input(s).
Advanced use of the Map Calculator requires learning a little about Avenue
syntax.
Set analysis properties
Setting analysis properties (Analysis Extent, Cell Size, and Masking) will
affect the analysis environment until the analysis properties are changed again.
Once you set the analysis properties, they will not change unless you change
them later.
Masking
Masking sets the output grid to the valid cells of another grid.
- First, we need to create a grid for masking.
- Perform a "normal" tabular query on the grid theme Map
Query 1 (where Value = 1).
- From the Theme menu, select Convert to Grid. Accept the
default name of nwgrd1. This creates a new grid that contains valid
cells only for the area that is in the 500-1000 ft elevation range. Because
there was a selection on the grid, the new grid will contain only selected
cells from the source grid, much in the same way converting shapefiles
respects selected sets.
- When asked if you want to add the theme to the view, select Yes.
This grid should be called Nwgrd1.
- From the menu, choose Analysis > Properties.
- Change the Analysis Extent to Same as View. This sets
the output extent to be the same as the maximum extent of all themes in
the view.
- Change the Analysis Cell Size to Same as Dem. In this
case, the cell size is 10 ft.
- Change the Analysis Mask to Nwgrd1. For any output grids,
valid cells will be created only for those cells that have a valid value
in Nwgrd1.

- Perform another Map Calculation, where the expression is ([Reclass of
Dem_int]). Using this type of function creates a carbon copy of the original
grid, but if analysis properties are set, the resultant data set will conform
to those properties (cell size, extent, and masking).

Note that the new grid will be identical to the original Reclass grid, but
it contains cells only for those valid cells in the mask grid.
Analysis Extent and Cell Size
The Analysis Extent is a rectangular area. When the Analysis Extent is set,
newly created grids (from Map Calculations or Map Queries) will be limited to
the spatial extent of that rectangle. The extent can be set to the extent of
an existing theme, to the View, to the current display, or to specific coordinates.
- Zoom into an area in the middle of the forest.
- From the menu, choose Analysis > Properties.
- Set the properties as below by selecting
- Same as Display in the Analysis Extent pulldown and
- Same as Dem in the Analysis Cell Size.
A consistent cell size is imperative to certain analytical functions
if informational integrity is to be maintained among different grids.
- Change the Analysis Mask to No Mask Set.

- OK the change.
- To verify that the settings work correctly, perform a very simple Map
Calculation:

- Turn off all other themes, zoom out to full view, and turn on the most recently
created theme.

You can see that the new grid is limited to the spatial extent of the last
display coordinates.
- Check the properties of this new theme:
- Beware that your grids may not register properly. Zoom into the edge of
the new grid until you can see individual cells. Unless you were extremely
"lucky," your grids will not line up exactly:
Because grid calculations can take a long time, if you reduce the number of
cells that are calculated, carefully setting analysis properties can greatly
reduce the time necessary to perform grid analyses. However, if your grid registrations
are "off," this may cause errors later on, even if the cell sizes
are the same. ArcView 3.x cannot simultaneously alter the analysis extent and
"snap" to the coordinate framework of an existing grid theme.
Examine projection properties
Grid themes cannot be projected.
- Open a new view.
- Add the feature theme states.shp from the esridata\usa directory
on the CD.

- From the Theme menu, select Convert to Grid. Save the new
grid as state_grid in the working directory.
- Accept the default Conversion Extent, Cell Size, Row and Column parameters.

- Select State_name as the value field in the conversion.

- Join the attributes to the grid and add the new theme to the view.


- Turn on the new theme to verify that the conversion to grid occurred properly.

Each unique state name creates a new zone in the output grid.
- All of the source data so far are stored in geographic coordinates. Apply
a projection to the view (any one will do).
- Make the vector theme active active, and zoom to its extent.
- Turn off the grid theme and turn on the vector theme.
- Turn off the vector theme and turn on the grid theme.
- Make the grid theme active, and now zoom to its extent.
- Turn off the grid theme and turn on the vector theme.
- Turn off the vector theme and turn on the grid theme.
- Examine the coordinates as you move the pointer around the map display.
As you can see, ArcView 3.x is unable to project grid themes on the fly. If you
attempt to mix raster and vector themes in a view, and then apply a projection,
you may get unexpected results. On the other hand, because ArcView 3.x cannot project
raster themes, if you have projected raster themes and unprojected vector themes,
you can display them in the same view by setting the view's projection.
This is the only exception to the rule "never mix projected and unprojected
data in the same view."
Copy a grid theme to another location in the file system
Managing the file system and temporary grids is very important in raster analysis.
Because grid data sources are typically very large in size, it is important
that you know where the source files are, and that you are aware of how much
storage (disk) space is available.
The result of the last analysis, like most grids that are created from analyses,
is stored in the working directory. By default, these grids are given names
such as Calc1, Calc2, Query1, Query2, and so on.
They should be saved with a better name in a more permanent directory.
The data sources used in this example are for illustrative purposes only. Your
data sets and file systems will look different from these images.
- Switch back to the Pack Forest view.
- Make Map Calculation 1 the active theme.
- Select Theme > Save Data Set from the menu.
- Navigate to a more permanent directory, and call the new data set sine_of_asp.
(You may want to create C:\temp, and store the data set there, rather
than filling up your removable disk.)

Now the theme Map Calculation 1 is stored as C:\temp\sine_of_asp.
Grid data theme file names can be a maximum of 13 characters in length, and
should not start with a numeric character. Also, note that whey you save a grid
to a new directory, along with the grid directory is the directory info.
If the grid directory is moved, the info directory must also be moved.
Rather than using the OS to move and copy grid data sources, it is better to
use ArcView 3.x 's data source
management tool.
Some data sets that have been in use in a project cannot be moved or renamed
until the ArcView 3.x project is closed and a new project opened.