comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Finding distance with longitude and latitude
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Finding distance with longitude and latitude [message #83960] Tue, 16 April 2013 09:23
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
gpeterso@ucsc.edu writes:

> Thanks david, would you have any idea how to use the newfound distance to then graph the contour profile with?

Well, to be honest, I don't think I care about the distance at all if
"graphing" the contour profile is what I am after. Maybe I would use it
to label the graph.

I would probably display the great circle distance on the map by just
putting the profile on the map with cgPlotS, using the latitude and
longitude values you calculated, perhaps color coded with elevation
values. If I wanted to show more detail, I might add a plot of the
contour values at your profile locations just above the map.

I would also never write this program so that it has to use the Cursor
command. I'd write it as a widget program. This would make things *so
much* easier when you wanted to display the map and the contour profile
together in the same window. You could toggle between the map and the
map with contour profile, allow the user to draw multiple contour
profiles, and just generally have a LOT more control over what is
happening in your program. :-)

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: Finding distance with longitude and latitude [message #83961 is a reply to message #83960] Tue, 16 April 2013 08:46 Go to previous message
gpeterso is currently offline  gpeterso
Messages: 22
Registered: February 2013
Junior Member
On Sunday, April 14, 2013 4:57:14 PM UTC-7, David Fanning wrote:
> gpeterso@ucsc.edu writes:
>
>
>
>> Now I am trying to find the distance between longitude and latitude points using the vincenty formula form here: http://en.wikipedia.org/wiki/Great-circle_distance. I have completed this and I am getting logical answers I am just wondering if it is accurate or a correct.
>
>
>
> You could test it by seeing if you get the same answers with Map_2Points
>
> in the IDL library.
>
>
>
> Cheers,
>
>
>
> David
>
>
>
>
>
>
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")


Thanks david, would you have any idea how to use the newfound distance to then graph the contour profile with?
Re: Finding distance with longitude and latitude [message #83982 is a reply to message #83961] Mon, 15 April 2013 04:13 Go to previous message
seanelvidge is currently offline  seanelvidge
Messages: 11
Registered: January 2013
Junior Member
> Now I am trying to find the distance between longitude and latitude points using the vincenty formula form here: http://en.wikipedia.org/wiki/Great-circle_distance. I have completed this and I am getting logical answers I am just wondering if it is accurate or a correct.
>

Vincenty's formula is the traditional approach to solving geodesic problems on an ellipsoid. However this method can fail under certain conditions, one of which being for near antipodal points.

However recently, Karney described a more accurate, robust and quicker solution to this problem using Newton's Method. (Described in his paper 'Algorithms for Geodesics' http://link.springer.com/content/pdf/10.1007%2Fs00190-012-05 78-z).

On Karney's site he has implementations of this for C++, C, Fortran, Python, Javascript and Matlab. In adition he provides an online calculator (http://geographiclib.sourceforge.net/cgi-bin/GeodSolve).

If you would like to use our IDL implementation of Karney's solution to this problem you can download it here: http://seanelvidge.com/wp-content/uploads/2013/04/inverse_ge odesic.pro
Re: Finding distance with longitude and latitude [message #83983 is a reply to message #83982] Sun, 14 April 2013 19:38 Go to previous message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
IDL doesn't have an ATAN2 function. Instead, you call ATAN with two arguments. Look at the online help for ATAN

On Sunday, April 14, 2013 9:17:41 PM UTC-4, gpet...@ucsc.edu wrote:
> On Sunday, April 14, 2013 4:49:07 PM UTC-7, wlandsman wrote:
>
>> On Sunday, April 14, 2013 7:45:40 PM UTC-4, wlandsman wrote:
>
>>
>
>>> On Sunday, April 14, 2013 7:22:44 PM UTC-4, gpet...@ucsc.edu wrote:
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>> a=sqrt((cos(lat2)*sin(dlon))^2 + (cos(lat1)*sin(lat2)-sin(lat1)*cos(lat2)*cos(dlon))^2)/(sin( lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(dlat))
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> c= atan(a)
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> The Wikipedia article you quote says
>
>>
>
>>>
>
>>
>
>>> "When programming a computer, one should use the atan2() function rather than the ordinary arctangent function (atan()), in order to simplify handling of the case where the denominator is zero, and to compute \Delta\widehat{\sigma}\;\! unambiguously in all quadrants"
>
>>
>
>>
>
>>
>
>> I accidentally hit SEND too soon, but you want to use the two argument form of ATAN, e.g.
>
>>
>
>>
>
>>
>
>> c = atan( numerator, denominator)
>
>>
>
>>
>
>>
>
>> --Wayne
>
>
>
> When ever i tried to use atan2() it said that the variable was undefined. I dont know why that would happen
Re: Finding distance with longitude and latitude [message #83984 is a reply to message #83983] Sun, 14 April 2013 18:17 Go to previous message
gpeterso is currently offline  gpeterso
Messages: 22
Registered: February 2013
Junior Member
On Sunday, April 14, 2013 4:49:07 PM UTC-7, wlandsman wrote:
> On Sunday, April 14, 2013 7:45:40 PM UTC-4, wlandsman wrote:
>
>> On Sunday, April 14, 2013 7:22:44 PM UTC-4, gpet...@ucsc.edu wrote:
>
>>
>
>>
>
>>
>
>>> a=sqrt((cos(lat2)*sin(dlon))^2 + (cos(lat1)*sin(lat2)-sin(lat1)*cos(lat2)*cos(dlon))^2)/(sin( lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(dlat))
>
>>
>
>>
>
>>
>
>> c= atan(a)
>
>>
>
>>
>
>>
>
>> The Wikipedia article you quote says
>
>>
>
>> "When programming a computer, one should use the atan2() function rather than the ordinary arctangent function (atan()), in order to simplify handling of the case where the denominator is zero, and to compute \Delta\widehat{\sigma}\;\! unambiguously in all quadrants"
>
>
>
> I accidentally hit SEND too soon, but you want to use the two argument form of ATAN, e.g.
>
>
>
> c = atan( numerator, denominator)
>
>
>
> --Wayne

When ever i tried to use atan2() it said that the variable was undefined. I dont know why that would happen
Re: Finding distance with longitude and latitude [message #83985 is a reply to message #83984] Sun, 14 April 2013 16:57 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
gpeterso@ucsc.edu writes:

> Now I am trying to find the distance between longitude and latitude points using the vincenty formula form here: http://en.wikipedia.org/wiki/Great-circle_distance. I have completed this and I am getting logical answers I am just wondering if it is accurate or a correct.

You could test it by seeing if you get the same answers with Map_2Points
in the IDL library.

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: Finding distance with longitude and latitude [message #83986 is a reply to message #83985] Sun, 14 April 2013 16:49 Go to previous message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
On Sunday, April 14, 2013 7:45:40 PM UTC-4, wlandsman wrote:
> On Sunday, April 14, 2013 7:22:44 PM UTC-4, gpet...@ucsc.edu wrote:
>
>
>
>> a=sqrt((cos(lat2)*sin(dlon))^2 + (cos(lat1)*sin(lat2)-sin(lat1)*cos(lat2)*cos(dlon))^2)/(sin( lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(dlat))
>
>
>
> c= atan(a)
>
>
>
> The Wikipedia article you quote says
>
> "When programming a computer, one should use the atan2() function rather than the ordinary arctangent function (atan()), in order to simplify handling of the case where the denominator is zero, and to compute \Delta\widehat{\sigma}\;\! unambiguously in all quadrants"

I accidentally hit SEND too soon, but you want to use the two argument form of ATAN, e.g.

c = atan( numerator, denominator)

--Wayne
Re: Finding distance with longitude and latitude [message #83987 is a reply to message #83986] Sun, 14 April 2013 16:45 Go to previous message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
On Sunday, April 14, 2013 7:22:44 PM UTC-4, gpet...@ucsc.edu wrote:

> a=sqrt((cos(lat2)*sin(dlon))^2 + (cos(lat1)*sin(lat2)-sin(lat1)*cos(lat2)*cos(dlon))^2)/(sin( lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(dlat))

c= atan(a)

The Wikipedia article you quote says
"When programming a computer, one should use the atan2() function rather than the ordinary arctangent function (atan()), in order to simplify handling of the case where the denominator is zero, and to compute \Delta\widehat{\sigma}\;\! unambiguously in all quadrants"
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: How can I export a few million geocoded points from IDL to ArcMap?
Next Topic: Cubic root finding on a grid

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:10:21 PDT 2025

Total time taken to generate the page: 0.01101 seconds