Lab 3.2: The Raster Data Model

Note: This laboratory requires the ArcView Spatial 3D Analyst extension. A trial version of this extension is supplied on the CD with the text. If you have not yet registered the extension, you will need to do so before completing this lab.

The Raster Data Model. The raster data model is quite different from the vector data model which we explored in the previous lab. Space is treated as a continuum in which values represent the magnitude of an attribute in space. Attributes that are thought of as being continuous such as rainfall, air temperature, or pressure are frequently represented as raster data. In this lab, you will create a raster file by hand, and convert this text file to spatial data.

Digital Elevation Models. Digital Elevation Models (DEMs) are raster representations of the surface of the earth, and can be used to create three-dimensional views of the surface of the earth. DEMs are provided by the United States Geological Survey (USGS). Several types of surfaces, such as slope and aspect, can be derived from DEMs. Both of these types of surfaces are used in a variety of GIS applications ranging from fire modeling to urban planning. You will use the ArcView Spatial Analyst extension to derive slope, aspect, and hillshade for the DEM.

Deriving Vectors from Rasters. In addition to deriving surfaces from the DEM, vector contour lines can also be calculated using the Spatial Analyst extension. Contour lines are often easier for people to interpret than raw DEMs, and so are useful both for map production and digital data visualization. You will learn how to create contour lines from the raster DEM.

Accuracy and Resampling. Raster data are often preferred because of the potential for greater spatial accuracy. The accuracy of these data depends on the size of the cell. Cellsize can be increased using a process called resampling. When data are resampled, data is generalized and the original data values are frequently lost, but it may be necessary to resample data if your files are too large. In this lab, you will resample your DEM, and consider some of the tradeoffs.

Creating ASCII Raster Files

Now we are going to create several ASCII files that we will later import into ArcView. An ASCII file is simply a text file that you will produce in a word processor. Open the text editor provided on your machine. If you are working with the Windows95, Windows98, NT, or 2000 operating systems, you will be using Wordpad, or Notepad. Type in the following text:

ncols 15

nrows 10

xllcorner 50

yllcorner 50

cellsize 100

nodata_value -9999

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

0 0 1 0 0 0 0 0 1 0 0 50 50 50 0

0 0 1 0 0 0 0 0 1 0 0 0 1 0 0

0 0 1 0 0 0 0 0 1 0 0 0 1 0 0

0 0 50 50 50 50 50 50 50 0 0 0 1 0 0

0 0 1 0 0 0 0 0 1 0 0 0 1 0 0

0 0 1 0 0 0 0 0 1 0 0 0 1 0 0

0 0 1 0 0 0 0 0 1 0 0 0 1 0 0

0 0 1 0 0 0 0 0 1 0 0 50 50 50 0

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

The first 6 lines of this text file are the “header” of the data file, and contain instructions for formatting the data matrix that follows. Now save the file to the folder with your data for this lab as a .txt file.

Notice the location to which the file is saved. Using Windows Explorer or trough the “My Computer” icon, go to the directory in which the document resides. Right click on the icon for the file. Select rename.

Note: If the file extension (.txt) is not visible for the file, in the main menu select Tools -> Folder Options and uncheck the box that says “Hide file extensions for known file types.” Now you should see the .txt extension on the end of your file and you can complete the steps to rename the file.

Change the extension from ".txt" to ".asc". This will change the file from a Text file to an ASCII file. Both ASCII files and Text file are files that are unformatted, but for ArcView to create a Raster layer from the file, it must be an ASCII file.

Copy and paste the file so that you now have two additional copies of the file, naming them appropriately, e.g. "raster.asc", "raster2.asc", and "raster3.asc". Edit the second file so that the data matrix is entirely on one line, with single spaces between values.

ncols 15

nrows 10

xllcorner 50

yllcorner 50

cellsize 100

nodata_value -9999

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 50 etc.

Edit the third file so that the header looks like this (the data matrix can look like either the one in your first or second data file):

ncols 15

nrows 10

xllcorner 0

yllcorner 0

cellsize 10

nodata_value –9999

Creating a Raster Grid From an ASCII File

Now we will create raster grids from these files. Start ArcToolbox.

In ArcToolbox select Conversion Tools -> Import to Raster -> ASCII to Grid.

In the window that opens, enter the location of your ASCII file in the “Input ASCII file” text box. Select a name for your output Grid file and enter it in the “Output Grid” text box. Make sure that the Grid type is set as “Integer.”

Since we want to convert each of the three files that we have made to raster Grids, we can use the “Batch” command to convert them all at once.

Click on the Batch button. You will notice that there is a new item in the window showing the file information that you just entered as the first item in your “batch.” To add new items to the batch, click on the “Add row” icon (circled in red in the image below). When you have added a new row, follow the same instructions as above to enter your second input ASCII file and select an output grid. Do the same for all of the files that you want to convert, and then press OK to process them all.

Question: Do you think that batch processing useful? Why or why not?

Now open ArcMap and add all three of the raster layers (grids) that you just created.

Question: What do you think the ascii file header lines mean?

ncols ?

nrows ?

xllcorner ?

yllcorner ?

cellsize ?

nodata_value ?

Question: Given the amount of time it took to create these very small ASCII raster files, how practical do you believe manual data entry would be for large raster data sets?
Question: Can you think of two alternate ways to capture raster data?
Question: What effect do you think a smaller cellsize would have on the accuracy of geographic data?
Question: Would you rather work with larger or smaller cellsizes? Why? Can you think of two reasons to prefer larger cell sizes to smaller cellsizes?

Working With Digital Elevation Models

Now that you have created some simple raster data sets by hand, we will work with an already created Digital Elevation Model (DEM). Using the Import to Raster -> DEM to Grid tool in ArcToolbox, import the san_marcos.dem file that is included in the data folder for this lab. This DEM covers the area of San Marcos Pass, California. Make sure the Grid type is set to “Float.”

Question: Why do we want the Grid type to be “Float” for this data when we used “Integer” for the ASCII raster files that we created?

When you have created your new raster layer, open ArcMap and add the new raster layer. It should look something like this:

Open the Properties window for the San Marcos raster layer.

Question: Describe the Source tab for the San Marcos raster layer. What type of information about the layer is available here?
Question: What do you think are the legend units for elevation for this data set? Are you certain? How do you think that you could find out?
Question: How could a lack of information about spatial or attribute units be a problem in GIS?

The DEM that we are using can be used to derive several other surface products. You will derive slope and aspect surfaces, and create a hillshaded model of the DEM. Your current view should look like the above graphic. Spatial Analyst in ArcMap will be used to calculate a slope surface, and place this new theme in your table of contents. Make sure the Spatial Analyst toolbar is turned on. If it isn’t, click on View-> Toolbars-> Spatial Analyst. If the options in the toolbar are not available (“greyed out”), make sure the Spatial Analyst extension is turned on. Click on Tools -> Extensions and make sure the box for “Spatial Analyst” is checked.

In the layer box in the Spatial Analyst toolbar, make sure that the San Marcos raster layer is selected. Click on the “Spatial Analyst” drop down button and select Surface Analysis -> Slope. Change the output raster so that it is saved into your working folder, name the file “sm30m_slope.” Click OK.

Question: Since the slope data is derived from the DEM data, describe the relationship between errors in the DEM and the accuracy of the slope data.
Question: How could this sort of error propagation be a problem in GIS?
Question: Do you think that you could recognize errors in the slope data just by looking?

Click on the Spatial Analyst drop down button and select Surface Analysis -> Aspect. Make sure that the San Marcos raster layer (not the slope raster that we just created) is the Input Surface. Set the output raster so that it is saved into your working folder and name the file “sm30m_aspect.” Click OK.

Question: What are the units of measurement on the aspect legend? Why would a flat area not have an aspect attribute?

Now select Surface -> Hillshade from the Spatial Analyst drop down button. Make sure the San Marcos raster layer is your Input Surface. Save the output rater as “sm30m_hill.”

Now we will change the analysis cell size and examine the effects. Click on the Spatial Analyst drop down button, select Options. Switch to the Cell Size tab and change the Analysis Cell Size to “As Specified Below,” and specify 100 as the cell size.

Calculate a second hillshade. Save the output raster as “sm100m_hill.”

Question: What are the differences between the 30 m and 100 m hillshade?

Question: When doing analysis based on raster layers, what effect do you think altering the resolution would have on the results?

You will now use your DEM data to calculate a vector layer of elevation contours. Select Surface Analysis -> Contour. Make sure that your Input Surface is the San Marcos DEM, the contour interval is 100 meters, name your output “contour100m.”

Now change the Analysis Cell Size back to 30m. Create a new contour layer with contour intervals of 100m, name your output “contour30m.” Make certain that the contour layers have different, contrasting symbol colors. Zoom in on your view and inspect the two vector themes.

Question: What are the differences between the two contour layers?

Question: What are the trade-offs in selecting cellsizes, and contour intervals? Do you think that there is a single correct answer to the question, “What is the best cellsize for spatial analysis?”

Conclusion

In this lab you have learned to create a raster data layer by converting a text file to spatial data. In addition you have imported USGS DEM data into ArcView. You have explored some of the features of the Spatial Analyst extension, creating derived surfaces from your DEM. Finally you created vector layers derived from raster layers in the form of elevation contours. Important themes in this lab are the effect of resolution and scale on these surface calculations. Underlying issues of accuracy, and data generalization were explored.