USING ARCVIEW

IPM CRSP

VIRGINIA TECH - CARDI JAMAICA

INFORMATION SYSTEMS FOR COLLABORATIVE RESEARCH

GIS WORKSHOP

August 18 - 20, 1998

Larry Grossman

Department of Geography

Virginia Tech


NOTE: The materials on these pages--both in printed form and on the World Wide Web--are to be used only in association with the Virginia Tech IPM CRSP. Reproduction or use of these pages, in part or in full, for commercial purposes is strictly prohibited. Those wishing to reproduce or use these pages for non-profit, educational purposes should contact the author at LGROSSMN@VT.EDU for permission.


Acknowledgment: All coverages and part of the data in these GIS lessons are supplied by Glynis Ford of the Rural Physical Planning Division (RPPD), Ministry of Agriculture, Jamaica.

Step 11: Spatial Analysis III: Using and Creating New Variables in a Database Table

Tables in ArcView

We have seen previously that each feature--whether a point, line, or polygon--has certain attributes, or characteristics. These attributes are stored in tables that serve as a database in ArcView. Each theme is associated with a different table of attributes. We can also use the data in the attribute tables to create new variables that can contribute to spatial analysis.

For example, if in our table we have one "field" with data on pest populations and another "field" with data on garden areas, we can divide pest populations by garden area to create a new field--pest population density--which can then be mapped. Similarly, we can calculate total animal populations by summing the individual fields for the populations of cattle, sheep, goats, and pigs.

Here, we are simply going to sum the populations of cattle, sheep, goats, and pigs to create a new field that contains the sum of the four. To do so, we need to know how to perform basic mathematical operations on the fields in our tables. We can then map the new fields to examine their spatial relationships with other variables.

We will examine the data in the theme "Major Crop," which is really our original theme, "bpkprcl.shp." (Note: even though we changed the name of the theme in the Table of Contents to "Major Crop," the original name of the theme ("bpkprcl.shp") in its table remains the same.) We first need to be sure that the theme is active.

Click on the Open Theme Table buttonOPEN THEME TABLE at the top of the screen below the menu. The "Attributes of bpkprcl.shp" table will appear.

Note that the menu and buttons at the top of the screen have changed from those we used in the View of our map.

Notice also that at the head of each column in the table is the field name and each row represents an individual feature on the map. We can find more fields to the right hidden from view now by scrolling to the right using the scroll bar at the bottom of the screen.

Similarly, we can find more records beyond the bottom of the screen by scrolling down using the scroll bar on the right.

Above the words "Attributes of bpkprcl.shp" are two boxes noting the number of total records in our table (the box on the right)and the number of records that has been selected (the box on the left).

Right now, none have been selected.

When we selected features on our map in the previous lesson, the color of the records of those features in the table also changed to yellow, though we did not see it at the time.

To show this, close the table and randomly select about 10 or so polygons on our map using the Select Feature button, as I have done here.

Open up the table again and note that the corresponding records have also been selected and are now also yellow; there are more records selected out of view below.

(Note: to see all the items selected grouped together at the top of the table for easier comparison and analysis, click on the Promote button at the top of the screen below the menu.)

Use the Select None button at the top of the screen below the menu to remove the yellow highlighting.

NOTE: Before performing calculations, it is best to check to see if any of the rows of data in the table have been selected. In ArcView, if anything is selected, calculations are performed only on the records or map objects that have been selected. In some cases, you may want to perform analyses on only a limited set of records, but here we want none to be selected.

Creating New Variables

We want to sum the number of cattle, sheep, goats, and pigs to create a new variable called "Livestock_Pop". We first have to create a new field in which to place the summed figures.

Creating a new field is easy. From the menu at the top of the screen, select Table and then from its drop-down list, select Start Editing.

Table menu

Nothing seems to happen after making the selection, except one subtle difference is that the font of the field (column) headings changed from Italics font when we are not editing to Normal font when we are editing. This action simply enables you to start editing the table.

From the Edit menu at the top of the screen, select from the drop-down list Add Field.

Edit menu

A small Field Definition dialog box appears.

Field Definition

Erase "NewField" in the small box to the right of the category "Name" and type in the new name for our field--Livestock_Pop--that we want to create.

Note that below the name that we typed in is a box with a drop-down list to the right of "Type:". The current choice is "Number" which is appropriate for our variable that we are creating. But there are other choices as well.

If we wanted to create a new variable of a category, such as soil type or pesticide used, we would select "String" from the drop-down list.

You can also select the number of decimal places for the new field as well as the width of the new field in this dialog box.

After clicking on the OK button in the "Field Definition" dialog box, the new field, "Livestock_Pop," that we just created appears as the heading of the last column at the right end of our table.

(Note: We can later change the location of this or any other column in our table by placing our cursor on the field name at the top of the column and then dragging it to where we want it placed in the table.)

Now we want to calculate the sums of the four types of livestock and place the results in our new field.

From the menu at the top of the screen, select Field and then from its drop-down list, choose Calculate.

calculate

The Field Calculator dialog box now appears.

Let us examine the dialog box. On the top left is a list of all the "Fields" in our table. We will be combining four of these fields to create our new variable, "Livestock_Pop." On the top right, is a list with the heading "Requests." From this list, we can choose various mathematical operators to create an equation that will produce the new variable. (In the section in the middle is the type of field, in this case a number). In the bottom left is a box with the heading "[Livestock_Pop]=". Here ArcView wants to know what variables we will be using and how they will be combined to produce our new field, "Livestock_Pop."

First, use the scroll-down bar in the "Fields" category in the top left of the dialog box to find the field [Num_cattle]. Double-click on [Num_cattle] and it will appear in the window below the heading "[Livestock_Pop]=".

Now from the list below the heading "Requests" on the right of the dialog box, double-click on the plus "+" sign, which then causes it to also appear in the box below the heading "[Livestock_Pop]=".

Return to the list below "Fields" and double-click on [Num_goats] which then appears in the box below the heading "[Livestock_Pop]=" to the right of the plus "+" sign. Go back to the "Requests" list and double-click on the plus "+" sign again, which, in turn, appears in the equation in the box below the heading "[Livestock_Pop]=". Then return to the list under the heading "Fields" and double-click on our next field, [Num_sheep]. Again double-click on the plus "+" sign. And double-click on our last field, [Num_pigs], which is also added to the equation.

The equation should now look like this:

In essence, our equation indicates that our new field, "[Livestock_Pop]," is equal to the sum of the values in the fields for the number of cattle, goats, sheep, and pigs.

Click on the OK button on the right of the dialog box and the sum for the animal population for each record will appear in our new field, "Livestock_Pop".

To save our changes, we need to exit from "editing mode." To exit from "editing mode" select from the menu at the top of the screen Table and then from its drop-down list, select Stop Editing.

stop editing

The Stop Editing box appears.

stop editing box

Click Yes to "Save Edits" (the changes that we have made to the attribute table, including creating the new field).

Note that when we stop editing the attribute table, the font of the headings of the columns changes back to italics again.

(There are many variables that we could create in our database table. For example, if we had data on pest populations over time for different years, we could easily calculate rates of growth and then map them. But note that if you want to create a new field for rates of growth, it is important to specify that you want decimal places in the "Field Definition" dialog box.)

Once we have created our new field, we can then map it just like any other field. We could compare, for example, the spatial distribution of livestock holdings with the distribution of type of household head or crop type.

Sorting Records

There are other things that we can do in our table. One is to arrange the values for all livestock holdings (or for any other field) in ascending order (from lowest to highest values) or descending order (from highest to lowest values) based on the data in the field. This will enable us to quickly identify those plots with the highest and lowest scores in relation to a particular variable.

First, be sure that the cell in which the column heading "Livestock_Pop" is located appears darker than those of the other column headings. This tells ArcView that we want to work with this field. (If it is not darker, click once on the name of the field in the column heading to make it darker.)

Then go to the buttons at the top of the screen below the menu and click on the Descending Order DESCENDING ORDER button. ArcView will rearrange the records according to their values, from highest to lowest for "Livestock_Pop".

Similarly, we can change the order of the values in the "Livestock_Pop" field by clicking on the Ascending Order ASCENDING ORDER button, which rearranges the list to show the lowest values first for this field.

We could then see where the ten plots with the lowest values are located on our map by selecting them. When working with tables, you choose the Select button, which looks like an arrow (This is normally selected when we open a table.) to select records.

Now click on the ten records with the lowest values so that they turn yellow. To select more than one record at a time, hold down the Shift key while selecting each one.

Then close the table and you can see where such livestock holdings are located on the map and how they relate spatially to other variables, such as the size of a plot. (Usually those with few livestock also have small garden holdings; we also know that female-headed households in the Caribbean have fewer livestock than male-headed households and could determine whether that pattern is also evident here.)

(Remember that any features that are selected--whether points, lines, or polygons--can be converted into and saved as a separate shapefile for further analysis.)

Open up the table again. Click on the Promote button at the top of the screen below the menu to make sure that the records of the ten gardens that we selected are grouped together again at the top of the table.

Before removing the yellow highlighting, click on the Switch Selection button at the top of the screen, which tells Arcview to deselect the items currently selected and select all the other items. Your table should now look like this.

Thus, you can perform separate analyses on the two groups.

To remove the highlighting, click on the Select None button at the top of the screen, which removes the yellow highlighting. If we did not remove the highlighting, when we tried to perform additional analyses, ArcView would only perform the analyses on the highlighted records.

There are many other things that we can do with tables. We will try just a few more here.

Obtaining Statistics on Fields

If you want to get statistics about the new field, "Livestock_Pop", (or any other field), click on the name of the theme at the top of the column so that the cell in which the title name appears is darker than those for the other column headings, and then go to the menu at the top and select Field and from the drop-down list choose Statistics...

Field menu

A box with statistics then appears for that field.

Click on the OK button to close the window. (Note: As suggested above, you can also get statistics on a limited number of rows in a field by selecting them).

Aggregating Data

There is one other aspect of the attribute tables that we want to use. In many attribute tables, the same characteristic appears more than once in a field. For example, in the field for crops ("Crop1"), the names of each of the three crops appears more than once. In such cases in which the same characteristic appears more than once, we can summarize or aggregate the information for those characteristics based on a variety of mathematical operations.

For example, we can summarize the data by crop type and then make a variety of calculations, such as determining the area ("Area" is another one of our fields) devoted to each crop.

To summarize data for a field, you first have to click on the heading of the field to make its cell darker. Click on the field name "Crop1" to make its cell darker.

Then click on the Summarize button Summarize at the top of the screen below the menu. This brings up the Summary Table Definition dialog box.

There are two small boxes on the left with drop-down lists. The first box is labeled "Field" and the second is labeled "Summarize by."

Select "Area" from the "Field" drop-down list. This tells ArcView that we want to find out something about the areas devoted to each of the three crop types.

Select "Sum" from the drop-down list for "Summarize by." This tells ArcView that we want to find the sum of the area for each crop type. (Note: There are other choices as well, such as obtaining averages.)

Then click on the Add button in the middle of the dialog box. Notice that in the blank box on the right "Sum_Area" has appeared.

This statement means that for each crop type ArcView will provide the sum of the area.

(Note also that at the top of the dialog box is the "Save As" button. If you click on it, you can provide a name for the summary table that we are creating and determine the directory in which you want to save it.)

Now click on the OK button in the dialog box and a new, smaller table is created that lists each crop type, the number of plots containing the crop (under the heading "Count") and the sum of the area for each crop.

We could perform other summary analyses, such as determining the average number of pests in the three crops or the average number of livestock for male and female-headed households.

[Return to beginning]

[GO TO STEP 12]