root/MGET/Branches/Jason/PythonPackage/dist/TracOnlineDocumentation/Documentation/PythonReference/Method_GeoEco.DataManagement.Fields.Field.CalculateArcGISField.html @ 307

Revision 307, 15.1 KB (checked in by jjr8, 5 years ago)

Rebuilt MGET 0.6b1 with no changes as 0.6. This will be merged into the Trunk and released as the final build of MGET 0.6.

Line 
1<?xml version="1.0" encoding="utf-8"?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>CalculateArcGISField Method</title><link rel="stylesheet" type="text/css" href="lib.css?format=raw" /><style xml:space="preserve">
4            td.metadataTitle { font-size: 80%; font-weight: bold; font-family: avantgarde, sans-serif; }
5            td.metadataValue { padding-left: 0.5em; }
6          </style></head><body><div class="navigation"><div><table align="center" width="100%" cellpadding="0" cellspacing="2"><tr><td class="online-navigation"><a title="Field Class" href="Class_GeoEco.DataManagement.Fields.Field.html?format=raw"><img src="previous.png?format=raw" border="0" align="bottom" height="32" width="32" alt="Previous Page" /></a></td><td class="online-navigation"><a title="Field Class" href="Class_GeoEco.DataManagement.Fields.Field.html?format=raw"><img src="up.png?format=raw" border="0" align="bottom" height="32" width="32" alt="Up one Level" /></a></td><td class="online-navigation"><a title="CalculateArcGISFields Method" href="Method_GeoEco.DataManagement.Fields.Field.CalculateArcGISFields.html?format=raw"><img src="next.png?format=raw" border="0" align="bottom" height="32" width="32" alt="Next Page" /></a></td><td align="center" width="100%">GeoEco Python Reference</td><td class="online-navigation"><a title="Table of Contents" href="TableOfContents.html?format=raw"><img src="contents.png?format=raw" border="0" align="bottom" height="32" width="32" alt="Table of Contents" /></a></td><td class="online-navigation"><a title="Module Index" href="ModuleIndex.html?format=raw"><img src="modules.png?format=raw" border="0" align="bottom" height="32" width="32" alt="Module Index" /></a></td><td class="online-navigation"><img src="blank.png?format=raw" border="0" align="bottom" height="32" width="32" alt="" /></td></tr></table><div class="online-navigation"><b class="navlabel">Previous:</b> <a class="sectref" href="Class_GeoEco.DataManagement.Fields.Field.html?format=raw">Field Class</a> <b class="navlabel">Up:</b> <a class="sectref" href="Class_GeoEco.DataManagement.Fields.Field.html?format=raw">Field Class</a> <b class="navlabel">Next:</b> <a class="sectref" href="Method_GeoEco.DataManagement.Fields.Field.CalculateArcGISFields.html?format=raw">CalculateArcGISFields Method</a> </div><hr /></div></div><h1><tt class="member">CalculateArcGISField</tt> Method</h1><p>Calculates the value of a table field using a Python expression.</p><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td class="metadataTitle">Class:</td><td class="metadataValue"><tt class="class"><a href="Class_GeoEco.DataManagement.Fields.Field.html?format=raw">Field</a></tt></td></tr><tr valign="baseline"><td class="metadataTitle">Intended use:</td><td class="metadataValue">Recommended for external callers</td></tr><tr valign="baseline"><td class="metadataTitle">COM:</td><td class="metadataValue">Exposed as the <a style="font-family: verdana, sans serif; font-size: small;" href="../COMReference/Method_GeoEco.Field.CalculateArcGISField.html?format=raw">CalculateArcGISField</a> method of COM class <a style="font-family: verdana, sans serif; font-size: small;" href="../COMReference/Class_GeoEco.Field.html?format=raw">GeoEco.Field</a></td></tr><tr valign="baseline"><td class="metadataTitle">ArcGIS:</td><td class="metadataValue">Exposed as the <a style="font-family: verdana, sans serif; font-size: small;" href="../ArcGISReference/Field.CalculateArcGISField.html?format=raw">Calculate Field Using a Python Expression</a> geoprocessing tool</td></tr><tr valign="baseline"><td class="metadataTitle">Method type:</td><td class="metadataValue">Classmethod</td></tr></table><h3>Usage</h3><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td style="white-space: nowrap;"><var>outputTable</var> = <b><tt class="method">Field.CalculateArcGISField</tt></b>(</td><td><var>table</var><var>, field</var><var>, pythonExpression</var><big>[</big><var>, where</var><big>[</big><var>, modulesToImport</var><big>[</big><var>, statementsToExecFirst</var><big>[</big><var>, statementsToExecPerRow</var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table><h3>Arguments</h3><dl><dt><var>table</var></dt><dd><table cellpadding="0" cellspacing="0" style="margin-top: 1.0em;"><tr valign="baseline"><td class="metadataTitle">Python type:</td><td class="metadataValue"><tt class="class">unicode</tt></td></tr><tr valign="baseline"><td class="metadataTitle">Minimum length:</td><td class="metadataValue">1</td></tr><tr valign="baseline"><td class="metadataTitle">Maximum length:</td><td class="metadataValue">255</td></tr><tr valign="baseline"><td class="metadataTitle">Must exist:</td><td class="metadataValue">Yes</td></tr></table><p>Table that contains the field to calculate.</p></dd></dl><dl><dt><var>field</var></dt><dd><table cellpadding="0" cellspacing="0" style="margin-top: 1.0em;"><tr valign="baseline"><td class="metadataTitle">Python type:</td><td class="metadataValue"><tt class="class">unicode</tt></td></tr><tr valign="baseline"><td class="metadataTitle">Minimum length:</td><td class="metadataValue">1</td></tr><tr valign="baseline"><td class="metadataTitle">Maximum length:</td><td class="metadataValue">255</td></tr><tr valign="baseline"><td class="metadataTitle">Must exist:</td><td class="metadataValue">Yes</td></tr></table><p>Field to calculate.</p></dd></dl><dl><dt><var>pythonExpression</var></dt><dd><table cellpadding="0" cellspacing="0" style="margin-top: 1.0em;"><tr valign="baseline"><td class="metadataTitle">Python type:</td><td class="metadataValue"><tt class="class">unicode</tt></td></tr><tr valign="baseline"><td class="metadataTitle">Minimum length:</td><td class="metadataValue">1</td></tr></table><p>Python expression to evaluate for the specified field.</p><p>For each row of the table, this function updates the value
7of the field by evaluating the expression using the Python eval
8function. In your expression, you can access the value of any field by
9referencing the field as an attribute of the "row" object. For
10example, if your table contains a SampledSST field and you want to
11calculate the ActualSST field from it, you might calculate ActualSST
12with the following expression:</p><div class="verbatim"><pre xml:space="preserve">row.SampledSST * 0.075 + 3.0</pre></div><p>Your expression may be any Python statement appropriate for passing to
13the eval function. It must evaluate to a data type that is appropriate
14for the field's data type:</p><ul><li>For string, text, or character fields, return a Python str or
15unicode object.</li><li>For integer fields of any size less than or equal to 32 bits, return
16a Python int.</li><li>For 32-bit or 64-bit floating point fields, return a Python float.</li><li>For date or datetime fields, return an instance of the Python
17datetime class.</li><li>To set the field to a database NULL value, return Python None.</li></ul><p>Other database data types might work if the appropriate Python data
18type is used, but these have not been tested.</p><p>For more information on Python syntax, please see the <a href="http://www.python.org/doc/">Python
19documentation</a>.</p></dd></dl><dl><dt><var>where</var></dt><dd><table cellpadding="0" cellspacing="0" style="margin-top: 1.0em;"><tr valign="baseline"><td class="metadataTitle">Python type:</td><td class="metadataValue"><tt class="class">unicode</tt> or <tt class="class">None</tt></td></tr><tr valign="baseline"><td class="metadataTitle">Default value:</td><td class="metadataValue"><tt class="class">None</tt></td></tr><tr valign="baseline"><td class="metadataTitle">Minimum length:</td><td class="metadataValue">1</td></tr></table><p>SQL WHERE clause expression that specifies the subset of rows to
20process. If this parameter is not provided, all of the rows will be
21processed. If this parameter is provided but the underlying database
22does not support WHERE clauses, an error will be raised.</p><p>The exact syntax of this expression depends on the underlying database
23and the type of connection used to access it. If you are using the
24ArcGIS geoprocessor to access the database, ESRI recommends you
25reference fields using the following syntax:</p><ul><li>If you're querying ArcInfo coverages, shapefiles, INFO tables or
26dBASE tables (.dbf files), enclose field names in double quotes in
27the SQL expression: "MY_FIELD".</li><li>If you're querying Microsoft Access tables or personal
28geodatabase tables, enclose field names in square brackets:
29[MY_FIELD].</li><li>If you're querying ArcSDE geodatabase tables, an ArcIMS feature
30class, or an ArcIMS image service sublayer, don't enclose field
31names: MY_FIELD.</li></ul></dd></dl><dl><dt><var>modulesToImport</var></dt><dd><table cellpadding="0" cellspacing="0" style="margin-top: 1.0em;"><tr valign="baseline"><td class="metadataTitle">Python type:</td><td class="metadataValue"><tt class="class">list</tt> of <tt class="class">unicode</tt>, or <tt class="class">None</tt></td></tr><tr valign="baseline"><td class="metadataTitle">Default value:</td><td class="metadataValue"><tt class="class">None</tt></td></tr><tr valign="baseline"><td class="metadataTitle">Minimum length:</td><td class="metadataValue">0</td></tr></table><p>Python modules to import prior to evaluating the expression. If
32you need to access Python functions or classes that are provided by a
33module rather than being built-in to the interpreter, list the module
34here. For example, to be able to use the datetime class in your
35expression, list the datetime module here. In your expression, you
36must refer to the class using its fully-qualified name,
37datetime.datetime.</p></dd></dl><dl><dt><var>statementsToExecFirst</var></dt><dd><table cellpadding="0" cellspacing="0" style="margin-top: 1.0em;"><tr valign="baseline"><td class="metadataTitle">Python type:</td><td class="metadataValue"><tt class="class">list</tt> of <tt class="class">unicode</tt>, or <tt class="class">None</tt></td></tr><tr valign="baseline"><td class="metadataTitle">Default value:</td><td class="metadataValue"><tt class="class">None</tt></td></tr><tr valign="baseline"><td class="metadataTitle">Minimum length:</td><td class="metadataValue">0</td></tr></table><p>Python statements to execute prior to looping through the rows of
38the table. The statements are executed sequentially using the Python
39exec statement. You can use Python statements to perform
40initialization tasks such as setting variables that you reference from
41your field expression. For example, you might want to perform a
42calculation on all of the rows that involves the current date and
43time, but you want the date and time to remain constant while the rows
44are being updated. To obtain the current date and time, you know you
45can import the datetime module and then invoke the
46datetime.datetime.now(). But you do not want to put this into your
47field expression because the value will change as the system clock
48ticks during your computations. Instead you can set the now variable
49using the statement:</p><div class="verbatim"><pre xml:space="preserve">now = datetime.datetime.now()</pre></div><p>and then reference it from your field expression. (Don't forget to add
50datetime to the list of modules to import first.)</p></dd></dl><dl><dt><var>statementsToExecPerRow</var></dt><dd><table cellpadding="0" cellspacing="0" style="margin-top: 1.0em;"><tr valign="baseline"><td class="metadataTitle">Python type:</td><td class="metadataValue"><tt class="class">list</tt> of <tt class="class">unicode</tt>, or <tt class="class">None</tt></td></tr><tr valign="baseline"><td class="metadataTitle">Default value:</td><td class="metadataValue"><tt class="class">None</tt></td></tr><tr valign="baseline"><td class="metadataTitle">Minimum length:</td><td class="metadataValue">0</td></tr></table><p>Python statements to execute for every row after the row is
51retrieved but before the field expression is evaluated. The statements
52are executed sequentially using the Python exec statement. You can use
53Python statements to perform arbitrary tasks prior to evaluating your
54expression. For example, your table's rows may represent files from
55which you want to extract a piece of metadata, but the extraction code
56cannot be expressed in a single statement. You could provide the
57Python statements needed to open each file, extract the metadata, and
58assign it to a variable. Your field expression could then reference
59the variable, causing the metadata value to be stored in the
60field.</p></dd></dl><h3>Returns</h3><dl><dt><var>outputTable</var></dt><dd><table cellpadding="0" cellspacing="0" style="margin-top: 1.0em;"><tr valign="baseline"><td class="metadataTitle">Python type:</td><td class="metadataValue"><tt class="class">unicode</tt></td></tr><tr valign="baseline"><td class="metadataTitle">Minimum length:</td><td class="metadataValue">1</td></tr><tr valign="baseline"><td class="metadataTitle">Maximum length:</td><td class="metadataValue">255</td></tr><tr valign="baseline"><td class="metadataTitle">Must exist:</td><td class="metadataValue">No</td></tr></table><p>Table that contains the field to calculate.</p></dd></dl><div class="navigation"><div class="online-navigation"><p></p><hr /><table align="center" width="100%" cellpadding="0" cellspacing="2"><tr><td class="online-navigation"><a title="Field Class" href="Class_GeoEco.DataManagement.Fields.Field.html?format=raw"><img src="previous.png?format=raw" border="0" align="bottom" height="32" width="32" alt="Previous Page" /></a></td><td class="online-navigation"><a title="Field Class" href="Class_GeoEco.DataManagement.Fields.Field.html?format=raw"><img src="up.png?format=raw" border="0" align="bottom" height="32" width="32" alt="Up one Level" /></a></td><td class="online-navigation"><a title="CalculateArcGISFields Method" href="Method_GeoEco.DataManagement.Fields.Field.CalculateArcGISFields.html?format=raw"><img src="next.png?format=raw" border="0" align="bottom" height="32" width="32" alt="Next Page" /></a></td><td align="center" width="100%">GeoEco Python Reference</td><td class="online-navigation"><a title="Table of Contents" href="TableOfContents.html?format=raw"><img src="contents.png?format=raw" border="0" align="bottom" height="32" width="32" alt="Table of Contents" /></a></td><td class="online-navigation"><a title="Module Index" href="ModuleIndex.html?format=raw"><img src="modules.png?format=raw" border="0" align="bottom" height="32" width="32" alt="Module Index" /></a></td><td class="online-navigation"><img src="blank.png?format=raw" border="0" align="bottom" height="32" width="32" alt="" /></td></tr></table><div class="online-navigation"><b class="navlabel">Previous:</b> <a class="sectref" href="Class_GeoEco.DataManagement.Fields.Field.html?format=raw">Field Class</a> <b class="navlabel">Up:</b> <a class="sectref" href="Class_GeoEco.DataManagement.Fields.Field.html?format=raw">Field Class</a> <b class="navlabel">Next:</b> <a class="sectref" href="Method_GeoEco.DataManagement.Fields.Field.CalculateArcGISFields.html?format=raw">CalculateArcGISFields Method</a> </div><hr /><span class="release-info">Marine Geospatial Ecology Tools version 0.6</span></div></div></body></html>
Note: See TracBrowser for help on using the browser.