The new field calculator in ArcGis Pro

 One of the most common tools for data management is the famous ArcGIS Field Calculator.   When you are on a tabular view, by right- clicking on the field name (column), you find the option “Field Calculator” which opens the famous calculator:

 Similarly ArcGis Pro performs the same operation and opens the field calculator window:

 

At first glance it looks like it’s the same thing, with a modification in the setting up. But, there’s more than that.

Goodbye ArcMap calculator, welcome Toolbox Calculator

But on the contrary, this is not the same calculator as the one retrieved by the attribute table.
In ArcMap you have an interactive calculator called ArcMap or ArcCatalog, and a “batch” calculator that you can use, indirectly, for models treatment, or directly, from the Toolbox.

In ArcGis Pro, it’s this second use that is retrieved from the table.

In theory, now it’s easier since you only have one working mode. On the other side, there are some small details to keep in mind. The first, and rather important, is that unlike your ArcMap calculator, since the new one is part of the geprocessor, it abides by the environmental parameters.  Particularly, if you have a defined treatment range, the calculation will, only, be performed on those records that are within this range. The rest of the records will not be calculated.

To change the environment parameters, you must click on “Environments” at the top of the window.

Goodbye VB, welcome Python

In the ArcMap calculator you have, at the top of the window, two buttons that allow you to choose the language used to write complex expressions in the calculator . You have the choice between Script VB and Python. With ArcGis Pro, more buttons, more choices. Or you can try with Python, but… !

Made public many times and started in stages for a few years, the abandonment of VB by ESRI has been completed with the introduction of ArcGis Pro.
If you had stored calculations in VB, you must have quitted and rewrite them in Python.

On the other side, Python is a real plus regarding the calculator possibilities. Just as much in VB you were limited to ongoing registration, now you have functions such as auto increment ( ) that generates a sequential identifier; accumulate (), which calculates the accumulated values of a column (each line is the result of the sum of its value plus the value of the previous line), percentIncrease () which is similar but stores the percentage in relation to the previous line.

Another interesting feature is that Python works on the attributes area and length, but by changing the default units. You can to have areas in square meters and perform the calculations in km², etc…

Regarding the length calculations, especially for users of the Lambert 93 projection (not the CC) you can calculate the geodesic lengths instead of flat lengths. This prevents lengths miscalculations with Lambert 93.

Besides, Python expressions can use geometric properties such as: type, range, centroid, firstPoint, lastPoint, area, length, isMultipart and partCount (eg shape.area!).

Getting started with the new calculator

What is absolutely needed to know before getting started, is that the field names are now delimited by exclamation marks: !fieldname!

Another little detail is that when you double-click the field name as before, it is copied in the calculation window. On the other side, if you want to replace a field that is already in the calculation window, you had to select it in advance, and then double-click the name of the new field. This no longer works. Instead, you have to clear the field in the calculation window since the double click only adds a field name, it does not replace the selection.

Here we cannot cover a full Python course. There are quite a few in the web. On the right ArcGis Pro field calculator window (Helpers) lists the main available functions.
By alphabetical order hazard, you find as first “Helper”, the function conjugate ( ). If you believe you can start inspecting what Python does with this function, you are selecting the worst departure !

Conjugate ( ), as imag (), real () are functions to work with imaginary numbers! Sincerely, I doubt that this is your case.

For start, take a look to the strings functions (capitalize, rstrip, replace), mathematical functions (math. *) and especially, at the very bottom of the list, the new functions we have discussed (accumulate, percentage, etc.).

Lastly, before getting started, if you are not familiar with Python and you set going on your own, remember that, in Python, the lines comply an indentation. When you have scripts on several lines, starting by clicking two spaces or no space, everything changes!

Leave a Reply

Your email address will not be published. Required fields are marked *