IPM CRSP UGANDA

GIS WORKSHOP

USING ARCVIEW

Larry Grossman

Department of Geography - Virginia Tech


Held at Makerere University, Kampala, Uganda
February 19 - 21, 2002


VIRGINIA TECH
MAKERERE UNIVERSITY
NATIONAL AGRICULTURAL RESEARCH ORGANIZATION


NOTE: The materials on these pages--in printed and digital 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.


Acknowledgments: The digital data in these GIS lessons are supplied by the Institute for Environment and Natural Resources, Makerere University, Uganda; the National Environmental Management Agency (NEMA), Kampala, Uganda; the National Biomass Project, Department of Forestry, Kampala, Uganda; the World Resources Institute (African Data Sampler), New York; the Blackland Research and Extension Center and the Department of Rangeland Ecology & Management, Texas A & M University (Almanac Characterization Tool); and the United Nations.

Step 14: Adding, Editing, and Importing Data

We have been using tabular data already stored in our files. We can add tabular data from other sources in a variety of ways.

Adding Manually Entered Data into New Fields

First, we will add a new field to our table and manually enter data into it to update our records on pest-control strategies. A basic problem with manually entering data in tables in ArcView is that the process is slower and more cumbersome compared to working with Excel spreadsheets.

Make the top theme "Pest Control Strategies"--which has the legend for Numpest1, 2, and 3--active and open its table.

We need to add a new field. Make sure that you select from the menu at the top of the screen Table and then Start Editing from the drop-down list first to enter editing mode. Then select Edit from the menu at the top of the screen and Add Field from the drop-down list. In the Field Definition dialog box, name the new field "Numpest4" which will represent the number of pests found in time period four.

Click on the OK button to add the field. Scroll to the right to find our new field.

Now click on the Edit button in the second row of buttons at the top of the screen.

This button enables us to either enter new data or to edit existing data in our tables. Note that when you place your cursor over the table, it now changes to a hand with a finger pointing.

Put your cursor in the first row just below our new field name, "Numpest4" and click in the empty cell. Type in the number 88. Press the Enter key to enter the data and the cursor automatically moves to the cell beneath the current row.

We are going to enter more data in the column. Remember to press the Enter key after each data entry.

In the second row, type in 55. In the third row, type in 90. In the fourth row, type in 100. In the fifth row, type in 150.

You have to press the Enter key after the last entry as well. When you do so, the cursor then shifts to the top row of another field. Thus, when you are entering data in a new field, as you approach the bottom of your new field, go slowly, for otherwise you could overwrite data in the first row at the top of another field. (Note: If you do overwrite data in another field, select Edit from the menu at the top of the screen and select Undo Edit from the drop-down list.)

The right side of our table should look like this:

We now have manually entered data in a new field in a table. We also need to save our entries.

Select Table from the menu at the top of the screen and Stop Editing from the drop-down list. Select Yes when you are prompted if you want to "Save Edits?" Your changes are now saved.

Close the attributes table.

We can now add the data in our new field to our map. Double-click on the top theme, "Pest Control Strategies"--which has the legend for Numpest1, 2, and 3. In the Legend Editor dialog box, we see the information for only Numpest1, 2, and 3 on the right of the dialog box. To add our new field, change the "Legend Type" at the top of the dialog box to "Single Symbol" and then change it back to "Chart." Now add Numpest1, 2, 3, and 4 to the right of the dialog box under the category "Fields.".

Be sure to click on the bar chart button in the bottom left of the dialog box. Then click on the Apply button and close the Legend Editor dialog box. Your map should look like this, with the new data on "Numpest4" also displayed.

You can thus continue to update your GIS projects.

Note that you can also change data in cells already containing data. After entering editing mode, use the same Edit button in the second row of buttons at the top of the screen. Click on the cell in which you want to make the change, enter the change, and press the Enter key. Be sure to save your changes.

Importing Data from Excel Spreadsheets

Now we will discuss importing data from Excel spreadsheets. The advantage of working in Excel is that it is easier to manipulate data in Excel than it is in ArcView tables.

There are two methods of working in Excel.
The first is to use Excel to edit an existing ArcView table, which is in ".dbf" format.
The second is to create an entirely new table in Excel and then import it into ArcView by joining it to an ArcView table.

Editing an existing ArcView ".dbf" format file in Excel.

First, uncheck both boxes next to the two themes "Pest Control Strategies" at the top of the Table of Contents so that they are no longer displayed in our View.

We are going to edit the table for the theme "Shambas.shp". Make the theme active, display it in our View, and zoom to the active theme.

Open the attributes table for "Shambas.shp". Notice that while there are many (77) parcels listed in the table, we have no unique identifying number for each parcel. We want to give each parcel a unique ID number, from 1 to 77. Doing this manually in ArcView is cumbersome. It is very easy to do in Excel.

The file name for the attributes table for "Shambas.shp" is "shambas.dbf". Close the attributes table.

Now, open Microsoft Excel.

Import "shambas.dbf" into Excel by selecting from the menu at the top of the screen File and then Open from the drop-down list. At the bottom of the Open window in Excel, there is a drop-down list for Files of type:. Select dBase Files (*.dbf) from the drop-down list. Then locate your file in the window (in the directory "ipm-crsp"), highlight it, and click on the Open button to open your file in Excel.

Note that the entries in the first row of an Excel spreadsheet are the same as the column headings that appear in the ArcView tables.

Note also that the first column in an ArcView table, the "Shape" field, does not appear in Excel.

Our first column (column "A") heading in Excel (in row 1) is "ID". We can use this column to put in our ID numbers. Note that our Excel file has 78 rows, one for the column heading and 77 for the individual parcels.

Enter the number "1" in cell A2 and press the Enter key on your keyboard. Then highlight with your cursor cells A2 to A78. Select from the menu at the top of the screen Edit and then Fill from the drop-down list and Series from the pop-out window.

In the Series dialog box, select under "Type" the choice "Linear" and under "Step Value" select "1".

Click on the OK button and a series of numbers from 1 to 77 is entered in Column A. Click in a cell in column A to remove the highlighting.

While in Excel, you can make such changes, add fields, perform calculations, etc. But there is a potential problem here. If you simply saved your current file in Excel as a ".dbf" file and then you tried to open it in ArcView, none of your changes that you made in Excel would appear in ArcView.

To get around this problem requires a few extra steps. When you have finished making changes to your file in Excel, copy all the columns and rows in your file (whether changed or unchanged) that have data in them and paste them into a new empty spreadsheet in Excel.

Note: When you copy these cells, DO NOT copy them by selecting the entire spreadsheet for copying; copy only those cells that have data in them. Thus, drag your cursor to highlight the block of cells from A1 to G78.

Now copy the cells by clicking on the copy button.

Open a new (blank) spreadsheet (workbook). Select from the menu at the top of the screen File and then New from the drop-down list. A blank spreadsheet appears.

To paste the cells A1 to G78 into the new spreadsheet, click only on cell A1 in the new spreadsheet and then click on the paste button.

Before saving the new spreadsheet in Excel, first be sure to click on one of the cells with data in it so that it is highlighted. If you have highlighted a cell without data in it, you could not save the new file.

When ready to save the new spreadsheet in Excel, select File from the menu at the top of the screen and Save As from the drop-down list. The Save As window will appear. Give the new spreadsheet a name.

Name the file "ShambasID.dbf", which is different from the original name, "shambas.dbf." The reason that I suggest giving the file a different name is to enable you to save the original file as a back-up in case you make mistakes.

Also, make sure that it has a ".dbf" extension by selecting from the drop-down list for "Save as type" at the bottom of the window the choice "DBF4(dBASE IV)(*.dbf)".

When you click on the Save button, the following window will appear:

Click on the OK button. You will now get the message:

Click on the Yes button.

Try to exit the Excel program. You will get the message:

Click on the Yes button. A new window appears.

Click on the OK button. The Save As window reappears.

Click on the Save button again. Now you get the message

Click on the Yes button to replace the existing file..

Another window appears asking if you want to save the changes to the original file you opened in Excel (here it was "Shambas.dbf")

Click on the No button because you cannot save the changes to the original file anyway.

You may get the following window again:

Click on the Yes button. Excel should now close.

Open the "IPM-CRSP" directory in Windows Explorer.

You should now rename the original, unchanged dbf. file (here "shambas.dbf") to another, similar name to create a backup file (such as "shambas-orig.dbf") and then rename the new file you just created in Excel (here "shambasID.dbf") to the original file name, "shambas.dbf."

Close Windows Explorer.

Return to the ArcView program.

Open the attributes tables for "Shambas.shp." It may appear distorted. Do not worry.

To make the attributes table appear correctly, you first need to delete the theme "Shambas.shp" from the Table of Contents and then add it back again.

To delete a theme from the table of contents, make sure that it is active. Then select from the menu at the top of the screen Edit and Delete Themes from the drop-down list. The Delete Themes window appears. The message in the window asks "Are you sure you want to delete theme Shambas.shp." Click on the Yes button. The theme is now deleted from the Table of Contents.

Now add the theme "shambas.shp" back again to the Table of Contents. Open the attributes table for "Shambas.shp."

The table will now appear in its proper form, with the new data in the field "Id."

Close the table "Attributes of Shambas.shp".

Creating an entirely new table in Excel and then importing it into ArcView

The second method of working in Excel is to create an entirely new spreadsheet that can be incorporated into ArcView. The key here is to have one column in your Excel file that matches exactly a preexisting column in the ArcView .dbf file that is associated with the theme that you are examining. You can then join the two tables.

Uncheck the box next to the theme "Shambas.shp" in the Table of Contents so that it is no longer displayed in our View.

Scroll to the bottom of the Table of Contents. Display the theme "District Names" (based on the shapefile "uganda-district.shp"), make it active, and zoom to the active theme. Open its table.

If we look at our table "Attributes of District Names," we can see that there is one column that would be easy to re-create and match in our Excel file--the field "Adm1", which has the district names.

We now want to open the file "District.xls," which was created in Excel, so that we can join it to "Attributes of District Names." Open the Excel program. In the bottom of the Open window, be sure to change the section "Files of type" to "Worksheets (*.xls)" because it is an Excel file. Open the file.

You can see the district names in column A. The names match exactly those in the ArcView table "Attributes of District Names." The other columns have demographic data.

Note: The names (or numbers) in a field in an ArcView table must match exactly those in a column in Excel in order for the two tables to be joined. But the name in the column heading of a field in an ArcView table can be different from the name in the column heading in Excel (in row 1). Thus, the fact that the field name in ArcView in "Attributes of District Names" is "Adm1" and the column heading in column A in Excel is "District" is not a problem.

Save our Excel file "District.xls" as a .dbf file in our directory "ipm-crsp". (You have to go through the many steps we illustrated above to save it as a ".dbf" file.) The file "District.dbf" can now be imported into ArcView.

Let us see how this works.

To import the file "District.dbf" into ArcView, first go to the Project Window, click on the Tables icon and then click on the Add button, which brings up the Add Table window.

Make sure that the "ipm-crsp" directory appears on the right. On the left, double-click on the file name "district.dbf."

The file then opens in ArcView.

We need to join our new table, "district.dbf," with our pre-existing table in ArcView because only the pre-existing ArcView table is referenced spatially so that it can be displayed in our map.

Joining tables means combining the contents of the two tables.

To join our two tables, we need to highlight the names of the fields that have the same data in both tables, in this case, the field name "District" (in "district.dbf") and the field name "Adm1" (in "Attributes of District Names").

But the order in which we highlight the fields in the two tables is crucial. When ArcView joins two tables, it abandons the table in which we first highlight the field heading and only keeps the table in which we highlight the field heading last.

Thus, go ahead and first click on the field name "District" in "district.dbf", which causes the cell containing the name of the field to be darker than the other field headings.

Then, open up the table "Attributes of District Names" and click on the field name "Adm1" in the table .

To join the two tables, click on the Join button at the top of the screen below the menu.

The contents of our two tables will be joined and our table "district.dbf" will be closed, with only "Attributes of District Names" remaining. "Attributes of District Names" now contains the additional fields concerning demographic information joined from "district.dbf".

Now the demographic information about the districts can be displayed in our map, just like our other fields.

Note: if you had a problem joining the two tables, be sure that you are not in editing mode. You cannot join tables while in editing mode.

Saving Joined Tables

An important note is warranted here concerning our joined table. If you searched for this new table in a single ".dbf" file on your hard drive, you would not find it. Although we see a joined table, ArcView preserves the two original tables as distinct files.

Thus, after you join a table, you can only edit the original part of the table, not the part that you joined, because they are really separate tables.

To save our joined file as a single file in which all fields can be edited, go to the menu at the top of the screen and select File and then Export from the drop-down-list.

The Export Table window appears.

Select dBASE as the format. dBASE files have the ".dbf" file extension. Click on the OK button and the Export Table window will appear asking you for the name of your new .dbf file.

I will name it "table1.dbf" and will place it in our "ipm-crsp" directory. Click on the OK button.

To bring our new "table1.dbf" into our project, close the current table and return to the Project Window. Click on the Tables icon, which brings up a list of the tables that have been used in our project. Click on the Add button, which brings up a list of available .dbf files in the Add Table window. Double-click on "table1.dbf" on the left. Then, "table1.dbf" will appear.

You can now edit all fields in this new table. Close the table.

If you go back to the Project Window, you will also see "table1.dbf" listed as well.

To go back to our map, click on the Views icon in the Project Window and click on "View1" and then the Open button.

Importing ARC/INFO Files

Another task with importing data is to incorporate pre-existing data created in the program ARC/INFO. Such data from ARC/INFO are exported with the extension ".e00".

We will not do this here. I provide this information for future use.

To import such data into ArcView, we need to click on the Windows Start button, select Programs and from the pop-up list choose ESRI; from the ESRI list, select Import71.

The Import71 Utility window now appears, with two blank boxes. One asks for the Export Filename. Here you need to enter the name of the ARC/INFO file, which you can enter by searching for it using the Browse button on the right. The second box asks for the Output Data Source. Here you need to create a name for a subdirectory in which ArcView will place the converted files so that they can be used in ArcView; the subdirectory will be located in the same directory in which the ARC/INFO file is located.

After you press the OK button, the window will indicate that ArcView is processing the file. Do not do anything until a small Import71 Utility window appears with the message "Import Complete." Click on the OK button to close it.

Before adding the theme to your project, make sure it has the same View Properties as your other themes. If it does not, you will have to project the data. See advanced users for help in projecting data.

Then you can add the new theme to your map; the theme will have the same name as the name you entered for "Output Data Source."

[Return to beginning]

[GO TO STEP 15]