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:
- Legacy tree GPS xy coordinates (i.e. a center location in the canopy gap)
- Bearing to sapling from the legacy tree (e.g. 218 degrees)
- 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