I have a point, and based on this point, a certain distance and a bearing I want to calculate the resulting coordinates. And I was wondering how to do this in arcpy, while the spatial reference system is honored.
Lets say I am in EPSG 3006, have an arbitrary point (57.6222951N,18.8333582E), a distance of 2000 meter, and a bearing of 345 degree...
How can I achieve that with arcpy?
Solved! Go to Solution.
For that, you have to use PointGeometry
# what you have
coordinates = (57.6222951, 18.8333582)
sr = 4326
# what you want
bearing = 345
distance = 2000
target_sr = 3006
# create a point geometry from the given coordinates and project it into the target coordinate system
y, x = coordinates
p = arcpy.PointGeometry(arcpy.Point(x, y), arcpy.SpatialReference(sr))
p_proj = p.projectAs(arcpy.SpatialReference(target_sr))
# get the target point geometry
p_target = p_proj.pointFromAngleAndDistance(bearing, distance)
# print coordinates
p_target.firstPoint
#<Point (728268.6981234621, 6395030.819025804, #, #)>
For that, you have to use PointGeometry
# what you have
coordinates = (57.6222951, 18.8333582)
sr = 4326
# what you want
bearing = 345
distance = 2000
target_sr = 3006
# create a point geometry from the given coordinates and project it into the target coordinate system
y, x = coordinates
p = arcpy.PointGeometry(arcpy.Point(x, y), arcpy.SpatialReference(sr))
p_proj = p.projectAs(arcpy.SpatialReference(target_sr))
# get the target point geometry
p_target = p_proj.pointFromAngleAndDistance(bearing, distance)
# print coordinates
p_target.firstPoint
#<Point (728268.6981234621, 6395030.819025804, #, #)>