How do I use arcpy.CalculateField_management()
to convert a column with distances in degrees to meters? I don't see this specific example in the docs. This post, answer by "dlee-esristaff" implies it can be done in two steps but I am having trouble implementing it.
Specifically, I don't see how to specify my source field (DISTANCE
) and target field (dist_m
) in the arcpy.CalculateField_management()
inputs. Do I need to write a short function to do this, and then call the function? (If so, I am not sure how to write the function, I think !shape.geodesicLength@meters!
is used but I am not sure how.)
Using ArcMap 10.7 Advanced license.
Also, please note that everything is done in WGS84, instead of UTM (hence distances in degrees) because the source SHPs are from all over the world and we don't have local UTM EPSGs. The input SHP here is a point SHP which is output from the Point Distance tool.
arcpy.AddField_management(myshp, 'dist_m', "FLOAT")
# expression = ??? somehow get !shape.geodesicLength@meters! from ['DISTANCE'] into ['dist_m']
# codeblock = ??? somehow get !shape.geodesicLength@meters! from ['DISTANCE'] into ['dist_m']
# ??? arcpy.CalculateField_management(myshp, ['dist_m'], expression, "PYTHON3", codeblock)
CalculateField
,PointDistance
and DA Cursors. You must start with two shapes. Please Edit the question to ask something that is ppssible (converting Cartesian degrees obtained elsewhere is not possible) – Vince Aug 14 '20 at 1:16