Geography 387 Lab Home | Geography 387 Home | Geography Home Lab 3: Working with Attribute DataOutline
1.0 PurposeIn this lab you will strengthen your ArcGIS skills from previous labs and begin to work with attribute data. First we will download GIS data from the National Atlas, import metadata, define a projection and project the data to a new layer. Next, we will explore many aspects of attribute data in ArcGIS, including how to select records with queries, add new fields, calculate new values based on an existing field, and create classified maps and graphs based on attribute values. 2.0 Get the dataMake a Lab 4 work folder in your workspace, then go to the following web site: http://nationalatlas.gov/
The webpage may look different than the screenshot above because the National Atlas is a dynamic site, which changes its "What's New" section regularly. Click on the "About" link below the search window at the top. Read through the description of the National Atlas and answer the following question.
We are now going to download a GIS layer from the National Atlas site. Click on the "Mapping Professionals" in the blue bar at the top right. Read the information about "Raw Data" and "Raw Data Documentation". Now answer the following questions:
We are now ready to download the a raw GIS data layer from this site. First click on "Raw Data" icon.
You will see a series of themes (e.g., Agriculture, Biology, Boundaries) that are used to group the raw data. Click on the Boundaries tab. Several GIS layers are available for download. Each layer occupies a row in the table. Locate the "County Boundaries, 2001" row in the table and right-click, select "Save as..." on the "countyp020.tar.gz" Shapefile in the "Format and Raw Data Name" column. This will download the a shapefile in a compressed (Gzip) format. Note: if the National Atlas server does not respond, then just click here to get the data archive.
3.0 Explore the data in ArcCatalogDecompress the contents of this file archive to your Lab 3 folder. Ask your intstructor for help if you can not decompress the archive's contents. Examine the contents of the archive in Windows Explorer. Now open ArcCatalog and preview the geographic and tables information for the countyp020.shp Shapefile. Also examine the Metadata tab. Now right-click on the Shapefile in the Catalog Tree and select "Properties". In the Field tab, you will see the names of all the fields (columns) in the Shapefile's attribute table. This is the window where we set the projection information for the USA48.shp layer in Lab 2 (remember doing this in ArcCatalog?).
You should have noticed in the Metadata tab that none of the description fields were filled in. We have to import the metadata from an auxilliary text file (TXT) contained in our Gzip archive. You should see this text file appear in the catalog tree of ArcCatlog with a special text file icon.
Open this file directly from ArcCatalog by double-clicking it. This opens the provided metadata in a default text editor. Browse the information in this metadata file. Look for the section entitled "Spatial_Reference_Information:" and answer the following question:
We can now import the metadata from the text file into a format that is available to read from the Metadata tab (ArcCatalog needs to convert the (.txt) text format to a XML (.xml) file format). Click on the countyp020.shp Shapefile in the Catalog tree and go the Metadata tab. There should be a series of tools available in the Metadata tab. Some of these tools may look familiar... we saw them at the beginning of Lab 1. Select the appropriate tool for importing metadata. Select the format for "txt" files and import the metadata from "countyp020.txt". You should see many of the fields now contain information in the metadata tab. Explore the metadata to answer the following questions:
We would like to define the projection/coordinate system using the information from Question 7. Using your skills from Lab 3, proceed to define the projection. In this case, we are not going to import the projection/coordinate system information from another Shapefile. Instead, you should select a predefined coordinate system and navigate to the "North American" folder. There you will find a "North American Datum" (NAD) that matches your datum in Question 7. This will create a ".prj" projection file for your Shapefile. Be sure you can locate this in your working directory as this is one of the lab deliverables. Click "F5" to refresh ArcCatalog and verify that your projection information has been updated in the "Spatial" tab of the metadata. 4.0 Selecting attributes in ArcMapWe will now explore working with attribute tables in ArcMap. Load the countyp020.shp Shapefile in ArcMap.
For the purpose of this lab, we are only going to focus on the 48 conterminous states. We will create a new Shapefile by first selecting the 48 states. We can do this by opening the countyp020.shp attribute table. Do you remember how to do this? If so, open the table.
If you do not remember...you right-click the Shapefile and select "Open Attibute Table".
Right-click on the "Options" button at the bottom right of the table and select "Select by Attributes". You should see a new window appear:
Using your notes and lecture presentation on attribute data, build a query to select polygons from the 48 conterminous states. Use the default "Create a new selection" method. You can double-click the appropriate field name to get it to appear in the SELECT window. Once you select a field, you can press "Get Unique Values" to show all possible values for that field. Do not click Apply just yet. You will need a combination of Set Algebra (i.e., =, <, >, <>) and Boolean Logic (i.e.., AND, OR, NOT). It is easiest to build your query by selecting all polygons that are not conterminous states (Alaska [AK], Hawaii [HI], Puerto Rico [PR], and the Virgin Islands [VI]). Also exclude from your selection any polygon that does not have a county name (use "COUNTY" <> ' '). You can save your query with the "Save..." button. Select the text in your query and do a right-click then "copy". Paste your query into the follow question box in your answers:
Go ahead and click apply. You should see polygons from the 48 conterminous states highlighted in light blue. Be sure that there are no polygons selected in the Great Lakes (polygons with no county name). If you did not get the query right, go back and try another query. You can always load your last query by clicking the "Load..." button in the query window (that is, if you remembered to save it before clicking Apply).
Now we can export the selected polygons to a new Shapefile. Right-click countyp020.shp and select Export Data
Leave the default "Selected features" option since we want to export only the selected polygons. We will use the "layer's source data" coordinate system. Give your output Shapefile an appropriate name.
Click "OK" and add the new Shapefile to the data frame. Turn off the "countyp020.shp" Shapefile. Zoom to the extent of the new Shapeifle by right-clicking your new Shapefile and selection "Zoom To Layer". We will no longer use the countyp020.shp Shapefile. You can remove it from your ArcMap map document by right-clicking countyp020.shp and selecting "Remove". This removes the layer from ArcMap, but it is still physically present in your work directory. 5.0 Calculating and Displaying AreaWe now are going to make a map that displays the area of each State. We do not want display the area values in the units of the Shapefile (see Question 7). Area in square units of the current coordinate system do not make much sense. Remember from Lab 2 that we can calculate the area in convenient units, like square meters, by projecting the layer to a planar projection. Remember how we did that? We reprojected the shapefile by changing the data frame and then we selected "data frame" option for the output coordinate system in the data export window. There is an easier way to reproject a vector feature class. You can use ArcTools! Look in "Data Management Tools", then "Projections and Transformations", then "Features", then select the "Project" tool. (NOT "Define Projection" - that tool defines the coordinate system information if it was missing, like you did in ArcCatalog).
Either of these layer projection methods, ArcTools "Project" or using the Data Frame/Data Export approach from Lab 2, will give you a projected Shapefile. Chose a method and project your Shapefile to the "USA Contiguous Albers Equal Area Conic" projection that we used in Lab 2. We could now calculate the area of the States field like we did in Lab 3 but there is one problem. We do not have State polygons. Instead we have polygons representing subdivsions of States (see Question 5). We will need to grounp polygons by State and dissolve their boundaries. This process will give us polygons representing states. We can do this with a very useful tool called "Dissolve". Open this tool in ArcTools. It is under "Data Management Tools", then "Generalization". Read the help to the right of the tool window to get a better understanding of the process. When you are ready, use your Albers-projected Shapefile as the input and give your output Shapefile an appropriate name. Click the "State" field as the "Dissolve_Field". Click "OK".
Close the tool and turn on your new dissolved layer. You should see that the small polygons in the input layer have been dissolved into larger polygons representing states.
Open the dissolved Shapefile's attribute table.
We now need to calculate the area for each polygon. First we need a new field to hold the area calculation. Go to "Options", then "Add Field". Type in "Area" for the Name and "Double" for the Type. Click "OK". This adds a new field to the table.
Use your skills from Lab 2 to calculate the Area field in the attribute table. Calculate area in square meters. Make another field, but this time name it "Hectares" and set its field Type to "Long Integer". Calculate the area for each polygon in hectares. Remember that the Area column has units of square meters (m2) and there are 10,000 m2 per hectare. The calculation is done by selecting the new Hectares column and then selecting "Calculate Values...". Click "Area" in the fields window and then in the white window below the "Hectares =", type in "/ 10000" after the "[Area]". Then click "OK". You should have a new column with the area for each polygon in Hectares. Notice how the hectares values are rounded to the nearest whole integer. This is because we chose "Long Integer" as the field type, rather than "Double", which is a real number (floating point) data type with decimal precision.
6.0 Make a Classified Map of State AreaRight-click on the dissolved Shapefile and click on Properties. Go to the Symbology tab and select "Quantities", then "Graduated Colors". Select the "Hectares" field for Value. Click on the "Classify" button and chose "Natural Breaks " for Method. Notice that the classify window has statistics (e.g., minimum, maximum, mean, etc) and a histogram with class break points. Change the color ramp to a color scheme of your choice. You should experiment with the other methods for determining the classification breaks (divisions between classes). We will learn more about map classification in the next lab.
7.0 Create a Bar Graph of State AreaFinally, we are going to learn how to use the Graph tool in ArcMap. This tool allows you to make graphs of the data in an attribute table, much like you would do in Excel. In this exercise we will make a bar graph of state area in hectares. Go to "Tools" in the main tool bar of ArcMap, then "Graphs", then "Create". Adjust the parameters so that they match the screenshot below. As you change parameters, notice how the graph in the right side of the window is affected. You can chose any color scheme that you want, but match the other parameters to this example. Here the color scheme is set to "Rainbow".
Click Next.
Change the title of the graph to something reasonable, for example "Area of the 48 Conterminous States". Match the rest of the parameters as shown in the screenshot, but take notice of what those parameters do. When you are done exploring, select "Finish". Notice that the graph's Y-axis labels skip every other state. We need to change this so that every state is labeled. First start by stretching the graph window so that it is longer, as shown below. The extact size does not matter, but we want to make room for the extra lables. Now right-clicking on the graph and select "Advanced Properties...". Click the + next to Axis to open the Axis properties. Select the "Left Axis" (Y-axis), then select the "Labels" tab, then set the minimum label separation to 0%.
Feel free to explore the Graph Wizard's advanced parameters. You will find that there are many ways to make your graphs look professional and customized for your particular needs. When you are done exploring, click "Close". You may have to stretch out your graph's window to see the graph's information properly. When you are have sized your graph, right-click on its window bar and select "Export". Export the graph to a JPEG (JPG) image format. Use the "Save..." button to save your graph image file to your Lab 4 directory.
Note: the final graph can be added directly to the map layout, so that you can have a map of geographic data along with the graph. This can be done by selecting "Add to Layout" instead of exporting to an image. 8.0 ConclusionsIn this lab you learned how download data from a web page with GIS data, explore and define its projection information, and import metadata. You then learned how to select a subset of the data based on an attribute query, and then you exported the selected set to a new GIS layer. From there, you used ArcTools to project the new layer to a projected coordinate system. You also learned how to generalize the layer with the dissolve function. You learned how to add new fields for holding the values of custom calculations. Finally, you created a classified map and bar graph from your calculated values. 9.0 To turn in
Submit electronic files via email to klacefie@sonoma-county.org, with the subject "G387, Lab 3, [your last name]". Remember to put your last name before each file name (e.g., clark_county020.prj). We will deduct 0.5 points for each file not properly named. Be sure to save all of your Shapefiles in a safe place! We will continue to work with this data in future labs. This lab was designed by Matthew Clark, Geography and Global Studies Department, Sonoma State University. This page was last modified on Sep. 3, 2008 by Matthew Clark
|