Can anyone give me some help on this Python field calculation? I'm passing two sets of Latitude and Longitude in order to calculate the distance between the two values.I get a general error when I run this. I have tried experimenting with a few things, but I haven't been able to get it to work. Any suggestions would be much appreciated!

Pre-Logic Script Code: [Dist_MemCh1 is the field name that is being calculated, Y_0, Y_1, X_0, X_1 are the fields that are being used to calculate the distance

Here is my code:

def Dist_MemCh1(Lat0, Lat1, Lon0, Lon1):

dlat = Lat0 - Lat1

dlon = Lon0 - Lon1

a = (math.sin(math.radians(dlat)/2 )*math.sin(math.radians(dlat)/2 )) +

math.cos(math.radians(Lat1) )*math.cos(math.radians( Lat0 )

)*(math.sin(math.radians(dlon)/2 )*math.sin(math.radians(dlon)/2 ))

c = 2*math.atan2( math.sqrt(a ),math.sqrt(1-a ))

H = c * 3958.756

return H

[Dist_MemCh1=this is the name of the field being calculated]

Dist_MemCh1( !Y_0!, !Y_1!, !X_0!, !X_1!)

What is your specific error message? Check the geoprocessing results for specific error message? When I tried your code, I got a Python syntax error. I am interested if you are getting the same.

UPDATE: It appears you have left off line continuation backslashes in your definition of a. I added the necessary backslashes, and was able to get the code to work.