It seems to me that ArcGIS Pro is not rounding my numbers correctly when I use Python in Calculate Field. Or my expression is incorrect.
Here is my example:
The Shape_Area of a feature is 7464.72748
My Calculate Field expression is
str(int(round(round(!Shape_Area!), -1)))
I would think this should result in a string value of 7470, but it gave me 7460.
Where am I going wrong? Shouldn't round(7464.72748) give me 7465 more or less?
And then round(7465, -1) give me 7470?
Solved! Go to Solution.
Please also have a look at the "decimal" module of Python:
https://docs.python.org/3.6/library/decimal.html
It may offer functions you need as well. You can import the module in e.g. the Calculate Field tool.
Rounding is ridiculous.
Joining up an "engineer's" spreadsheet with sorta-rounded-area numbers (integers) with a converted CAD drawing takes more effort than it should. This is what my code block Calculate Field expression had to look like to get as close as I could (though, I likely could have gotten closer with more ceilinging and flooring, but I got lazy):
import math
def ceiling(parcel, area):
return str(parcel) + " - " + str(int(math.ceil(math.floor(area) / 10)) * 10)
__esri_field_calculator_splitter__
ceiling(!Parcel!, !Shape_Area!)
thanks, Dan, for all the assistance!
engineers??? cool! use the base 9 thing.. that will keep them going for a few hours