Moving a point by distance and bearing

22157
6
09-17-2015 05:09 AM
Labels (2)
CGrantham
New Contributor II

I have a series of points along a transect that need to be projected various distances and directions from where the point was taken, each point being different.

Real life example is when conducting deer surveys for distance sampling, a transect is driven and once a deer or group of deer is observed, a waypoint is taken, a laser rangefinder is used to measure distance, and a bearing is taken to get an exact location.  How can these points be moved to show the location of the animal without creating new points if possible?

Please, no coding answers.

6 Replies
CGrantham
New Contributor II

Thanks Dan,

The last link you provided was the closest. Unfortunately, I knew about this action but I was trying to avoid creating a new point each time. I have a few hundred points to "edit". I do not know the exact coordinates, only the coordinates of where the point was taken. I then wanted to plug in the distance and bearing from that coordinate to move the existing point to where the animals were located.

As far as the coding, my experience is quite limited in that realm and I wasn't sure how effective it would be if all points need to be moved and each point needing a specific code based on the criteria.

Chad Grantham

Extension Associate

cgrantham@ag.tamu.edu<mailto:cgrantham@ag.tamu.edu><mailto:cgrantham@ag.tamu.edu>

Texas A&M Institute of Renewable Natural Resources

1919 Oakwell Farms Parkway, Suite 100 | San Antonio, TX 78218

Office 210-295-0511

Cell 214-642-9406

irnr.tamu.edu

JeffPapirtis
New Contributor III

Python is going to be your best friend for this kind of stuff.

You have all the pieces that you need in order to calculate the new Location.  And it will be far easier to create 200 new points than edit and move 200.

Think of your initial points as your input.

import arcpy

import math

#r tells python this is a literal string, ignore escape squeunces like \n for newline

fc = r'Path to your feature class'

newFc = r'Path to your new feature class'

#the columns in your source table or feature class

feilds = ['x', 'y', 'distance','bearing']

outFeilds = ['SHAPE@','x', 'y', 'distance','bearing']

sCursor = arcpy.da.SearchCursor = (fc,feilds)

for row in sCursor:

     inputX = row[0]

     inputY = row[1]

     distance = row[2]

     bearing = row[3]

     #make sure you convert your bearing to Radians:

     bearing = radians(bearing)

     newX = inputX + distance * math.cos(bearing)

     newY = inputY + distance * math.sin(bearing)

      point = arcpy.point(newX,newY)

    

     #Insert the new point into the new FeatureClass

     iCursor = arcpy.da.InsertCursor(newFC,outFeilds )

     temp = [point,newX,newY,distance,bearing]

     iCursor.insertRow(temp)

     del iCursor

del sCursor

Use Arcpy Data Access Module to create a Search Cursor and then a for loop to iterate through each record.  output can be made by creating an Insert Cursor to a new feature class.

It may take just as long to do it this way the first time, but you will have a new skill that can be utilized many times over, and quicker.  Work hard to be lazy.

That's it.  Problem solved in less than 50 lines of code.  Most of that is new lines.  Should take about 15 seconds to process.

Thanks,
Jeff

DarrenWiens2
MVP Honored Contributor

There are a few mistakes in the script above, which will make it tricky (impossible) for a beginning to figure out. Particularly, needs to be "math.radians()", and typo in newFc vs newFC, all of which is compounded by not using the 'with' statement, so sCursor never gets deleted and causes yet more problems. I guess the point is, sometimes the out-of-the-box tools are worth it.

>>> import arcpy # import arcpy
... import math # import math
... fc = r'C:\junk\start_points.shp' # change to your existing input feature class
... new_fc = r'C:\junk\new_points.shp' # change to your existing output feature class
... fields = ['POINT_X', 'POINT_Y', 'DISTANCE','BEARING'] # existing fields in input
... outFields = ['SHAPE@','x', 'y', 'distance','bearing'] # existing fields in output
... iCursor = arcpy.da.InsertCursor(new_fc,outFields ) # insert cursor
... with arcpy.da.SearchCursor(fc, fields) as sCursor: # search cursor
...     for row in sCursor: # loop through rows in search cursor
...         inputX = row[0] # 1st field in search cursor
...         inputY = row[1] # 2nd field in search cursor
...         distance = row[2] # 3rd field in search cursor
...         bearing = row[3] # 4th field in search cursor
...         bearing = math.radians(float(bearing)) # convert to radians
...         newX = inputX + distance * math.cos(bearing) # calc new X
...         newY = inputY + distance * math.sin(bearing) # calc new Y
...         point = arcpy.Point(newX,newY) # create new point
...         temp = [point,newX,newY,distance,bearing] # organize new attributes
...         iCursor.insertRow(temp) # write new row
... del iCursor # delete insert cursor
DarrenWiens2
MVP Honored Contributor

You can do this all using out-of-the-box ArcGIS tools:

1.) You need a table containing the observation point coordinates, bearing, and distance. If you need to add coordinates, use Add XY Coordinates tool.

2.) Run Bearing Distance to Line

3.) Use Add Geometry Attributes to calculate the END_X and END_Y coordinates

4.) Make XY Event Layer using the END_X and END_Y coordinates

5.) Export the event layer to a feature class on disk

ChadKopplin
Occasional Contributor III

In your GPS unit are you should be able to perform an offset of your waypoint.  Also, I did find this tool, maybe it could help, because if you can use a distance tool to create this line then you could convert the line to points and be left with your survey points.

ArcGIS Desktop Help 9.2 - Creating lines with the Offset Line window

0 Kudos