You are on page 1of 7

GEO/EVS 425/525 Unit 4 Operations on Raster Images

In this exercise, you practice several different kinds of actions on raster images. These will involve three different classes of actions: actions on individual pixels, actions on local neighborhoods, and actions on regional neighborhoods.

Operations on Individual Pixels


Changing the ability of an image to communicate ERDAS Imagine In ERDAS, you can increase the ability of an image to communicate by using the raster attribute editor: First, let us try the simplest sort of action on individual pixels improving the visibility of image by using the raster attribute editor. Copy the images LANIER.IMG and LNLANDC.IMG from the Q: drive onto your X: drive, and then open them. The first is a thematic mapper image of the area around Gainesville, Georgia; the second is a land-cover model of the same area. The colors which appear in the land-cover image are designed to be reasonably close to those found in the original thematic mapper image (LANIER.IMG) from which this land-use class model was derived. Remove LANIER.IMG from your view, and open the raster attribute editor for the land-cover model by rightclicking it and choosing to show the raster attribute table. You will notice that there are 15 land-use classes. Because the colors are what they are, they do not stand out legibly. By clicking on the color swatches in the raster attribute editor, change the colors for each land-use class to colors that better express the actual use of the land. Note that the raster attribute editor includes a column for the histogram, indicating the number of pixels in each land-cover type. If you choose to add an area column, you will get the area in each land-cover class as well. Close the raster attribute editor. When you are prompted to save it, do so. In doing this simple action, you have not changed any of the data in the image. However, you have made a major change in the ability of the image to express information. It is much easier to distinguish land uses now than it was previously. Save this image on your X: drive and close Imagine. Open Windows Explorer and navigate to the file you have just saved. Right-click on the name of the image. Remember that a single image may include more than one file. Choose to Rename the file. Rename it to something that will remind you that it is the version of LNLANDC that you manipulated in ERDAS. Rename each file comprising LNLANDC. You will need this image later. ENVI Again copy LNLANDC.IMG from Q: to X:. Open it in ENVI. It should look exactly like it first did when you opened it in ERDAS. Right-click the layer name and choose Raster Color Slices. Since there is only one layer (Layer_1), that layer will be highlighted. Choose OK. You can right-click on any color swatch and choose to edit the color to change it to any other color you want. Note that you are given several different systems of color management from which to choose. You should look at how each of them manages color differences and choose the one that makes the most sense to you. When you are done, save the file. You will be asked for a new name; give it one that reminds you that it is the file you manipulated in ENVI, and be sure to put it on your X: drive. Note that if you wanted to, you could save your new color palette to a file of its own, so that if you had several land-cover models with the same 15 classes you could simply change to the same palette by loading that file. Before you remove this image from your view, right-click on the classes under the image name and choose Stats for All Classes. This gives you the same information about the extent of each class as you received from ERDAS. Generating new data using known relationships As you know, the temperature of the land surface is a function of the elevation. We can approximate the

relationship between the temperature at any point in time and elevation with the general equation: AirTemp = GaugeTemp - (AdiabaticLapseRate * (ActualElevation - GaugeElevation)) This the formula for the theoretical relationship between elevation and temperature, assuming that no energy is added to or subtracted from an air mass as it changes elevation. The key parameter for the equation is the adiabatic lapse rate, which varies between 0.0036 EC / m for moist air and 0.01EC / m for dry air. The average value is 0.0066EC / m. You will be making a map of the calculated temperature for an area in California ranging from Death Valley, California, on the east, across the Sierra Nevada and Mount Whitney and into the Central Valley to the west. This area includes areas both above and below sea level, including the highest and lowest points in the lower 48 states. For our purposes, we will assume an adiabatic lapse rate of 0.009 EC / m, closer to the dry lapse rate, since this is a fairly dry area. We shall also assume that the reference gauge is at an elevation of 150 m above sea level approximately the elevation of Fresno. If we ask, therefore, what the temperature in this area when the sea-level temperature is 30EC (86EF), the temperature of each point in this area can be estimated by the specific formula: AirTemp = 30 - (0.009 * (Actual Elevation - Gauge Elevation)), or AirTemp = 30 - (0.009 * (ActualElevation - 150)), where AirTemp is EC and ActualElevation is in meters. What you will do here is to begin with an image in which the raster attribute is elevation in meters and create a new attribute of temperature, based on the value of the primary pixel attribute (i.e. elevation) and the well-known relationship between elevation and temperature. You could, if you chose, add a series of attributes (e.g. Temp10, Temp20, Temp30, etc.) to calculate the temperature of the area where the temperature at sea level (or any other known elevation) is 10E, 20E, 30E, etc. To be sure, the calculation is not precise, since there are differences in weather from the Fresno to the Sierra Nevada and Death Valley area, and the actual lapse rate does depend on both weather patterns and the relative humidity of the air, but the basic logic is quite sound. Note also that you have used the elevation value for each pixel in the image to calculate the corresponding temperature. The lapse rate formula works on a place-by-place basis, and the temperature value of one place does not depend on the elevation of adjacent places. ERDAS Imagine Copy the image, MTWHITNEY.IMG into your X: drive, and load it into the viewer. Be sure that you open it as a pseudocolor image. Use the Inquire Cursor function to get an idea of the variation in elevations from place to place. Open the metadata, and determine as much as you can about the image. Display the attribute table, and click on the Column Properties icon. Choose to add a new column, and make its name editable. Give it a suitable name (e.g. Temperature), and fill the columns using the formula, 30 - (0.009 * ($Value - 150)). Be sure that you understand why this formula will calculate the temperature at each elevation throughout the region when you click on apply. Remember to check the Apply on OK box, so that the formula really does apply! Now find the areas of likely snow cover when the Fresno temperature is 30EC. To do this, use the hidden row functions to set a search criterion, Temperature < 0", where temperature is whatever you named the column you added in the Raster Attribute editor. Change the color of the areas selected by this criterion to white. Now find the areas in which the temperature is greater than 88EF (31EC). Change the colors of these areas to red. ENVI For this exercise, you do not need to copy the MTWHITNEY image again, although you can if you want. Open the image from the T: drive and click Spectra -> Spectral Math from the ENVI toolbox. In the Enter an Expression field, type 30-(0.009 * (s1 - 150)) S1 becomes the variable name for your elevation. ENVI expects these variables to begin with the letter s and to be followed by a number. When you click OK, you will get a window that tells you that variable S1 is undefined. This window contains a Map Variable to Input File button, which you should press.

Your input file is the MTWHITNEY.IMG file on the T: drive. Give your output a new name and click OK. The resulting image is a bit different from what you got with Imagine. In ERDAS, the attribute table included the primary attribute, elevation, and a secondary attribute, temperature. In ENVI, you have calculated a new image whose attribute is temperature. When the results show up in the view, rightclick on the name and choose Raster Color Slices. The numbers shown represent the temperature across the Sierra Nevada to Death Valley. Adjust the color scales as you wish. Again, find the areas of likely snow cover when the Fresno temperature is 30EC. You can easily see which color swatches refer to temperatures below 0EC and below 31EC. Note that the default color table is about 16 different slices. However, if you click the New Default Color Slices icon you can increase the number markedly if you want. You should experiment with these tools and come to a result that pleases you. Overlaying layers from different maps So far, our operations have acted only on single images. Lets do an analysis in which we need two images. Using the familiar images of Gainesville, GA, determine which areas of deciduous forest have Pacelot soils. ERDAS Imagine Open two views by clicking Add Views -> Display Two Views on the Home tab, and load LNSOILS.IMG and LNLANDC.IMG. Now Click on Thematic -> Overlay By Min or Max from the Raster tab. You are prompted for two input images and an output image. Use the two images in your viewers as your inputs, and give the output a suitable name. Click on the button below the LNSOILS.IMG window labeled Setup Recode. Select the soils which are Pacelot soils (i.e. $Class_Names contains Pacelot). Note that the Setup Recode window looks almost identical to the Raster Attribute window. There is one difference, however. There is a window labeled New Value and a button labeled Change Selected Rows. Make sure there is a 1' in the New Value window, and press the Change Selected Rows button. Now invoke the hidden functions popup by right-clicking on the lefthand row and choose Invert Selection. Put 0' into the New Value window and press the Change Selected Rows button. You have just created a raster in which the areas with Pacelot soils have the value of 1' and all others have the value of 0'. This is a Boolean image that answers the query, Identify all areas with Pacelot soils. Now click on the Setup Recode button below the LNLANDC.IMG window and change the areas of deciduous forests to 1' and the other areas to 0'. Again, this is a Boolean image that answers the query, Identify all areas of deciduous forest. Now look at the other things required in this dialog. You can choose the union or intersection of the two images. If you choose the union, your output will include all of the area in both of the input images, including areas that do not overlap. If you choose the intersection, your output will include only the area of overlap in the two images. Since your two images are of precisely the same area, the two are equivalent. More important, look at the radio button for Maximum Value or Minimum Value. If you choose the maximum value, the output will code all areas in which either of the input images had a value of 1' as 1'. If you choose the minimum value, the output will code only areas in which both of the input images had a value of 1' as 1'. Since you are interested in the areas that meet both conditions, you need to choose the Minimum Value option. Click on OK, and look at the result. Compare it to the soils and land use images. To make the comparison easiest, open the metadata for LNSOILS.IMG and find all areas of Pacelot soils using the criteria hidden function. Change the color so that all areas of Pacelot soils have an appropriate color (e.g. brown). Invert your selection, and change the color of all non-Pacelot soils to some other color (it doesnt matter what) with an opacity of 0, so that that part of the image is transparent. Open the metadata for LNLANDC.IMG and change the color of deciduous forests to an appropriate color (e.g. green) and all non-deciduous-forest areas to transparent. Take the image you have just created and change the color of Pacelot+Deciduous to something other than what you determined for the land-cover and soils maps (e.g. yellow) and the opacity of the background to 0. Be sure to save all of these images on your X: drive. Now load open a viewer with LANIER.IMG as the base image, your newly adjusted LNSOILS.IMG and LNLANDC.IMG images in the middle, and your newly created image on top. Assuming you picked the suggested colors (and you should be creative in

picking colors), the areas of Pacelot soils in areas other than deciduous forest will be brown; the areas of deciduous forest on soils other than Pacelot will be green; the areas of deciduous forest on Pacelot soils will be yellow, and all other combinations will show the satellite image of the Gainesville area. ENVI Load LNSOILS.IMG into your viewer. It looks identical to the same image when you loaded it into ERDAS, but the Layer Manager shows only Layer_1 as the information. Now click File -> Save As to save it as an ENVI file. When the layer is displayed, you will note that in addition to Layer_1, the 35 soil classes are also shown. The Pacelot soils are index numbers 28 through 31. In the ENVI toolbox, click Classification -> Post Classification -> Class Statistics. Choose the ENVI file you just created for your Classification Input File and your Statistics Input File. When the Statistics Input File opens, click Mask Options -> Build Mask. When the Mask Definition window opens, click Options -> Import Data Range. Enter 28 as the minimum value and 31 as the maximum value. Enter an appropriate file name, and click OK. The mask is produced in which Pacelot soils have the value of 1 and all others have the value of 0. Carry out the same actions on LNLANDC.IMG. Load it into your viewer, save it as an ENVI file, use the Class Statistics tool to create a mask in which deciduous forests are chosen. You will end up with a mask in which deciduous forests have the value 1 and other land covers have the value 0. Now we can find out which areas are both Pacelot and Deciduous. Click Raster Management -> Masking -> Build Mask from the ENVI toolbox. Before you can use this tool, you have to enter the number of columns (samples) and rows (lines). You find these by opening the Data Manager, choosing a file, and clicking File Information. Then click Options -> Import Data Range. Choose one of the masks you created. The minimum and maximum values are both 1. Then click Options -> Import Data Range again and choose the other mask. Again, the minimum and maximum values are both 1. Give your output an appropriate name and click OK. You now have 3 masks, one of Deciduous trees on all soils, Pacelot soils under all land covers, and Deciduous trees on Pacelot soils. Arrange these in your viewer so that LANIER.IMG is on the bottom, the Deciduous and Pacelot masks are in the middle and the Deciduous-trees-on-Pacelot-soils is on top. For each of the masks, you now have to make the background transparent. Its really easy. Right-click on the mask name and choose Raster Color Slices. Choose the mask band of the file you want to work on. There are two color swatches, one for value=1; the other for value=0. For the value=1, change the color swatch to the color you want. For the value=0, click on the number 1 in the left-hand column (i.e. the ID number corresponding to the value=0) to choose it; then click on the X icon to delete the color, leaving just one color in the color slice. Click OK. Do this for all 3 masks.

Operations on Immediate Neighborhoods


Many operations with respect to a specific pixel depend not only on the attribute value of that pixel but also of the attribute values of the 8 adjacent neighbors. Slope and Aspect Consider a terrain model such as MTWHITNEY.IMG. The primary attribute for each pixel is the elevation of the point to which it refers. But we can compare the elevation of each pixel with each of its neighbors and calculate both a slope and an aspect (i.e. direction in which the slope faces). Imagine, for example, that you are doing an ecological study of the central Sierra Nevada, and that you wish to determine which areas are likely to be very dry. In order to do this, you need to identify the areas with a southern exposure, so that they are heated most continuously by the sun, and sufficient slope that what rainwater falls on the surface will run off quickly. ERDAS Imagine Click on the Slope and Aspect icons on the Terrain tab to find the slope and aspect, respectively. Use MTWHITNEY.IMG for the input image in both dialogs. Give the output images

suitable (and different) names. Since this only has one layer, and it is a DEM, use the default for this window. When you have generated your images, open two views, one containing each of the two images you have just created and make sure to open them as pseudocolor images. Using the Raster Attribute editor, change the colors so that all slopes greater than 35E (70%) are highlighted, and slopes less than 35E are white and have an opacity of 0. Likewise, change the colors so that all slopes with aspects greater than 140E and less than 220E are highlighted, and those with aspects other than this range are white and have an opacity of 0. Link the viewers, and see which of the steep slopes face south. These are the driest areas of your study area. Given the topography, which is some of the most rugged in the world, is there an easier way to pick out the really dry areas as quickly? ENVI Slope and Aspect are both calculated from tools that appear when you click Terrain -> Topographic Modeling. Note that you can use either the Slope (degrees) or Slope (percent) tool to calculate the slope! Again, use the tools to generate the slope and aspect models. To generate the masks showing the slopes greater than 35E and the aspects between 140E and 220E, click Statistics -> Compute Statistics in the ENVI toolbox. Your slope and aspect images are the input files. Choose Options -> Mask Options from the Compute Statistics Input File dialog and enter the appropriate minimum and maximum values. With ENVI you have the choice of creating two masks, one for slope and the other for aspect, or creating the intersection of these two masks in one pass. You do that by loading both the slope and the aspect images into the Mask Definition dialog, one after the other.

Operations on Extended Neighborhoods


Euclidian Distance Many operations beginning with a single pixel or a single object act not with regard to the 8 neighboring pixels, but rather over the entire image. The most common of these is those operations involving distance. For example, we may wish to examine land cover in the vicinity of ecologically sensitive watercourses. The image LNHYDRO.IMG is a model of the Gainesville, GA area that classifies land areas into several different levels of ecological vulnerability. We will use this image to examine the notion of distance. ERDAS Imagine Load LNHYDRO.IMG into a viewer. Use the Raster Attribute editor to see what this image of the hydrography in the Gainesville, GA area involves. Imagine, for the moment, that you wish to locate a secure landfill in the Gainesville area, and that it is important that it be as far as possible from any hydrologically sensitive area. How far is it possible that you can locate this landfill, and how far is it from the nearest sensitive area? Look at the metadata for LNHYDRO.IMG. What are its height and width in pixels? Now click on Thematic -> Search on the Raster tab. The dialog that opens accesses the distance algorithms in Imagine. Your input image is LNHYDRO.IMG. Give your output image a suitable name. Click on the Setup Recode button. Drag the mouse down the sensitive classes (perhaps classes 1-9, but you might choose another set) to select them, and change their value to 1'. Use the hidden functions to change the other classes to 0'. This is significant. Pixels with a class value of 1' are considered origins of a distance search; those with a class value of 0' are considered pixels to which a distance must be ascribed. In essence, the search algorithm will calculate the distance of any unallocated pixel (i.e. one of class value 0') to the nearest pixel with a class value of 1'. Be sure that the Distance to Search (in pixels) window contains a large enough number that every pixel in the image will be searched. Then press OK. When the process has run, open the newly created image (in pseudocolor). Use Inquire Cursor to check on some of the values. What do the pixel values indicate? Where is the point in the image furthest from a hydrologically sensitive area? If you cant find it easily, open the metadata to find the value. Then display the Attribute Table and change the color of the largest distances in the table.

ENVI Load the LNHYDRO.IMG into your viewer, and save it as an ENVI file. The class names will show up in the Layer Manager window when the save is complete. Then click on Classification -> Post Classification -> Buffer Zone Image. The input file is the ENVI file you just saved. Click OK. Choose all of the ecologically sensitive areas in the Buffer Zone Image Parameters dialog, and give a number of pixels for your maximum distance that you can be sure that all pixels will be included in the search. Again, find the point in the image furthest from the hydrologically sensitive area. Buffer Zones Gainesville, GA is an old city. Much of its expansion predated the environmental consciousness that we now take for granted. It would be interesting to see what sorts of land cover were within close proximity to the sensitive hydrologic areas e.g. Lake Lanier, the streams, and the A zones. Fairly arbitrarily, let us define 240 m as a buffer zone of interest that we would like to set around these sensitive zones. What land covers lie within this buffer zone? ERDAS Imagine Again click on Thematic -> Search on the Raster tab. Use LNHYDRO.IMG as your input image, and give your output image a suitable name. Set up your search exactly as you did in the previous instance except limit your search to the 300 m buffer zone size. To do this, insert the correct number of pixels in the Distance to Search (in pixels) window. What is the correct number? Remember that you are inserting the number of pixels, not meters. If your buffer zone is 300 m, divide 300 by the pixel size in meters (remember that the metadata include the pixel size). This gives you the number of pixels required to give 300 meters. When you run the model, you will get an image in which the images used as the origins of the distance model have the value 0' (i.e. they are 0 distance from the reference object). Points within the buffer zone have a value referring to the number of pixels they are from the reference object. Points outside the buffer zone have a value of 1 more than the number of pixels you entered in the Distance to Search (in pixels) window. Using the Raster Attribute editor, change the color of the background and highest classes to white, and remove the opacity from all classes within the buffer zone. Then load the modified LNLANDC.IMG you created in the first portion of this exercise into the same viewer and use Arrange Layers to put the buffer zone image on top. This shows clearly which land uses lie within the buffer zone. ENVI Again, click on Classification -> Post Classification -> Buffer Zone Image from the ENVI toolbox. Use the same logic as you did with ERDAS Imagine when setting your buffer zone parameters. When you have generated your image, create a mask so that pixels more than 300 m from a vulnerable zone have a value of 1 and those close than 300 m have a value of 0. Then use the Band Slice tool on that mask to remove the slice corresponding to 0. Load the resulting image over the land-cover map.

Questions to Consider
1. Why was it important to open most of the images in this exercise as pseudocolor images? They came up in gray scale anyhow. Couldnt you just as easily have opened them as grayscale images and not had to worry about pseudocolor? Can you think of a way to use the imaging tools within Imagine to visualize what this area looks like? Do they work? Why or why not? Can you think of a way in which you can create a single image to show the portions of the central Sierra Nevada face south and have more than 70% slope? Can you think of a way in which you can use the statistical tools in Imagine to calculate the area of each land-use class within the buffer zone?

2.

3.

4.

Portfolio
Three images should be printed for your portfolio:

1. 2. 3.

The image of the Mount Whitney/Death Valley area showing areas of snow cover and hot temperature. The image showing areas around Gainesville, GA, in which deciduous forests occur on Pacelot soils. The image showing land uses within the buffer zone of 240 meters of streams, Lake Lanier, and other hydrologically vulnerable areas.

You might also like