1

I am using ArcMap 10.1.

In the below image, I am trying calculate my XY_LINK field to return the values from Point_X and Point_Y field.

Example of final result: {2474785.499662}{376075.063004}

enter image description here

My code is as follows:

Output(!POINT_X!, !POINT_Y!)

def Output(POINT_X, POINT_Y):
    FPX = round(float(X, 4)
    FPY = round(float(Y, 4)
    return "{%(FX)012.4f}{%(FY)012.4f}" % {'FX': FPX, 'FY': FPY}

The error I am receiving is as follows. (I am brand new to Python)

Failed to execute. Parameters are not valid. Error 000989: Python syntax error: Parsing error SyntaxError: invalid syntax (line 3)

I don't understand why the error is being returned on Line 3 and not like 2 also since they are the same with the exception of the X and the Y.

0

1 Answer 1

2

You defined your variables as POINT_X and POINT_Y, but you use in the function X and Y. Then i also would go for an easier approach and not the old string formatting method, that is harder to read. In the code block you can put the following that is more logical (in my opinion):

def Output(POINT_X,POINT_Y): return '{'+str(round(float(POINT_X),4))+'}'+'{'+str(round(float(POINT_Y),4))+'}'

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.