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 II

Discussion:

There are many different types of raster analysis available in ArcView 3.x. Here are just a few of the common analytical functions. More analytical functions on raster surfaces models will be dealt with in 3-D and Surface Modeling.


  1. Start a new project
  2. Importing data from generic raster files
  3. Mosaicking grids
  4. Calculating distance surfaces and buffers
  5. Creating surfaces from point samples
  6. Mapping contours
  7. Calculating summary attributes for features using a grid theme ("Zonal summary")
  8. Cross tabulating areas
  9. Querying across multiple grid themes
  10. Calculating neighborhood statistics
  11. Reclassifying the cell values of a grid theme
  12. Conditional processing
  13. Converting raster and vector data sources


 


Start a new project

  1. Delete everything you can from your removable disk.

  2. Start ArcView 3.x with the cfr250.apr project from the CD (Create a new project called r_an2.apr).

  3. Set the working directory to your preferred location (by default it is set to the root of your removable drive's file system).

  4. Enable the Spatial Analyst Extension.

  5. Make sure to save early and often. You may want to turn on auto-save with the Auto Save Extension.

 


Importing data from generic raster files

  1. Download the file q1822.zip, and save it on the removable disk.(The full set of Washington State DEMs is available from a server in Geological Sciences.)

  2. Open the Windows Explorer and double-click on the file you just downloaded.

  3. When WinZip starts, Extract the file as q1822.dem. The extracted file is a USGS format digital elevation model (DEM) for the USGS 7.5' topographic quadrangle map of Eatonville. The DEM is a raster data set representing elevation values.



  4. Open a new View document and rename it to Eatonville.

  5. From the File menu, select Import Data Source. Select the USGS DEM file type.



  6. Open the q1822.dem file.



  7. Save the new grid theme as eaton.



  8. Add the new theme to the view.




  9. Turn the theme on. Change the classification to 64 Equal Interval classes.

  10. Alter the color fill symbol of three different values (note: the class numbers here are approximate; you do not need to count classes, just get the correct shade in a class close to the value shown in the table below):

    Class Value Color
    class 1 green
    class ~10 yellow
    class 64 red
    No Data blank ("X")

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

 

You have just successfully downloaded a public-domain digital elevation model, imported it into ArcView 3.x, and displayed it in a graduated color ramp by elevation. Almost all of the DEMs for the US are available for free download. DEMs are used in all aspects of GIS analysis of landscapes. Elevation is one of the most basic things we need to know about landscapes. Also, elevation data sets are the basis of slope and aspect data sets.

 


Merging adjacent grids ("mosaicking")

  1. Also download and import the Elbe DEM (q1823.dem). Call the output grid elbe.



    Even if you use a similar color ramp, you can still see the hard edge between the two grids. You can also see that these are still two separate grids in the View's table of contents.

  2. Open a Map Calculator by selecting Analysis > Map Calculator from the menu. In the Map Calculator's expression area, enter

    ( [Elbe] ).Mosaic( {[Eaton]} )



    This expression is the Avenue syntax for "Mosaic the Eaton grid with the Elbe grid." This is an example of using the Map Calculator to run some Avenue code. Most of the functions that can be performed on grids is not available in the Map Calculator GUI; in order to access these functions, they must be constructed in the Map Calculator using Avenue syntax.

    If you are mosaicking together more than two grids, place the other grids as a comma-separated list within the curly braces, e.g., if you were to also mosaic the Ashford DEM grid with the other two (don't actually do this, it is an example):

     ( [Elbe] ).Mosaic( {[Eaton], [Ashford]} )


  3. After a few moments you will see the result as Map Calculation 1 in the View.



  4. Alter its legend as you did with the other grids and you will see that there is a smooth transition between the two source grids in the output.

 

You have just downloaded, imported, and merged two adjacent USGS digital elevation models. If your study area runs across several USGS quad sheet boundaries and you need to perform analysis using elevation data, you will need to mosaic them together.

 


Calculating distance surfaces and buffers

  1. Create a new view called Pack Forest.

  2. Add the streams theme from the CD.

  3. Turn the theme on, make it active, and make sure that you are zoomed to the extent of the active theme.

  4. From the Analysis menu, select Find Distance. Accept the default values for cell size, rows, and columns.
    A large cell size will process much more rapidly. Use a smaller cell size if you need more precision.




    Note: if you have already set Analysis Properties from the menu, you will not get the Output Grid Specification dialog. You will only get this dialog if you have not explicitly set analysis properties for the view.

  5. The new grid theme will be added to the view. Change the drawing order so that streams draws on top.

  6. Change the classification of the new theme to 64 equal-area classes, and use the Yellow to Green to Dark Blue color Ramp.



    Now every cell in the output grid has a value for its distance to the closest stream. This has a similar look as a buffer with concentric buffer zones, but each cell is coded for its distance to the closest stream rather than simply being coded for "inside or outside" a particular buffer.

  7. Using the Identify tool, examine a few values for the new grid.

Do you see how this is different from the buffer function in the vector world?

 

Now that you have a surface which has distance to each stream, create a grid theme which represents the cells within 500 ft of existing streams.

  1. From the Analysis menu, select Map Calculator.

  2. Format a calculation that only takes cells within 500 ft of streams.




  3. Turn this new theme on.



  4. Create a theme query (using the Query Builder button, not a Map Query) on the new theme (Map Calculation 1) for cells with a value of 1 (cells that are within 500 ft of streams). You should see the cells highlight in yellow.

  5. With Map Calculation 1 the active theme, select Theme > Convert to Grid from the menu. Call this grid str500. This creates a grid composed only of valid cells from the selected set in the last step. The difference between this new theme and the previous theme is that the previous theme has valid cells outside the 500 ft boundary; the new theme you just converted only has valid cells within that 500 ft boundary.

  6. From the Analysis menu, select Properties. Set the Analysis Mask grid theme to Str500. Now calculation output will only occur for cells located at the same place as non-null cells in the mask grid. Stated another way, now new grids will be created, but cells will only have value in that new grid where they are within 500 ft of a stream.

  7. Create a new Map Calculation with the expression

       ([Distance to Streams])

    This will create a new grid that is identical to the original distance grid, but its will have value for cells only within the mask grid. The mask limits the spatial extent of output cells.

  8. Change the color ramp and classes for this new grid. You should be able to verify that the new grid has value only for cells within the mask grid by using the Identify tool. When you click within a buffer zone, you will get the distance of that cell to the closest stream. If you click outside of the 500 ft buffer, there will be no cell value reported in the Identify Results dialog.



  9. Make sure to set the Analysis Mask back to No Mask Set before proceeding.

The "easier" method is to use Avenue code:

  1. Using the distance grid you created before, perform a single Map Calculation:

    ( ([Distance to Streams] > 500.AsGrid).SetNull ([Distance to Streams]))

  2. This translates to the English sentence:

    "If the value of the Distance to Streams.shp grid is greater than 500, make the value of the output cells No Data ('Null'), otherwise set the value of the output cells equal to the value of the Distance to Streams.shp grid."

    It might actually be possible to perform the entire process (creating the distance surface and limiting to 500 ft) with a combination of the AsPolylineFTab, EucDistance, Con, and SetNull requests.

 

You have just created a distance surface grid from a stream vector theme. These distance surfaces are similar to buffers, but rather than having a simple binary in-or-out value, the cells are coded with the actual distance of the cell center to the nearest stream. If you are performing some kind of modeling where the actual distance from a feature (rather than an inside/outside a buffer) is important, you can use this technique.

 


Mapping contours

  1. Go back to the Eatonville view and turn off the merged grid (Map Calculation 1).

  2. Click the Create Contours button and click anywhere on the map. This will trace a contour at the elevation where the pointer was located when the mouse button was clicked.



    The line connects cells that have the same value

  3. If you use this technique, it allows you to visualize the location of contiguous cells with the same value as the location you clicked. The resultant line is a simple graphic, rather than a theme, which is why it appears with selection handles. Click a few more locations to see other individual contours.

  4. From the Edit menu, choose Select All Graphics, to select all of the contour lines you just created. Press the <Delete> key to delete the graphics.

  5. Now, instead of creating simple graphic contours, now create a contour line theme

    From the Surface menu, select Create Contours.

  6. Choose a Contour Interval of 10, and a Base Contour of 0 , and click OK. This specifies contours to be created at multiples of 10, starting at 0 or the lowest multiple of 10 in the current grid.



  7. After a few moments, the process will finish, and a new line theme will be added to the view.

  8. Zoom in so that you can see the contour lines clearly.



  9. Using the Selection tool, select a single contour line. Open the theme table and click the Promote button.
    You will see that the record for the selected contour contains the value of the elevation of that selected line.

 

You have just created single contour lines as graphics, as well as an entire vector contour line theme. Use this technique to create contour line data if you only have available raster elevation data, but need contours on your map. Beware, however, that the contour lines are only as good as the input data, which in many cases, are not very good at all. There are also issues of line generalization that may affect data quality.

 


Calculating summary attributes for features using a grid theme ("Zonal summary")

  1. Create a new view and add the grid theme Dem and the polygon theme Stands from the CD.

  2. Make the Stands theme active and select Analysis > Summarize by Zones from the menu.

  3. Choose the item Site_index as the zone defining field. This specifies that we are interested in grouping the stands together and analyzing by unique value of site index.



  4. Choose Dem as the theme containing the variable to summarize. This specifies that we are interested in creating summary statistics for elevation, but based on spatial groups ("zones") lumped by site index value.



  5. The zone summary will take a few moments. Select Mean as the Statistic to Chart. A new chart will open.



  6. In addition to the chart, a summary table will be created.



    This table contains the statistics for the Dem grid (elevation) for each Site Index zone in Stands.

 

This chart shows the mean elevation within each different site class zone for the area within Pack Forest. You can customize the chart to show any of the statistics that have been created in the zonal summary table. You can use any field from the polygon theme to generate statistics for the grid (e.g., stand name, age class)

If you have a selection of polygon features, the statistics generated will only contain values calculated for those selected polygons.

If your number of unique values in the summary field is too many to chart, the summary table will still be created.

 


Cross tabulating areas

Area cross-tabulation is useful for comparing different data sets for the same area, as well as for comparing the same data themes at different times. We will compare the bd-ft volume of conifers in 1994 to that of 1974 for each CFI zone.

  1. Create a new view called PF CFI.

  2. Add the CD:\packgis\cfr250\cfi.shp theme from the CD. This is a polygon data set where the entire polygon is coded for the values obtained from the plot center.

  3. Make the cfi.shp theme active and select Theme > Convert to Grid from the menu.

  4. Call the new grid con1974. Its cell values will represent conifer volume for 1974.

  5. Accept the default cell size, etc. if you have not previously set analysis properties.

  6. For the Conversion Field, select Sv61974cpa (conifer volume per acre in 1974). This creates a new grid that represents 1974 conifer volume.

  7. Add the new theme to the view.

  8. Convert the cfi.shp theme to a grid, but this time, call the new grid con1994, and use the Sv61994cpa (conifer volume per acre in 1994) as the Conversion Field, and add this theme to the view. This creates a grid whose value represents conifer volume in 1994.

  9. Create a Map Calculation to convert the Con1974 grid to an integer grid, with value in MBF/ac (1000 bd ft/ac). The Map Calculation simply takes the board-foot volume estimation in feet and converts it to a grid where the values are 1000 board-feet (known in the trade as MBF). The values must also be converted to integer in order to run the cross-tabulation.



  10. Using the Theme > Save Data Set menu choice, save the newly created Map Calculation theme as Mbf1974. (Note that if you have saved the project, your temporary grids will already have become permanent, and the Save Data Set option will be grayed out.)

  11. Rename the theme as it appears in the view (Theme > Properties from the menu) to Mbf1974.

  12. Open the table for Mbf1974.
    1. Sort the table (in descending order) based on the Value field to determine how many digits are present.

  13. Start editing the table, and add a numeric field called mbf74. Make sure the new field is wide enough to hold a copy of the Value field, as you determined in the previous step.

  14. Calculate the new field equal to the Value field. The only difference between the Value and mbf74 fields is the name. The more descriptive name will make it much easier to read the output table.

  15. Stop editing the table and save the changes.

  16. Repeat the previous steps from Step (3) to Step (15), to create a new grid called Mbf1994, representing data from 1994 instead of 1974.

  17. From the Analysis menu, select Tabulate Areas.
    Make sure to select the newly added and calculated fields for the Row Field and Column Field.



  18. A table will be opened that contains records for the values in 1994, and columns for the records in 1974. You can look at changes in volume across the 20-year period. The table is a change matrix.



    The first field in the table represents the unique MBF values for plots in 1994, and the other fields represent the MBF values in 1974.

    For example, look at the record for 12 MBF/ac in 1994 (where mbf94 = 12). Each mbf74* field for this record represents area (in map units, which in this case, are square feet) with that given MBF value in 1974. For this record, there were 421,174 ft^2 of land with 0 MBF in 1974, that have grown to 12 MBF in 1994. There were 456,272 ft^2 of land with 1,000 bd-ft per acre in 1974 that have grown to 12,000 bd-ft per acre in 1994.

 

You have just created a table that represents the difference between two themes. The values in this type of table can be used for change detection. Imagine using different data, such as population for the Puget Sound region across a time interval, or the land cover type from today and 20 years ago..

You may find this topic difficult to understand at first. If you have any trouble understanding this complex analysis, make sure to read ArcView 3.x 's help files on "Tabulate Area."

 


Querying across multiple grid themes

Perform a complex query that identifies cells that meet multiple criteria across several grid themes. In this example, find all areas in the forest that are above 1500 ft in elevation, which are within 500 ft of streams, and have a conifer MBF volume greater than 60.

  1. Open the Pack Forest view.

  2. Add the grid theme Dem from the data CD.

  3. Add the Mbf1994 grid theme to the view.

  4. Perform a Map Query with the following syntax:



  5. Format the view so that you can clearly see the selected cells along with other features.



  6. What is the total area of this zone?
    1. Open the Theme > Properties for the new theme, and make a note of the cell size (in this case, the cell size is 99.45; your value may vary).



    2. Open the theme table for the new theme, and start editing.
      Add area_acres as a numeric field, 6 columns wide, with 2 decimal places.
      Calculate the new field (acres = number of cells * area of cell / conversion constant for square feet to acres):







      There are 112.6 ac which are within 500 ft of streams, above 1500 ft in elevation, and containing at least 60 MBF/ac of conifer volume.

 

You have just performed a query that picks out cells that match criteria from more than one grid. This is very similar to the topological overlay analysis of intersection. Do you see how much more rapid this type of analysis is with raster analysis? How many separate single actions would it have taken to do this with vector data? Using more complex syntax within the Map Calculator would have allowed us to perform the analysis with even fewer steps.

Although the vector data analyses take advantage of the better representation of shape for line and polygon features, if the cell size is small enough to correctly represent the shape of features, the numbers generated should be within an acceptable margin of error.

 


Calculating neighborhood statistics

What parts of the forest has the greatest topographic complexity? Based on a 5 by 5 cell kernel passed over the entire landscape, calculate the standard deviation of elevation within that 5 by 5 cell kernel, and place the output of each of those calculations in the center cell of the output grid.

  1. Make the Dem theme active.

  2. From the Analysis menu, select Neighborhood Statistics.

  3. Select the statistic Standard Deviation. Use a 5 by 5 rectangle of cells.



  4. After a few moments, a new grid theme will be added, called Nbr StdDev of Dem ("neighborhood standard deviation of Dem").
    The values for each cell of this grid theme represent the standard deviation of elevation in a 5 by 5 cell neighborhood for each original cell in the Dem grid. The standard deviation in this case gives a measure of the local variability in elevation.




    The darker areas are similar in location to the places with high slope for Pack Forest. This is no coincidence; places with the greatest slope over a small area will have the greatest variability in elevation over the same area. Here is a view with slope generated for the same area, displayed in the same color scheme:


 

The same basic technique could be used, for example, to characterize land use or land cover types. For nominal data such as land use or land cover, the neighborhood statistic Variety would render a new grid theme in which the output cells represent the number of distinct classes within the kernel area.

Here is an example of a neighborhood calculation based on some vegetation grid zones. The highest-contrast edges (those that have the greatest difference in vegetation zone type value) result in cells with a higher standard deviation value (shown in a darker shade of gray). Can you reproduce something like this using the Pack Forest stand polygons, based on the Site_index field values?

 


Reclassifying the cell values of a grid theme

Sometimes it is more convenient or appropriate to deal with classes of data values rather than continuous values. Frequently, elevations are easier to deal with in quantized intervals, rather than in continuous form. Nominal data are often reclassified to ordinal values as input to numerical or statistical models.

  1. Make the Eatonville view active, and make the Eaton grid theme active.

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

  3. Using the Reclassify Values dialog, create 9 classes.

  4. Alter the Old Values field to use class breaks at multiples of 100.



  5. When you have finished altering the Old Values, click OK.
    The new theme will be called Reclass of Eaton.



    Now, rather than unique elevation values, the cell values are constant within the each 100 m elevation class, as shown in the theme table:



  6. Add the original Eaton DEM grid theme to the view to compare your original data with the reclassified elevation data.

    This data conversion is frequently used for inputs to models in which classes of data are assigned a certain weight. For example, a predictive model of vegetation or habitat might use weighted values for elevation classes, rainfall, and temperature.

 

  1. Open a new view and add the Stands theme from the CD.

  2. Create a simple summary table from the Stands theme attribute table with Species as the Summary Field and no Summary Statistics (do not add any fields, just click OK).

  3. Alter the new table.
  1. Add the numeric field spp_rank (a 2 column numeric field).
  2. Delete the Count field.
  3. Alter the values so that the table looks like this:



  4. Stop editing the table (and save changes)

  1. Join this table to the Stands theme table. Now you have a numeric value attached to each stand that represents ordinal values of Species.

  2. Create a new grid from the Stands feature theme. Make sure there is no selection on this theme.

  3. Accept the default extent, cell size, rows, and columns.

  4. Call the new theme Stand_g. Select spp_rank as the Conversion Field.

  5. Add the new theme to the view and classify based on the Value field.




    This grid represents a ranking of different dominant species.

    In this example, the ranking scheme is meaningless, but vegetation and habitat raster models are frequently developed using rankings of various landscape properties, such as slope, aspect, or vegetation type.

 

You have just reclassified raster data. Frequently raster data contain too many values to be of any practical use, either for analysis or mapping. Reclassification allows you to lump classes together so that they are easier to understand or to manage. Beware that doing this type of reclassification is not reversible, and it is always easier to lump classes together than to split them apart later. This type of aggregation of data incurs a loss of information, but can lead to better understanding.

Be careful that you somehow maintain the original source of your classes. If you create reclassified grids but do not have the "key" to the values, you may not recognize the data later. In order to get around this, you can always add new fields representing the original range of values for the class.

 


Conditional processing

Suppose you have a vegetation model that uses an elevational response. If elevations are between 500 and 700 feet, the model inputs will be 100 * the elevation value. If the elevations are outside this range, the model inputs will be 0.

  1. Use a Map Calculator to create an expression using the Con request on the merged Eatonville/Elbe grid (Map Calculation 1) in the Eatonville view.

  2. Enter the following expression (feel free to cut-and-paste, remembering to use the standard <CTRL-C>, <CTRL-V> cut and paste keystrokes):

    (([Map Calculation 1] < 500.AsGrid).Con(
    0.AsGrid, ([Map Calculation 1] > 700).Con(
    0.AsGrid,
    [Map Calculation 1])) * 100)


    The expression means this line-by-line, in English:

    If [Map Calculation 1] is less than 500, then
    set the output grid value at 0, but if [Map Calculation 1] is greater than 700, then
    set the output grid value at 0, but if none of the criteria are met, then
    set the output value equal to [Map Calculation 1] * 100.

    The output grid will look like this, if you use a natural-breaks classification and a distinctive color scheme:



    Note that the low and high elevations have an output value of 0, with the values of the original 500-700 now in the range of 5000-7000.

 

You have just used conditional processing to create a new grid. The actual values we used are meaningless, but the theory is important. Do you see how this is different from either a simple reclassification or a map query? A reclass with this precision would have taken quite some time to code, and a map query would have given us only yes-or-no values.

The syntax of the conditional statement takes a little getting used to, but you can see what a powerful tool this is for dealing with conditional processing of cell values. Frequently in modeling spatial phenomena, we want to treat a subset of cells in one way and a different subset of cells in a different way.

 


Converting raster and vector data sources

What is the length of stream within each 100-ft elevation class in Pack Forest? This question requires (1) reclassification, (2) conversion from grid to polygon, and (3) topological overlay.

  1. Reclassify the Pack Forest Dem grid into 17 100-ft elevation classes.
    You should choose 17 because the range of data values is ~ 400 > 2100 (roughly 100 ft of elevation per zone).
    If you feel particularly ambitious, format the reclassification so that the class boundaries fall at even 100 ft intervals.
    This will create a new temporary grid called Reclass of Dem.

  2. Make this new theme active.

  3. From the Theme menu, select Convert to Shapefile. Name the new shapefile elev100, and add it to the project.

    (You have just converted a grid theme to a polygon shapefile representing elevation bands)

  4. Make sure that the XTools Extension is enabled.

  5. Intersect the themes Streams and elev100.

  6. Open the theme table for the resultant intersected line theme.

  7. Create a summary table based on the Gridcode field, with the summary statistic Sum_Length.




    For each elevation zone, we have the sum of length of streams. Extra problem: add a descriptive field containing the actual elevation ranges within the class so that rather than the unitless Gridcode field, the table actually has meaning to a reader.

Instead of calculating the length of streams within these zones, suppose we want to count cells instead.

  1. Make the Streams theme active.

  2. From the Theme menu, select Convert to Grid. Call the new theme Stream_g.

  3. Accept the default extent, but choose an output grid cell size to match the Dem theme.

  4. Use Dnr_type as the Conversion Field.

  5. Do not join attributes, but to add the new theme to the view.

  6. The actual cells may not be visible unless you zoom in quite a bit.




    (You have just converted line feature data to a grid theme).

  7. Cross-tabulate the elev100 theme's Gridcode field against the Value field of Stream_g. Now you can analyze the "area" of streams within each elevation class:

 

You have just converted between raster and vector data types. Sometimes you need to perform an analytical task either with raster or vector data. If one of your data sources is in the wrong data type, you can use this technique to convert between the data types. Remember that there is almost always a loss of information when you convert between these formats. Also be cognizant of any attribute value changes as you move between feature theme tables and VATs.


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