Select to view content in your preferred language

# Calculating point based and start point, distance and angle

1431
1
11-08-2022 05:25 AM
Labels (3)
by
Occasional Contributor III

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?

- We are living in the 21st century.
GIS moved on and nobody needs a format consisting out of at least three files! No, nobody needs shapefiles, not even for the sake of an exchange format. Folks, use GeoPackage to exchange data with other GIS!
1 Solution

Accepted Solutions
MVP Frequent Contributor

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, #, #)>``````

Have a great day!
Johannes
MVP Frequent Contributor

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, #, #)>``````

Have a great day!
Johannes