1

I have a grid of points created from NOAA oceanic current data which has the currents as east and north directions that I'm needing formatted as an overall speed(got that part) as well as the direction the water is flowing in azimuth degrees.

How do I get from point A to point B? Watched a few videos that kinda attempt to describe it but between poor English or they're just typing and music overlaid I'm not getting very far and my math really is a bit on the pathetic side.

I'm thinking it's something to do with Cosine or Tangent and I maybe need to add 90degrees based on whether the northing or easting is a negative value or not.

Currently everything's in ArcMap if there's a tool to do this...or I have the field calculator.

1 Answer 1

1

I created a Python (2.7) script quite a while back where I ported formulas over to Python. I don't claim to understand all the math behind it but I do know it does work.

If your coordinates are in a geographic coordinate system (e.g. 41.977880,-91.665623) this script could work or you could at least reverse engineer the code's math to fit your needs.

The formula information for calculating bearings was taken from this page under the "Bearing" topic.

This code was part of my answer for this question on Getting all vertex lat, long coordinates every 1 meter between two known points using PHP?. So there is also a port of this code to PHP as well as Javascript.

Here is my python code to get the azmuth in degrees:

import math

def calculateBearing(lat1,lng1,lat2,lng2):
    '''calculates the azimuth in degrees from start point to end point'''
    startLat = math.radians(lat1)
    startLong = math.radians(lng1)
    endLat = math.radians(lat2)
    endLong = math.radians(lng2)
    dLong = endLong - startLong
    dPhi = math.log(math.tan(endLat/2.0+math.pi/4.0)/math.tan(startLat/2.0+math.pi/4.0))
    if abs(dLong) > math.pi:
        if dLong > 0.0:
            dLong = -(2.0 * math.pi - dLong)
        else:
            dLong = (2.0 * math.pi + dLong)
    bearing = (math.degrees(math.atan2(dLong, dPhi)) + 360.0) % 360.0;
    return bearing


#Cedar Rapids, Iowa
startLatitude = 41.977880
startLongitude = -91.665623

#Chicago, IL
endLatitude = 41.878114
endLongitude = -87.629798

azimuth = calculateBearing(startLatitude ,startLongitude ,endLatitude ,endLongitude)

print "Your Initial Azmuth Would be {0} Degrees".format(round(azimuth,2))

The output of this script would look like the following: enter image description here

Hope this helps or at least gets you on the right track.

Also, you could just plug that function into that field calculator if you have the correct input and it could calculate the azimuth without major modification with the field calculator like so:

enter image description here

4
  • I appreciate your help...it's along the lines of what I am trying to do, if I knew how far the water traveled north or east I could probably calculate the second point but I only know the speed at which it is traveling so I'm not sure that gets me there. I'm at about the same point as you on the whole math part :)
    – tarnis
    Commented Apr 17, 2018 at 18:36
  • Please clarify your question. You have coordinates in a projected CRS and each point has speed data and direction data? You want to know where the water from point A will be after some time based on this speed and direction? If so, how much time? What values are the directions in, true north, magnetic north, grid north?
    – GBG
    Commented Apr 17, 2018 at 18:45
  • I have lat/long of a current with the velocity in meters/second it is moving north/south and east/west. I need the direction in degrees it is moving as well as its over all velocity in knots.
    – tarnis
    Commented Apr 18, 2018 at 12:52
  • You can’t just get an azimuth with speed and a start point. To get direction you need a start and end point. If you are following river center lines you could get that by calculating distance traveled along the river centerline if you have the speed and a defined duration of time (6mph for 5 min equals 2640ft or .5 miles). You then could calculate the lat and long for the end point along that line (in theory) if the speed is a constant.
    – PMK
    Commented Apr 18, 2018 at 14:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.