com.esri.arcgis.geoprocessing.tools.datamanagementtools
Class CalculateField
java.lang.Object
com.esri.arcgis.geoprocessing.AbstractGPTool
com.esri.arcgis.geoprocessing.tools.datamanagementtools.CalculateField
- All Implemented Interfaces:
- GPTool
public class CalculateField
- extends AbstractGPTool
Calculates the values of a field for a feature class, feature layer, or raster catalog.
The Calculate Field tool is contained in the Data Management Tools tool box.
Usage tips:
- Python expressions can be created using properties from the (Type, Extent, Centroid, FirstPoint, LastPoint, Area, Length, IsMultipart, and PartCount).
- Python expressions can use the geometry Area and Length properties with an areal or linear unit to convert the value to a different unit of measure.
- In the tool dialog, an expression can be entered directly into the Expression parameter, or interactively built using the Field Calculator.
- When used with a selected set of features, such as those created from a query in or , this tool will only update the selected records.
- The calculation can only be applied to one field per operation.
- Existing field values will be overwritten. A copy of the input table should be made if you want to preserve the original values
- For Python calculations, field names must be enclosed in exclamation points (!fieldname!).For VB calculations, field names must be enclosed in square brackets ([fieldname]).
- To calculate strings to text or character fields, in the dialog box the string must be double-quoted ("string"), or in scripting, the double-quoted string must also be encapsulated in single quotes ('"string"').
- This tool can also be used to update character items. Expressions using character string should be wrapped, using single quotes—for example, [CHARITEM] = 'NEW STRING'. However, if the character string has embedded single quotes, wrap the string using double quotes—for example, [CHARITEM] = "TYPE'A'".
- To calculate a field to be a numeric value, enter the numeric value in the Expression parameter; no quotes around the value are required.
- The arcgis.rand() function is supported by this tool when a Python expression is specified. The arcgis.rand() function has been created for ArcGIS tools and should not be confused with the Python Rand() function. The syntax for the available distributions for the arcgis.rand() function can be found at .
- The expression and code block are connected. The code block must relate back to the expression; the result of the code block should be passed into the expression.
- The Code Block parameter allows you to create complex expressions. You can enter the code block directly on the dialog, or as a continuous string in scripting.
- The Python math module and formatting are available for use in the Code Block parameter. You can import additional modules. The math module provides number-theoretic and representation functions, power and logarithmic functions, trigonometric functions, angular conversion functions, hyberbolic functions, and mathematical constants. To learn more about the math module, see Python's help.
- When calculating joined data, you cannot calculate the joined columns directly. However, you can directly calculate the columns of the origin table. To calculate the joined data, you must first add the joined tables or layers to ArcMap. You can then perform calculations on this data separately. These changes will be reflected in the joined columns.
Constructor Summary |
CalculateField()
Creates the Calculate Field tool with defaults. |
CalculateField(java.lang.Object inTable,
java.lang.Object field,
java.lang.Object expression)
Creates the Calculate Field tool with the required parameters. |
Method Summary |
java.lang.String |
getCodeBlock()
Returns the Code Block parameter of this tool . |
java.lang.Object |
getExpression()
Returns the Expression parameter of this tool . |
java.lang.String |
getExpressionType()
Returns the Expression Type parameter of this tool . |
java.lang.Object |
getField()
Returns the Field Name parameter of this tool . |
java.lang.Object |
getInTable()
Returns the Input Table parameter of this tool . |
java.lang.Object |
getOutTable()
Returns the Output Feature Class parameter of this tool (Read only). |
java.lang.String |
getToolboxAlias()
Returns the alias of the tool box containing this tool. |
java.lang.String |
getToolboxName()
Returns the name of the tool box containing this tool. |
java.lang.String |
getToolName()
Returns the name of this tool. |
void |
setCodeBlock(java.lang.String codeBlock)
Sets the Code Block parameter of this tool . |
void |
setExpression(java.lang.Object expression)
Sets the Expression parameter of this tool . |
void |
setExpressionType(java.lang.String expressionType)
Sets the Expression Type parameter of this tool . |
void |
setField(java.lang.Object field)
Sets the Field Name parameter of this tool . |
void |
setInTable(java.lang.Object inTable)
Sets the Input Table parameter of this tool . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
CalculateField
public CalculateField()
- Creates the Calculate Field tool with defaults.
Initializes the array of tool parameters with the default values specified when the tool was created.
CalculateField
public CalculateField(java.lang.Object inTable,
java.lang.Object field,
java.lang.Object expression)
- Creates the Calculate Field tool with the required parameters.
Initializes the array of tool parameters with the values as specified for the required parameters and with the default values for the other parameters.
- Parameters:
inTable
- the table containing the field that will be updated with the new calculation.field
- the field that will be updated with the new calculation.expression
- the simple calculation expression used to create a value that will populate the selected rows.
getInTable
public java.lang.Object getInTable()
- Returns the Input Table parameter of this tool .
This parameter is the table containing the field that will be updated with the new calculation.
This is a required parameter.
- Returns:
- the Input Table
setInTable
public void setInTable(java.lang.Object inTable)
- Sets the Input Table parameter of this tool .
This parameter is the table containing the field that will be updated with the new calculation.
This is a required parameter.
- Parameters:
inTable
- the table containing the field that will be updated with the new calculation.
getField
public java.lang.Object getField()
- Returns the Field Name parameter of this tool .
This parameter is the field that will be updated with the new calculation.
This is a required parameter.
- Returns:
- the Field Name
setField
public void setField(java.lang.Object field)
- Sets the Field Name parameter of this tool .
This parameter is the field that will be updated with the new calculation.
This is a required parameter.
- Parameters:
field
- the field that will be updated with the new calculation.
getExpression
public java.lang.Object getExpression()
- Returns the Expression parameter of this tool .
This parameter is the simple calculation expression used to create a value that will populate the selected rows.
This is a required parameter.
- Returns:
- the Expression
setExpression
public void setExpression(java.lang.Object expression)
- Sets the Expression parameter of this tool .
This parameter is the simple calculation expression used to create a value that will populate the selected rows.
This is a required parameter.
- Parameters:
expression
- the simple calculation expression used to create a value that will populate the selected rows.
getExpressionType
public java.lang.String getExpressionType()
- Returns the Expression Type parameter of this tool .
This parameter is specify the type of expression that will be used.
This is an optional parameter.
- Returns:
- the Expression Type
setExpressionType
public void setExpressionType(java.lang.String expressionType)
- Sets the Expression Type parameter of this tool .
This parameter is specify the type of expression that will be used.
This is an optional parameter.
- Parameters:
expressionType
- specify the type of expression that will be used.
getCodeBlock
public java.lang.String getCodeBlock()
- Returns the Code Block parameter of this tool .
This parameter is allows for a block of code to be entered for complex expressions.
This is an optional parameter.
- Returns:
- the Code Block
setCodeBlock
public void setCodeBlock(java.lang.String codeBlock)
- Sets the Code Block parameter of this tool .
This parameter is allows for a block of code to be entered for complex expressions.
This is an optional parameter.
- Parameters:
codeBlock
- allows for a block of code to be entered for complex expressions.
getOutTable
public java.lang.Object getOutTable()
- Returns the Output Feature Class parameter of this tool (Read only).
This is an derived parameter.
- Returns:
- the Output Feature Class
getToolName
public java.lang.String getToolName()
- Returns the name of this tool.
- Returns:
- the tool name
getToolboxName
public java.lang.String getToolboxName()
- Returns the name of the tool box containing this tool.
- Returns:
- the tool box name
getToolboxAlias
public java.lang.String getToolboxAlias()
- Returns the alias of the tool box containing this tool.
- Returns:
- the tool box alias