# Creating points based on distance and bearing from survey point using QGIS?

I am plotting witness tree data to calculate pre-settlement tree density. I have a shapefile with points along section lines (square miles) at each half mile. I am making another table that contains tree data - distance, bearing, and diameter - related by survey point to the existing shapefile attribute table.

Is there a way to create points on the map for the trees based on the distance and bearing from each survey point?

It is pure trigonometry or vector calculus problem and you can get the result using polar coordinates (center of the figure) or the direction cosines (right) with 2D cartesian coordinates : ``````import math
point = (-1004.00, 635.00)
distance = 160
bearing =  103
angle =     90 - bearing

# polar coordinates

dist_x, dist_y = \
(distance * math.cos(angle), distance * math.sin(angle))
print dist_x, dist_y
#(155.89921036563763, -35.992168695018407)
xfinal, yfinal = (point + dist_x, point + dist_y)
print xfinal, yfinal
#(-848.1007896343624, 599.00783130498155)

# direction cosines

cosa = math.cos(angle)
cosb = math.cos(bearing)
xfinal, yfinal = \
(point +(distance * cosa), point+(distance * cosb))
print xfinal, yfinal
#(-848.1007896343624, 599.00783130498155)
``````

Result • True, but it's misleading to state that "polar coordinates" and "direction cosines" as being different. The only difference -- which i corrected in your code -- is using sin(T) versus cos(pi/2-T). Jun 12, 2014 at 4:26

I actually had to do something similar to this a couple of days ago. I found it easiest to do the calculations in Excel and then create an XY Events table in ArcGIS. I'm not familiar with QGIS but here is how you can do the calculations in Excel.

I'm assuming that there will be two columns in the spreadsheet with the following data

• Column A: Compass Bearing in decimal degrees
• Column B: Distance from base point in metres

You will then need to create two calculated columns (note these formalae are in Excel format)

• Column C: =SIN(RADIANS( [Column A]))*[Column B]
• Column D: =COS(RADIANS([Column A]))*[Column B]

Column C will contain the X displacement in metres from your base point and Column D will contain the Y displacement in metres from your base point. If you add the value in Column C to the X coordinate of your base point and the value in Column D to the Y coordinate of your base point you will have the coordinate of the tree.

• The formulae seem to have got swapped... Should be: `Column C: =SIN(RADIANS( [Column A]))*[Column B]` and `Column D: =COS(RADIANS([Column A]))*[Column B]` Sep 14, 2016 at 14:18
• Worked perfectly. Did this in Python like this gdf['C'] = np.sin(np.deg2rad(gdf['A']))*gdf['B'] May 12, 2022 at 7:55

So you have a survey point with x,y (and z?) coordinates, and information like "tree 1 is at 227° bearing, 12m distance. tree 2 is at 26° bearing, 200m distance"? This will then be a trigonometry problem, calculating the actual tree position in x,y coordinates. So i would first convert my coordinates to cartesian coordinates (e.g. UTM), then it becomes a simple problem of trigonometry to calculate each trees position. This could the be done e.g. with python, or you could create a table in e.g. excel or openCalc and then join that to your shapefile (by tree id or sth.)

• Hi,Yes that's it exactly. It's Florida so the Z component is trivial, and the distances are typically less than 300 meters. Converting to UTM and writing a trig function was my "plan B" if there wasn't an easier way. I might give it a try first in python - might be a good way to learn it a little better. If I need to I can use R. Thanks!
– Tim
Oct 31, 2013 at 15:11