- To browse to a dataset rather than typing in its name.
- Anytime the parameter's text string is complex.
- To use the same parameter value in subsequent command lines.
Consider the Project command, which takes an input dataset, an output dataset, and a definition of the coordinate system to apply to the output dataset. Typing the path names of the input and output datasets is easy (although you could use a variable for these as well), but the coordinate system parameter is another matter. Following is the text string you'd have to enter to define an Eckert IV coordinate system:
It would be ridiculous to try to enter such a complex string at the command line. Rather, you want to create a variable and use the user interface control to define the coordinate system. In this example, the first step is to enter the two required parameters to the Project command, followed by a space, which will bring you to the output coordinate system parameter. You then right-click and click Insert Variable, as shown below.
Once you click Insert Variable, the coordinate system parameter control will open. With this control, you can select the desired coordinate system, in this case, the Eckert IV projection.
After clicking OK, the command line will contain the auto-generated name of the variable you just created (such as out_coor_system1). When you execute the command, the variable will be replaced with the real parameter text—the coordinate system text string that was shown above.
Once you have created a variable, it will display in a drop-down list the next time you encounter the same kind of parameter when typing a command. Variables are distinguished by their icons in the drop-down list (
).
PROJCS['World_Eckert_IV',
GEOGCS['GCS_WGS_1984',
DATUM['D_WGS_1984',
SPHEROID['WGS_1984',6378137.0,298.257223563]],
PRIMEM['Greenwich',0.0],
UNIT['Degree',0.0174532925199433]],
PROJECTION['Eckert_IV'],
PARAMETER['False_Easting',0.0],
PARAMETER['False_Northing',0.0],
PARAMETER['Central_Meridian',0.0],
UNIT['Meter',1.0]] It would be ridiculous to try to enter such a complex string at the command line. Rather, you want to create a variable and use the user interface control to define the coordinate system. In this example, the first step is to enter the two required parameters to the Project command, followed by a space, which will bring you to the output coordinate system parameter. You then right-click and click Insert Variable, as shown below.
Once you click Insert Variable, the coordinate system parameter control will open. With this control, you can select the desired coordinate system, in this case, the Eckert IV projection.
After clicking OK, the command line will contain the auto-generated name of the variable you just created (such as out_coor_system1). When you execute the command, the variable will be replaced with the real parameter text—the coordinate system text string that was shown above.
Once you have created a variable, it will display in a drop-down list the next time you encounter the same kind of parameter when typing a command. Variables are distinguished by their icons in the drop-down list (There are two ways to create variables:
Finally, click the Value cell, and then click the Properties button that appears to the right of the cell, as shown below. The parameter control will then open, allowing you to enter the value.
- You can create a variable as you type parameter values. When you come across a parameter for which you want to create a variable, right-click then click Insert Variable. A variable with a default name will automatically be added as the parameter value. The default name is just the parameter name with a unique number appended. You can also press the F8 key.
- If you know the type of variable you want to create, such as a feature class or coordinate system, you can use the Variable Manager to create the variable. Right-click anywhere in the command line section and then click Variables. In the Variable Manager, click Add to add a new variable.
Creating a variable with the Variable Manager
To open the Variable Manager, right-click anywhere in the command line section and click Variables.To create a new variable, click the Add button and a new entry will be added to the list of variables. A name is chosen for you, such as Variable0. You can rename the variable at anytime by simply clicking on the cell.The next step is to choose a Data Type for the variable. Click the Data Type cell and choose the data type from the drop-down list. Learn more about determining data types
Finally, click the Value cell, and then click the Properties button that appears to the right of the cell, as shown below. The parameter control will then open, allowing you to enter the value.
You can add, delete, and rename variables as well as change their data type and values. These actions are done in the Variable Manager window. To open the Variable Manager window, right-click in the command line section, then click Variables.
Adding a variable
Click Add to add a new variable with the default name.Renaming
Click the cell containing the name you want to change and type a new name.Deleting
Click any cell of the variable you want to delete and click Delete.Changing data type
Click the cell of the data type you want to change and select a new data type.Changing the value
Click the cell of the value you want to change, then click the Properties button that appears on the right of the cell.When variables are created in ArcCatalog, they are saved to the default geoprocessing settings when ArcCatalog is closed or when the settings are saved as the default. All applications, when started, use the default geoprocessing settings.When you are switching between different applications or you are working on a certain project, you may want to save the variables you have specified to a file, so you can quickly load them when they are needed. Alternatively, you may save settings as the default, so all other applications will use them.The way you save variables is by saving the geoprocessing settings. Along with variables, you'll also save the state of the ArcToolbox window and the state of the Environment Settings dialog box. Learn more about geoprocessing settings
If you are working in ArcMap and you save the map document, all created variables will be saved with the map document, so you do not need to save settings in this case.