I have a point shapefile, and in its attribute table I have some coordinates (DISP_LON, DISP_LAT) which are slightly different from the actual location of the points.
I want to calculate the distance between actual point location and attribute table given co-ordinates, and want to insert in attribute table; preferably in Python, because I don't have ArcObjects SDK.
Initially I was trying to create line from the attribute coordinate and the Shapefile point coordinate. and then calculate line length.
To do some rough work I calculated the point lat-log in two new field name RP_LAT and RP_LONG and tried below code to create line by calculating distance between these two sets of coordinates:
import arcpy in_rows = arcpy.SearchCursor("C:\Temp\PA.shp") point = arcpy.Point() array = arcpy.Array() featureList =  cursor = arcpy.InsertCursor("C:\Temp\Line.shp",["SHAPE@"]) feat = cursor.newRow() for in_row in in_rows: # Set X and Y for start and end points point.X = in_row.RP_LON point.Y = in_row.RP_LAT array.add(point) point.X = float(in_row.DSPL) point.Y = float(in_row.DSPLT) array.add(point) # Create a Polyline object based on the array of points polyline = arcpy.Polyline(array) # Clear the array for future use array.removeAll() # Append to the list of Polyline objects featureList.append(polyline) # Insert the feature feat.shape = polyline cursor.insertRow(feat) del feat del cursor
But the result is unexpected, it created strange long lines and empty records in a line shapefile.
My ultimate goal is find to distance of point coordinates and attribute given coordinates.