TransWikia.com

ArcPy Calculate Field how to convert distances from decimal degree to meters

Geographic Information Systems Asked on January 13, 2021

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)

One Answer

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.

Correct answer by Vince on January 13, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP