L7 tablesArcPro
L7 tablesArcPro
You should read chapter 8 in the GIS Fundamentals textbook before performing this
Lab.
Data: are in the \Lab7 directory, with census data USCounties.shp in a continental
Albers projection, and soils.shp in UTM Zone 17, NAD83 meters coordinates. (note
make sure you have the most current version of USCounties.shp.
What You’ll Produce: Three maps: two of selections based on census data, and one of
a soils data set. You’ll also produce a table of soil properties.
Background: Most spatial data in a GIS consist of at least two types of data: those data
depicting the location and shape of objects, and text or numerical data describing the
objects. These text and numerical data are most often contained in tables, and most
GIS packages have some way of creating and editing these data tables.
ArcGIS - provides a rich set of tools for viewing and displaying attribute data. However,
you don’t have as many options for manipulating and saving table data, as with a full-
featured database manager, so we’ll do some rather simple operations in this lab.
Select by Attribute
Last week we selected rows manually by combinations of clicks and shift clicks on
sorted rows. While sometimes this is the fastest and easiest way to select a set of
features, more often we use a more complex query to select features. We’ll do some
selections using a query builder.
Start ArcGIS, and Add the data layer USCounties.shp to a new, empty project.
Most of the headings are somewhat descriptive and describe statistics from the decadal
U.S. Census for a period near the year 2000. These were pulled from various
collaborating federal organizations and include population and crime. These data were
all collected for county areas and referenced with a combined state-county FIPS code,
which is unique for every state/county combination.
1
GIS Fundamentals Lab 7 Table Operations
For example, POP2000 is the county population estimate for the year 2000,
Med_Age is the median age of the county population, BURG01 is the number of
reported burglaries for 2001, CropAcres is the number of acres of cultivated cropland in
the county, and Cows is the total number of bovine livestock in the county.
Make a few practice maps that you don’t need to turn in, to get to know the data, e.g.,
Median age by county, from 31.7 (brown) to 54.3 (red):
2
GIS Fundamentals Lab 7 Table Operations
3
GIS Fundamentals Lab 7 Table Operations
4
GIS Fundamentals Lab 7 Table Operations
When you displayed the table a Table View group appeared along
the top ribbon of the main window. Find it, and then click on the
Select by Attributes tool (see figure at right).
We can query the data via the Select by Attributes tool:
You build the clause by populating each of the windows through a combination of
selections from dropdowns and from manually typing values, as needed.
5
GIS Fundamentals Lab 7 Table Operations
If I click on the caret at the right end of the leftmost window – the one that contains FID
in the figure above – a
dropdown displays the table
variables:
You then type the threshold for selection directly in the rightmost window (below arrow):
6
GIS Fundamentals Lab 7 Table Operations
Display only
selected
Display
records
All
Again, data are collected by state agencies for most states, so variation in methods and
definitions between states can lead to odd differences at state boundaries. The simplest
comparisons are within state, although cross state differences can be conducted with
proper adjustments.
7
GIS Fundamentals Lab 7 Table Operations
Suppose we’re interested in how easy it is to rent a house, and so you want to map
counties by vacancy rates. If we look at the variables in the table we note that although
there are total number of housing units, and a number of vacant units, vacancy rates
are missing. We must calculate it.
Here, we’ll define it as the total number of housing units vacant, divided by the total
number of housing units, multiplied by 100. We need to create this normalized column,
as before.
Create a new variable called VacRate using the above (pg.3) and last week’s exercise
for guidance (use Float for type), and calculate an appropriate value into VacRate (like on
pg.4). Your formula should look something like:
Verify you did this correctly by checking that your statistics show a minimum vacancy
rate of about 1.53% and maximum of 77%. Your map of vacancy rates should look
something like that below when displayed with a quantile symbology and 10 classes.
The lowest rates should be on the coasts, the Upper Midwest, and in counties
containing large cities:
8
GIS Fundamentals Lab 7 Table Operations
This opens another clause builder window, into which I enter the following:
9
GIS Fundamentals Lab 7 Table Operations
10
GIS Fundamentals Lab 7 Table Operations
Your task is to identify counties with a large number of older aged people relative to
younger aged people, based on the data in the USCounties.shp data layer we’ve been
using. (Remember to Clear any selected fields before continuing)
Create and index variables in the table that is the ratio (People over 65) / (people 21
and under) * 100
Select counties that have a value for this ratio that is over 85, and a total population that
is over 150,000.
This selected set should contain 13 counties; 11 total in Florida, one in Arizona, and 1 in
Massachusetts.
Save the selected counties to a new data layer. (consider saving as a shapefile; such as
oldcounties.shp; remember SHAPEFILES cannot be saved in a Geodatabase, choose a folder for output like \Lab7).
Use both oldcounties.shp and USCounties.shp and create a layout that is similar to that
below.
11
GIS Fundamentals Lab 7 Table Operations
Make sure to
symbolize the 13
identified counties
in a contrasting
color so that they
stand out. Your
Age Index
categories don’t
have to exactly
match those
shown but should
be close.
Create a PDF of a
Layout and turn it
in on the class
Canvas website.
12
GIS Fundamentals Lab 7 Table Operations
We often manage tables separately and join them as needed on common fields for
combined analysis. We’ll cover how to join tables in ArcGIS Pro.
Create a new project, add a Map, and Add the layer (which is also called a “theme”)
demographics.shp from the Lab 7 folder. Also add the data table name more_data.dbf
Notice that both tables have an item named Blkgrp. This item can serve as a key for the
join. As described in the book, the join will match rows by these key variables, to
display a combined table.
Use the scroll bars at the bottom of each table to look at all the variables (columns) in
each table.
Are the variables ordinal, nominal, or interval/ratio? Which other variables are found in
both tables? Which variables might serve as keys for the table, and which would be
inappropriate as keys? See Chapter 8 in the textbook, if you’re unsure on these
concepts.
Each record (row) in each table corresponds to each polygon in this US Census Bureau
demographic data, displayed in demographics. These files were produced from U.S.
Census data, which uses a variable named Blkgrp as unique identifiers. The codes
correspond to groups of city blocks, and identify polygons used to summarize census
data. Each record in our tables corresponds to a block group.
13
GIS Fundamentals Lab 7 Table Operations
Also note that the like-named variables in this instance should be avoided, because
they’re not the same type and/or don’t hold compatible data. Examine the various items
that start with BLKGRP, but make sure you are joining demographics to the more_data
file and using the field Blkgrp, not a field called Blkgrp_.
14
GIS Fundamentals Lab 7 Table Operations
You may get a warning asking if you wish to create an index, accept the
recommendation. (Note: if you map disappears, select Symbology, and under Primary Symbology, choose
“Unique Values” and then switch back to “Single Symbol” and you map will reappear: This is a bug)
Notice the demographics table has the more_data fields append to the end of each
record.
You’ve just connected the two tables, matching the records in one table to the records
in another table that have the same value for BLKGRP.
This is a temporary join, the original files/data have not been modified. ArcGIS keeps
track of joins within a project, and how to display the various joined files. If you were to
display these data sets in another project, they would not appear joined. The data are
not copied to a new, combined, file. Rather, this join tells ArcGIS to display these two
data sets within this particular view, matching each row by the join variable.
15
GIS Fundamentals Lab 7 Table Operations
• Activate the Select by Attributes described in the previous section of this lab
16
GIS Fundamentals Lab 7 Table Operations
There are two files in the Lab 7 folder that will allow us to calculate and display this. The
first is the USCounties shapefile data layer we worked with in the first section of this lab.
The second is the USAgdat.dbf table that contains summary data for each U.S. county,
with the number of cows for each county stored in the item named Cows.
The item CountyAcre in USAgdat.dbf stores the number of acres in each county.
You need to perform a combination of operations to create a map that looks something
like that below; showing the number of cows per square mile (CPSM). It shows a
quantile symbology with 10 classes.
The combined FIPS code in each table may serve as a key to join them. It
concatenates the state and county FIPS codes as to uniquely identify each county.
(Note: if your map goes blank after the join, use symbology to display unique values; the primary single symbol
default display is cleared with the join)
There are 640 acres in a square mile, so you may wish to calculate a variable that holds
the number of square miles in each county, and then create another variable into which
you calculate the number of cows divided by the number of square miles. Alternately,
you can do a combined calculation into a single variable.
Create a layout, add a title, legend, your name, scale bar, and North arrow, export a
PDF, and turn it in on the course Canvas site.
17
GIS Fundamentals Lab 7 Table Operations
This exercise will give you practice in creating and joining tables, and practice in the
other techniques you learned in the first section of this lab (Video: Create Tables).
2. Uncheck the “Show all other values”, so this won’t appear in the legend.
18
GIS Fundamentals Lab 7 Table Operations
You should have a view similar to the figure below. Review the layer attributes, and in
particular notice the soil_type attribute.
The soil_type
attribute
contains a
code
corresponding
to the soil type
of each
individual
polygon.
Notice there are 15 different soil types designated by numbers between 18 and 69.
There are 122 different soil polygons.
Our job is to create a new table, enter important information for each of the 15 different
soil types, and join this data with the soils data layer.
In this exercise you will use the “soil_type” variable in the soils data layer as the join
item or join column. This is the “key” variable that will be used to match the rows from
the new soil properties table you will create to the soil polygon data in soils. The join
item must be defined the same way in both tables, with the same type (long or short
integer, text, etc.)
19
GIS Fundamentals Lab 7 Table Operations
Let’s examine the “key” or join column in the target table. Do this by a right click on soils
file in the Table of Contents window, then Select Data in the top ribbon menu and then
select Fields.
This should display the window below. Left click on the soil_type item and note the type
and other properties of the soil_type item.
Now we need to create the new data table we’ll be joining to soils.
20
GIS Fundamentals Lab 7 Table Operations
Open the soilprops table (right click in the TOC, then Open).
Add the following fields (remember via the table tools icon,
Add Field):
soil_type, long
name, text, length of 20
fert_class, double
drain_clas, double.
Remember to Save your Fields (at the top ribbon menu) when you are done entering
them.
Add the soilprops table to your Map if it isn’t already in your TOC, then Open the table.
Left click on the table to activate it, then on the soil_type cell for the first row. This
should put the cell in edit mode,
with a green background for the
column and darkened border
around the cell like ->
21
GIS Fundamentals Lab 7 Table Operations
Type the values for the first row from the table shown in below-right figure Click
successively down the row to add the values in the appropriate locations, e.g.,
Soil_Type: 18, Name: Eve, etc.
When you enter the value for the last column in a row hit return,
or click on the OID column label, then in the patch to the left of
the “Click to add new row” message.
When you are finished entering data, select the Edit ribbon menu
and Save
Join the soils layer and the soilprops table you just created.
Remember to use the common field soil_type, to join the files,
and refer to the instructions earlier in this lab if need be (pg.
12/13).
After you’ve completed the join, create a layout using the new
soils table. Display soils by fertility class in the top half of a portrait layout.
Recolor the soils data with different colors for each of the five fertility classes,
approximately as the example map on the next page. Set the fertility classes with a
Quantile Method for 5 soil fertility classes.
We’d like to add the table you entered onto the Layout. Switch to the layout view, as
shown on the next page.
22
GIS Fundamentals Lab 7 Table Operations
This will activate a cross-hair cursor, indicating you should draw a Table Frame. Now
click-hold and drag to put one in the lower part of the layout.
23
GIS Fundamentals Lab 7 Table Operations
We must stress the utility of what you’ve just done. Managers and scientists often
want information grouped and displayed in different ways. Joins are then used to add
information to and produce maps upon which decisions are based. Geographic data
may be joined to many different sets of tabular data. These joined sets may be selected
based on many combinations of attributes, greatly increasing the flexibility and utility of
data in a GIS.
24
GIS Fundamentals Lab 7 Table Operations
25