Geography 481:  Intro to GIS
Project Six: Editing Spatial Databases


One of the most common problems GIS users encounter is acquiring data in a format that is not exactly what they need.  The degree of "not exactly" can vary widely.  An extremely useful skill is the ability to manage and manipulate data so that it does meet your needs.

This project introduces three commonly used techniques for customizing spatial data sets: 1) Projecting geographic files, 2) editing geographic files and 3) joining external attribute files. You start with a map of the lower 48 states and a separate data file containing information about the states. Your goal is to combine the spatial and attribute information and modify it to produce a population density map and other demographic maps for just the eleven western states. You will learn how to permanently delete unneeded features from a shapefile and how to join external attribute files to your database so they are accessible for mapping.


Setup


Changing the Geographic Extent of a Map

You have a problem: the map shows forty-eight states but your project is supposed to cover only the eleven western states. You could set a layer filter to exclude unwanted states from your map. However, it often makes sense to eliminate the unwanted states altogether. For example, you can usually achieve better software performance by isolating only the desired features from the unwanted ones. This strategy is particularly useful when you only want to work with a small subset of the features in a layer or where you are concerned about performance problems associated with excessively large layers.

In this exercise, you will reduce the number of states to eleven by first selecting the ones you want to keep, then copying only those features to a new geographic boundary file, and finally adding the new file to your data frame as a layer for your map.

The initial step is to select the eleven states you want to keep:

If you have trouble locating the eleven states, you should consider taking Geography 332 - United States next semester!

The next step is to create a new data set on the hard disk consisting of only the selected features and their associated attribute records. In this case, that means creating a new shapefile on C:\temp:

At this point you should turn off the us48 layer or remove it from the map.


Adding an External Database File to a Project

Now that you have successfully modified the geographic area, it's time to look at the attribute side of the database. Your goal is to be able to map population density and other demographic variables. Let's check to see what data is in the database:

The only attributes are State_Name and Sq_mi. It looks like you'll have to first add data from an external source before you can map the region's demographics.

It is not uncommon to combine attribute data from one source with a geographic boundary file drawn from another source. Such "external" data files can be attached to the geographic file provided two conditions are met:

In this project, you have demographic data about the 48 states contained in an external file named states.dbf. The original source of the data might have been an Excel spreadsheet or similar file. However, since it was saved out of Excel (or another program) as a type .dbf file, it satisfies the first condition. ArcGIS can read .xls and .xlsx files as well, but with limited functionality.

The second condition is met if there is a field in the external database with contents that exactly match the values found in one of the fields in the shapefile's attribute table. You already know that the us48 and west11 shapefiles include a State_name field in its database.

You can check for the existence of an equivalent field in the external data file by adding the file to your project as a Table and viewing it.

Tables are added in the same manner as layers. 

Note, however, that the table appears differently in the TOC and only when the List by Source icon is selected. Right-click to open the table.

Notice that states.dbf also contains a state_name field. This will become your "join field" provided it contains information (state names) that exactly matches the information in the geographic file's state_name field. Note: the two fields don't have to have identical field names, just identical data values.


Joining an External Data File

So far, you have added the external database to your map project and confirmed that it appears to contain an appropriate join field. You haven't actually joined the new data to your geographic file. To create the join, you need to open the Join Data dialog box for the appropriate layer.

If not already open, open the West11 table. Look at the table then read the paragraph below.

All the fields from States.dbf are now shown as if they were part of the attribute file, but there is no data!  What happened?  The key to what went wrong lies in the requirement that the values (state names) in the join fields must match one another exactly. Check the two tables. If you hadn't already noticed, the state names in the attributes file are all caps; the state names in the states.dbf file are upper and lower case. They don't match exactly. Fortunately, it won't take you long to correct the situation.

First, remove the join:

Next, edit the eleven state names in the "attributes" file to upper and lower case:

Now, repeat the join process. This time you should see the demographic data for the 11 western states displayed in the appropriate cells. Note: you haven't actually added the data to the attribute file. Rather, you have temporarily "joined" it so you can work with the data as if it were physically attached. Also NOTE: Data failing to match during this process is more common than you would like. It can happen for the entire dataset like you saw in this example or it could be just a few records so look around. Typos, an extra space, and other inconsistencies can be extremely "exciting" to track down.


Projecting Latitude and Longitude Coordinates

Because the data frame contains unprojected latitude-longitude spatial data, you see a distorted view of the western states. To create a more balanced (not to be confused with "fair and balanced") view of the map, you should project the map coordinates. You will learn more about projecting map coordinates in Project 7. For now:

Now you should see a less distorted shape for the US map but there is still one problem: north is located toward the upper right of the page, not the top of the page. The reason for this is that the projection you chose is optimized for viewing the entire US and therefore has a central meridian located in the center of the country. You need to change the central meridian so that it is located in the center of the Western US

How does that look?


Combining Data from Two Joined Files

There is one final problem to address before you can map population density. The population values were in the states.dbf file while the area values were in the West11 attributes file. Now create the population density field that combines data from both fields:

You have successfully used data from the two files to create a new variable for mapping.

A Question: You know that the area data (Sq_mi) for each state is stored in the attribute table for west11.shp (west11.dbf) and that the population data (Pop2010) is stored in states.dbf. You also know that after you join the tables properly, the two data tables are not physically attached, they just look that way. Here is the question: Where is the new Popden data stored and how can you tell? What do you think will happen to Popden if you were to remove the join? Try it and see.


Exporting Projected Data

To complete your project, export a copy of the dataset to a new file. Once the copy is made, the two joined tables will be combined on-disk into one layer attribute table and the question of where the new field is located will no longer be an issue. This will also allow you to save the layer using the projected coordinates. In principle, this should be quite seamless.  However, I encountered some “excitement.”  If the procedure below doesn't work as expected, let me know. 


Mapping Population Density

All that remains is to create a thematic map of population density. That should be the easiest part of the exercise. Create a layout and include all the usual suspects - title, legend, north arrow, etc. Do you have enough information to produce an accurate scale bar? If so, include one. Be sure to select the correct data frame. Save your work! This is one of the items you will be submitting for this project.


Need more practice?

Of course you do.

In addition to the Population Density map, also create the following three (3) maps. Please print all 4 maps on two (2) pages.

These three maps will help you join files and introduce you to the vast quantities of data available from ESRI and other sources.

1. Use the data on esri_data on Geogsrv to create a map of the percent Hispanic for the counties of the 11 western states. Use the dtl_cnty data on Data_Maps_Newest\usa\census\

2. Then make a map of Oregon Counties showing which counties have more registered democrats vs registered republicans. The voter registration data is in the oregon_voters.dbf file in the proj6 directory.

3. Finally, use the esri_data on Geogsrv to create a map of 2017 Median Household Income for the Census Tracts in Orange County, California. Use the CFY17 Demographics Complete geodatabase on Data_Maps_Newest\2017 Demographics\fgdb\

Just to sum up, you need to turn in 4 maps on two pages.

Good luck.


Head Start

Project 7 is somewhat elaborate so it is helpful if you get a head start by working on the following 2 items.

  1. We will continue using the new data format called a geodatabase introduced briefly in Project 6. We will be using a specific type known as a File Geodatabase. In a geodatabase, the vector data we have been using in our shapefiles is stored as feature classes. Like shapefiles, a feature class can contain point, line or polygon features that have the same attributes and spatial reference. Numerous feature classes can be stored in one geodatabase. In addition to feature classes, geodatabases can also store rasters, tables, annotation and other data types. Additionally, geodatabases allow users to create subclasses and domains, relationships, geometric networks, behaviors and topologies. I have included a file geodatabase version of the data for Project 6. You should try it out.
  2. Please work on Project 7a before our next class. Data and instructions are posted on Canvas. There is nothing to turn in for Project 7a, but understanding projections will be crucial in Project 7 and will, in all likelihood, be a source of "excitement" when working on your individual projects. Please let me know if you encounter any issues.

Last modified 10/19/2021