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

Home » Public Forums » archive » Re: how to calculate distance from pairs of latitude/longitude measurements?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: how to calculate distance from pairs of latitude/longitude measurements? [message #65604 is a reply to message #65590] Wed, 11 March 2009 14:12 Go to previous messageGo to previous message
natha is currently offline  natha
Messages: 482
Registered: October 2007
Senior Member
I wrote this small program:

FUNCTION LATLON_DISTANCE, lat1, lon1, lat2, lon2, DEG=deg

IF KEYWORD_SET(deg) THEN BEGIN
lat1=lat1*(!PI/180.)
lon1=lon1*(!PI/180.)
lat2=lat2*(!PI/180.)
lon2=lon2*(!PI/180.)
ENDIF

R=6356.7523 ;; polar radius [km]

a=R*(!PI/2.-lat2)
b=R*(!PI/2.-lat1)

gamma=lon1-lon2

angle=COS(b/R)*COS(a/R)+SIN(b/R)*SIN(a/R)*COS(gamma)
distance=ACOS(angle)*R

RETURN, distance

END

The result is the same as MAP_2POINTS.
I'll use MAP_2POINTS anyway,

thanks
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: OpenADDE and IDL
Next Topic: Need Help Resolving ENDIF Errors

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

Current Time: Mon Oct 27 15:18:36 PDT 2025

Total time taken to generate the page: 0.48059 seconds