Saturday 17 March 2018

arcgis desktop - How to convert bearing, distance, xy coordinate measurements to point shapefile?


I have a natural resources dataset where individual seedlings in canopy gaps were recorded from a center "legacy tree" within each canopy gap. Each sapling has the following measurements associated with it:



  1. Legacy tree GPS xy coordinates (i.e. a center location in the canopy gap)

  2. Bearing to sapling from the legacy tree (e.g. 218 degrees)

  3. Distance in meters from the legacy tree


There are thousands of these individual tree locations, so an automated approach would be best.


How can I convert this dataset into a point shapefile/featureclass? ArcGIS, Arcpy/Python and R solutions would be especially useful.



Answer




The complex number support in python is a simple way to do operations against Cartesian coordinates. The cmath module provides a function that converts a distance and angle into a vector. This assumes that the coordinates are in a suitable projection.


import cmath
import math

x = 0
y = 0
angle = 0
distance = 100

#convert bearing to arithmetic angle in radians

angle = 90-angle
if angle<-180:
angle= 360+angle

angle = math.radians(angle)


start = complex(x,y)

movement = cmath.rect(distance,angle)


end = start+movement

endx = end.real
endy = end.imag

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...