Re: Finding distance with longitude and latitude [message #83960] |
Tue, 16 April 2013 09:23 |
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  |
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 #83983 is a reply to message #83982] |
Sun, 14 April 2013 19:38  |
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  |
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 #83986 is a reply to message #83985] |
Sun, 14 April 2013 16:49  |
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  |
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"
|
|
|