table with 2 sets X, Y

110
1
02-20-2019 02:10 PM
Highlighted
Occasional Contributor III

I have a table that has an origin X, Y (XP YP) and a destination X, Y (XD, YD) and an in-house 3rd party program that creates a OD vector line, however, this 3rd party tool reads lat/lons only. is there a formular to convert X to longitude etc. This is a table so calculate geometry is not available. 

Tags (3)
Reply
0 Kudos
1 Reply
Highlighted
MVP Regular Contributor

If you know the spatial reference of your x,y coordinates, you could use something like the following:

inSR = arcpy.SpatialReference(3857) # web mercator (use your spatial reference here)
outSR = arcpy.SpatialReference(4326) # wgs_1984 (lon-lat)

ptGeo = arcpy.PointGeometry(arcpy.Point(x,y),inSR).projectAs(outSR)
print (ptGeo.centroid.X, ptGeo.centroid.Y) # lon-lat of point‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

See Reprojecting tabular data without creating feature class? for more discussion.

Reply
0 Kudos