Introduction to Geographic Information Systems in Forest Resources
UW Home GIS@UW Search
Syllabus Schedule Class Meetings Assignments Course Data Internet Search

Current Grades

Contact Us CFR 590 Internet-only section Lab Locations  


Exercise: Raster Analysis I

  1. Clean out your removable disk
  2. Open an existing project
  3. Add a grid theme to a view
  4. Convert between floating-point grid and integer grid theme types
  5. Alter the display of a grid theme
  6. Query a grid theme
  7. Create a histogram
  8. Reclassify a grid theme
  9. Perform a map query on a grid theme
  10. Perform a map calculation on a grid theme
  11. Set analysis properties
    Masking
    Cell size and analysis extent
  12. Examine projection properties
  13. 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

  1. 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.

  2. Cancel the Add Theme dialog.

  3. Enable the Spatial Analyst Extension.

  4. Click the Add Theme button.

  5. Select Grid Data Source from the Data Source Types dropdown list.


    Now you will see the dem theme listed.



  6. Add the dem grid theme to the view.

  7. 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.

  8. 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.

  1. Open the Legend Editor for the Dem theme.

  2. Change the number of classes to 30.

  3. 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.

  4. 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.

  5. 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.

  6. 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.

  7. 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.



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



  9. 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.




  10. 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.

  1. 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.

  2. Select Analysis > Map Calculator from the menu.

  3. Double-click on Dem in the Layers field, which places it in the expression.

  4. Select the Arithmetic choice in the pulldown.

  5. Click the Int button, which specifies that the Dem grid should be converted to an integer grid, called Map Calculation 1.

  6. Make sure that your calculation is formatted

    ( [Dem].Int )

    as shown below.

  7. 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.

  8. 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.

  9. 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.

  10. 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.



  11. 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

  1. 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.

  1. Change the number of classes displayed in the Dem_int theme to 30, keeping the Green Monochromatic Color Ramp.

  2. 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.

  3. 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
  1. 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.



  2. Add the table identified in step 1 to the project. The tabular data source will be located in your current working directory.

  3. Turn off the Dem and Dem_int themes.

  4. Make the Pack Forest View document active. Make sure that the Dem_int theme is active with the previously defined selected set.

  5. From the Analysis menu, select Reclassify....

  6. 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.

  7. 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.

  8. Turn on the Reclass of Dem_int theme.

  9. Next, link the histogram table with the new theme table.

    1. Open the theme table for Reclass of Dem_int, and make the Value field active.

    2. 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.

  10. 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.

  11. 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.

  1. Make the Pack Forest View active.

  2. From the Analysis menu, choose Map Query.

  3. Double-click on Dem in the Layers field.

  4. Click the Greater Than button .

  5. Type in 500.

  6. Click the And button.

  7. Double-click on Dem in the Layers field.

  8. Click the Less Than button .

  9. 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."

  10. 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.

  1. Make Dem_int the active theme.

  2. 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.

  3. Select Map Calculator from the Analysis menu in the View GUI.

  4. Put the [Aspect of Dem_int] grid in the Map Calculator.

  5. Use the trigonometry functions to build a calculation by selecting the Trigonometry value in the dropdown.

  6. 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.



  7. 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.

  1. First, we need to create a grid for masking.
    1. Perform a "normal" tabular query on the grid theme Map Query 1 (where Value = 1).
    2. 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.
    3. When asked if you want to add the theme to the view, select Yes. This grid should be called Nwgrd1.

  2. From the menu, choose Analysis > Properties.
    1. 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.
    2. Change the Analysis Cell Size to Same as Dem. In this case, the cell size is 10 ft.
    3. 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.



  3. 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.

  1. Zoom into an area in the middle of the forest.

  2. From the menu, choose Analysis > Properties.

  3. Set the properties as below by selecting
  4. To verify that the settings work correctly, perform a very simple Map Calculation:



  5. 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.

  6. Check the properties of this new theme:




  7. 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.

  1. Open a new view.

  2. Add the feature theme states.shp from the esridata\usa directory on the CD.



  3. From the Theme menu, select Convert to Grid. Save the new grid as state_grid in the working directory.

  4. Accept the default Conversion Extent, Cell Size, Row and Column parameters.



  5. Select State_name as the value field in the conversion.



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





  7. 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.

  8. All of the source data so far are stored in geographic coordinates. Apply a projection to the view (any one will do).

  9. Make the vector theme active active, and zoom to its extent.
    1. Turn off the grid theme and turn on the vector theme.
    2. Turn off the vector theme and turn on the grid theme.

  10. Make the grid theme active, and now zoom to its extent.
    1. Turn off the grid theme and turn on the vector theme.
    2. Turn off the vector theme and turn on the grid theme.

  11. 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.

  1. Switch back to the Pack Forest view.

  2. Make Map Calculation 1 the active theme.

  3. Select Theme > Save Data Set from the menu.

  4. 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.


Syllabus Schedule Class Meetings Assignments Course Data Internet Search

Current Grades

Contact Us CFR 590 Internet-only section Lab Locations  

 

The University of Washington Spatial Technology, GIS, and Remote Sensing Page is provided by the College of Forest Resources and the College of Ocean and Fisheries Sciences through Unit-Specific UIF. Site administrator: Phil Hurvitz.
Copyright © Phil Hurvitz, 1998-2003