0

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)
  • You can calculate distance between two geometries, but you can't convert Cartesian degrees to ground units. There are many examples of how to do the former in the documentation (none of which mix the several different options of token parsing in the example you have given). – Vince Aug 14 at 1:05
  • 1
    @Vince, this post (community.esri.com/thread/7181), answer by "dlee-esristaff" steps 1 & 2 suggests this can be done, or am I misreading? thx – AlexS1 Aug 14 at 1:10
  • You can't mix-n-match the syntaxes of 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 at 1:16
  • @Vince the fact that it's not possible is an answer, no? And someone else could have this question and benefit from knowing it's not possible? – AlexS1 Aug 14 at 1:21
0

The only way to compute geodesic distance between two points is to have two points. The only way to meet that criteria with a Cartesian decimal degrees distance is to have one of the points and the bearing, also in on Cartesian degrees, between that point and the other (then you can reprooduce the second point and calculate a proper bearing and distance on a spheroid). If all you have is Cartesian degree distance, then I'd recommend dropping the column, because it's useless for any practical purpose.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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