Ex_1_Tables Exercise

advertisement
Geoprocessing Application Short Course
Exercise 1. Table Manipulation
The objectives of this exercise are to
1. Organize your Toolbox
2. Set up your Environments
3. Carry out a simple exercise that illustrates some of the important aspects of
using the Modeler
The model you build will create dbf table, manipulate fields in the table and enter
values into the table.
Copy the folder called EX1 from the data CD and place it in the root of C:. You can
actually put the folder anywhere you want. I suggest the root of C: because that will
lead to short paths to the Exercise folder and contents and that will lead to faster
definition of output file naming because you won’t have to scroll to the end of text
windows to enter file names.
1. Open ArcMap (note: having both ArcMap and ArcCatalog open can cause windows
problems resulting in strange error messages. Windows does not permit writing to
files that are active in another application.)
2. Set up
2.1. Select New Map and save it in C:\EX.1
2.2. Click the Tools menu and select Options.
2.3. Select the Geoprocessing tab.
2.3.1. Under General check the boxes for both entries
2.3.2. Skip the My Toolboxes section
2.3.3. In the ModelBuilder section check the box about connecting elements …..
2.3.4. Go back up and click the Environments Button
2.3.4.1.
Under General Settings:
2.3.4.1.1. Set the Current Workspace to EX1/Data.gdb
2.3.4.1.2. Set the Scratch Workspace to EX1/Scratch.gdb
This is how it looks on
my machine. I didn’t
have it on the root of C:
so had longer paths to
the data.
Geoprocessing Application Short Course
Exercise 1. Table Manipulation
3. Open the toolbox window if it is not already open.
3.1.1. In it create a new toolbox called Table.
3.1.2. Drag or copy/paste the following tools into Table
3.1.2.1.
Create Table (Data Management/Table toolset)
3.1.2.2.
Add Field (Data Management/Fields toolset
3.1.2.3.
Delete Field
3.1.2.4.
Calculate Field
4. Set up the Model (Right Click in Table.)
4.1. When the model opens:
4.1.1. Access the model properties by either
clicking the Model menu or Right Clicking in the model space.
4.1.2. Name the model something like SimpleTable (no spaces or special
characters) and Label the model Simple Model (with a space.)
4.1.3. Optional: In Diagram Properties I like to make the models more compact
by changing the Minimum spacing values to 15 and the Connection Routing
Horizontal and Vertical spacing to 5
5. Create the Model
5.1. Drag the Create Table tool into the model. 
5.2. As mentioned earlier, dragging data layers into
a model is a bad habit to get into because it
limits your choices of inputs. However, in this
case, since you are creating a new table, there
is no data layer to drag into the model!
5.3. Open the Create Table dialog by Double Clicking the tool. The input for this
element is the folder where you want to put the table (the folder has to exist.)
There are two required parameters for this tool (those with the green dots at
there left edge.)
5.3.1. For the Table Location parameter click the Browse button. It opens to
Note:
You can put a table in a GeoDatabase. In this case you would not append the .dbf
extension but just give it a name with no extension. A ,dbf is not supported by
GeoDatabases In addition, the Add Field tool does not seem to work on a file in a
GeoDatabase.
the Data GeoDatabase which is where you specified the data was to be
stored, However, you will have to click the Up arrow twice so you can
select the EX1 folder (see note above.) .
687318809
9/1/2009
Page 2 of 5
Geoprocessing Application Short Course
Exercise 1. Table Manipulation
5.3.2. The second parameter is the name of the table. Your choice. I used
SimpTab.dbf since the table will be a .dbf file.
5.3.3. Click OK
5.4. Click the Run button
or Run under
the model menu.
5.5. After running the model should look
like this ,
5.6. And Simple Table should have created
the table.
5.7. Open ArcCatalog to see if it did, in fact. do that. In Preview the table should
only have field headers OID and Field1.
6. Next Step is to add a field to the new table.
6.1. Drag the Add Field tool to the Simple Table model
6.2. Open the Add Field tool dialog and use the drop down arrow at the right end of
the Input Table text box to select the Variable
(blue
icon) SimpTab.dbf as shown to the right.
6.3. Set the Field Name to Table_Id.
6.4. Leave the other parameters with their default values.
6.5. Run the model
6.6. CLICK OK Save the model and close it.
7. From your toolbox double click the model. A dialog opens which says, “This tool has
no parameters.” That is because the model has all the parameters it needs to run.
Clicking OK will run the model the model again if you want to.
687318809
9/1/2009
Page 3 of 5
Geoprocessing Application Short Course
Exercise 1. Table Manipulation
8. Modifying the model so that you can enter parameters from the run dialog. Being
able to run the model without editing it is usually useful.
8.1. Edit the model.
8.2. Right Click the Create Table tool.
8.3. The dropdown menu shown below opens.
8.4. Select Make Variable/From Parameter/Table Name and click Table name.
8.5. A new element appears, right on top of the input folder element, with the label
Table Name.
8.6. Drag it below the input table element.
8.7. Right Click Table Name and select Model Parameter from the drop down menu.
A letter P will be placed above the Table Name element indicating it is a
parameter for the tool. The model should look something like that shown below
8.8. Save and Close the model.
8.9. In the Table Toolbox double click the Simple Table Tool.
687318809
9/1/2009
Page 4 of 5
Geoprocessing Application Short Course
Exercise 1. Table Manipulation
8.10.
The simple table tool dialog now opens with a requirement that you a)
either run with the default Simp.tab.dbf or enter in a new table name. Note
that the Yellow triangle with a “!” icon to the left of the field indicates trouble
(you can click on it for more info.) In this case the trouble is that SimpTab.dbf
already exists. And the warning does not go away when you enter a new,
different name! Enter a different name.dbf and click OK.
8.11.
In ArcCatalog the table
SimpTab.dbf and the new table you
just made would look like this :
The fields OID and Field1 are what
Create Table put in the table while the Field Table_Id was created by Add
Field.
9. Challenge
9.1. Modify the model to add a second field.
9.2. Then modify it delete Field1
9.3. Now calculate a value for Table_ID.
9.4. Look at the result in ArcCatalog.
9.5. If you are really adventuresome try to make the name of the field a parameter.
SUMMARY








To open a new model you right click in the tool box and select New/Model
To work on or with the model you click on Edit not open
To run a model you a) Open it or b) Edit it and run it.
Do not drag data into a model unless you really know what you are doing. Some
models require variable as input.
The tools and input and output data are model elements.
Models have parameters. That is what is entered into the tool dialogs.
Parameters can also be configured to be available when a model is opened. In
the model those parameters are marked with a “P” and are a lighter blue than
other inputs.
All tools have input and output data even if there is not output parameter in the
tool dialog. That was the case when Add Field was used. In that case the output
of the Add Field was the same as the input but with a (2) added; there is not
theoretical limit to the number of copies of the output (n),
The model you create is just like any other tool in the toolbox.
THE END
687318809
9/1/2009
Page 5 of 5
Download