Select to view content in your preferred language

Calculating point based and start point, distance and angle

1502
1
Jump to solution
11-08-2022 05:25 AM
Labels (3)
TomGeo
by
Frequent Contributor

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!
0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
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

View solution in original post

1 Reply
JohannesLindner
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