For points, I added some geometry fields (POINT_X and POINT_Y as automatically generated), which were created as Double type.
I want them to display as my label (e.g., "35.596821, -81.235600"). I went to the numeric formatting and changed to 6 as that's the number of decimal places I want.
For some (not all; most are fine), there is infinite repeat (e.g., "-81.39291999999999"). Here is my label code: Round($feature.POINT_Y, 6) + ", " + Round($feature.POINT_X, 6)
I've played around with the field calculator, even trying to create new fields and convert to different types, but that's not working.
HELP!!!
Solved! Go to Solution.
Add a text field, use that as the convertor . The format conversion will perform if point_x is indeed a number, it should fail with an error otherwise.
If you can replicate my example in your python IDE using python 3.5, then there is something wrong with the labelling
My example is Python... make sure that you specify python if there is any other options
If you just need the field for labelling (that is another issue that can probably be solved directly)
I take it that is Arcade?
In python you can use the formatting characteristics builtin to convert a numeric value to string with complete control over the justification and number of decimals.
"{:10.6f}".format(-81.39291999999999)
'-81.392920'
I am sure equivalent abilities exist in other labelling languages
Tried this in Python for the label, and it didn't work. Not sure what I'm missing. Is that truly all (with POINT_X replacing 81.39291999999) that should be needed?
Add a text field, use that as the convertor . The format conversion will perform if point_x is indeed a number, it should fail with an error otherwise.
If you can replicate my example in your python IDE using python 3.5, then there is something wrong with the labelling
My example is Python... make sure that you specify python if there is any other options
Ok, figured it out just now. It was kind of backwards. I was able to go off the original Double field (POINT_X). In Python, and the decimal places and preserved characters were in opposite positions from what I thought:
'{:6.10}'.format([POINT_X])
Still seems inefficient, and something is off with the Round() function I'd still be curious to figure out, but at least it works. Thank you!
Ensure you are working on a layer pointing to a Feature Class, not an Event Layer.
What happens if you write a similar expression for Labeling as follows (Python Parser):
round(float([POINT_X]), 6) + ", " + round(float([POINT_Y]), 6)
it you calculate the values into a text field, as in my suggestion above, then you can control the output format easily
This is what happened when I tried your code
is that a text field?
python parser in the field calculator
I just tried it
a = 91.1234567890
"{:6.2f}".format(a)
' 91.12'