The Scenario You have been hired as a GIS consultant with the county school board. They need to get a better idea of where school age children live and where they should consider building additional schools. Exercise 5: Working with tables In many cases, you will find that the attribute tables associated with your feature classes lack some fields that you would like to use. However, you may find that the data you wish to use is found in another, related table. This is common in census data, assessor s parcel data and, soil data. In some cases the attribute data is removed from a feature class to protect sensitive data. In other cases, the amount of information that could be in the attribute table would make the file size extremely large. In this exercise you will work with joining data to a shapefile and explore the functionality of the relationship between spatial data and tables. In this exercise you will: create a join based on a common attribute select data based on attributes export selected features to a new shapefile perform various field calculations on attribute data
Creating a Join 1. Open an ArcMap document and begin a new, blank map. 2. Add the following layers to your map document. CA_census_tracts.shp Census_tract_data.dbf The.dbf file has no spatial representation. It is only tabular data. You will note that when you add tabular data to your ArcMap document, the Table of Contents window will revert to the source tab. 3. Preview the attribute table for the shapefile and open the.dbf file. You will note that the shapefile attribute table is very limited in the amount of information it provides for each census tract. The.dbf file contains most of the population-related information. 4. In the Table of Contents, Right click the CA_census_tracts shapefile name and select Joins and related/join. This will open the Join Data dialog box. Source view in the Table of Contents 4 Page 2
5. Using the drop down menu, select FIPS for the Join field option. Since only one table is present in the map document, it appears, by default, in the Table field. 6. Using the drop down menu, select FIPS for the Table field option. 7. Click OK to complete the tabular join. 8. Using the Identify tool, investigate the attributes now provided for each feature in the map. You will note that attributes for both the shapefile as well as the.dbf table data are present. 5 Exercise 5: Working with tables 6 7 Page 3
Select by attributes Before you are able to complete this task, you will need to determine what the county FIPS code is for your county. This information is found in the CA_Census_tracts.CNTY_FIPS field in the attribute table. 1. Add the county outline feature class you added to your GIS county data library in exercise 4. Your county layer, although it might be in a different spatial reference, should overlap the state in the correct location. If this is not the case, you may need to refer to the spatial reference material found in Exercise 5. 2. Right-Click name of your county boundary in the ArcMap table of contents and select Zoom to Layer. 3. Using the check box in the table of Contents, turn off your county boundary layer. 4. Using the identify tool, identify one of the census tracts in your county. In the Identify dialog box, you will find the CA_Census_tracts. CNTY_FIPS field with the corresponding FIPS code. Every census tract in your county has that same code. Make note of that code. 5. Close the Identify dialog box. 2 County FIPS code Page 4
6. On the Main menu, click Selection and Select By Attributes. This will open the Select by Attributes dialog box. 7. In the Layer field, select CA_Census_Tracts 8. In the Method field, select Create a new selection. 9. In the table field window, double click CA_Census_tracts. CNTY_FIPS. This will begin to populate the Select code window. 10. Click the Equals (=) button. 11. Click the Get Unique Values button. This will populate the window above the button with all values for that particular field that are found in the attribute table. 12. Scroll up and down the list of values, and double click the FIPS county code for your county as noted in step 5 above. 13. Click OK to select all census tracts in your county and close the Select by Attributes dialog box. All of the census tracts within your county will be selected. 9 10 Exercise 5: Working with tables 6 7 8 12 11 13 Page 5
Export selected features In this task, you will export out the selected features to a new shapefile. 1. In Table of Contents, right-click the CA_Census_Tracts field name and select Data/Export data. This will open the Export Data dialog box. 2. In the Export option field, be sure that Selected Features is highlighted. 3. Leave the radio buttons for Coordinate system options at their default values. 4. Navigate to the folder where you would like to store the new shapefile and provide a file name. 5. Click OK to export the selected features to a new shapefile. After the new Shapefile is created, a prompt will ask if you wish to add the new shapefile to the map document. 6. Click Yes to add the new shapefile to the map document. 7. Turn off or remove the CA_Census_tracts shapefile from your map document. 8. Using the Identify tool, investigate the attributes provided in the new county-wide census shapefile you just created. You will note that the attribute table contains data from both the original shapefile as well as the joined table. This data is no longer joined, but has been migrated in to the attribute table of the newly created shapefile. 1 2 4 5 Page 6
Viewing field statistics 1. Open the attribute table for your county census data shapefile. 2. Scrolling back and forth, find the field name entitled POP2000. 3. Right-click the field name POP2000 and select Statistics This will open the Statistics for Feature class dialog box. 1 Based on the field type, this window will vary in display. However, if the field type is a numeric value, the Statistics window will display the following: Count: The total number of features Minimum: The lowest value Maximum: The highest value Sum: The total value of all features Mean: The average value Standard Deviation: The extent to which values ranged from the average 3 Page 7
Creating a new field 1. Click the Options button on the attribute table and select Add Field. This will open the Add Field dialog box. 2. In the Name field, type K12_RATIO 3. In the type field, select Double from the drop down menu. 4. Leave the Precision and Scale values at their default values. 5. Click OK to create a new field in the attribute table. A new field will appear on the far right side of the attribute table. The field values will be blank. 1 2 3 5 Page 8
Using the Field Calculator In this task, you will populate the new K12_RATIO field with the ratio of school-aged children with the total population. Before you begin, be sure that all features are unselected. 1. Right click the K12_RATIO field name and select Field Calculator. A prompt will inform you that you are beginning to edit the table outside of an edit session and that any changes you make cannot be undone. 2. Click Yes to continue to the field calculator. This will open the Field Calculator dialog box. 3. In the Fields window, double click AGE_5_17. 4. Click the divide (/) button. 5. In the field window, double click POP2000. 6. Click OK to run the field calculation. The field will be populated with a value representing the total number of children with ages between 5 and 17 divided by the total population, a ratio of school-aged children. 5 1 4 6 Page 9
7. Right click the K12_RATIO field name and select Sort Ascending. Those census tracts with the lowest ratio of school-aged children will appear at the top. The highest numbers appearing at the bottom. 8. Scroll to the bottom of the attribute table. 9. Select the feature in the attribute table that has the highest ratio of school age children by clicking the small box on the far left side of the row in the attribute table. 10. Minimize the attribute table. On the map, you can see the location with the highest ratio of school children. Be sure to save your county census shapefile, as it will be used in future exercises. Exercise 5: Working with tables 9 Want More? Using the select by Attributes tool, try to select all of the census tracts with over 25% school age population. Symbolize your shapefile based on the ratio of school age children. 8 Page 10