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

Home » Public Forums » archive » Distance between coordinates
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
Distance between coordinates [message #90933] Thu, 14 May 2015 13:57 Go to next message
khyde is currently offline  khyde
Messages: 21
Registered: November 2013
Junior Member
Hello,

Is there an IDL function that can calculate the distance between two longitude/latitude coordinates (no map projection)? If not, does anyone have code that does this? I don't want to duplicate effort if there is already something out there.

Thanks,
KH
Re: Distance between coordinates [message #90934 is a reply to message #90933] Thu, 14 May 2015 16:16 Go to previous messageGo to next message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On 5/14/15 2:57 PM, kimberly.hyde@noaa.gov wrote:
> Hello,
>
> Is there an IDL function that can calculate the distance between two
> longitude/latitude coordinates (no map projection)? If not, does
> anyone have code that does this? I don't want to duplicate effort if
> there is already something out there.
>
> Thanks, KH
>

Yes, checkout MAP_2POINTS in the IDL distribution.

Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com)
Re: Distance between coordinates [message #90941 is a reply to message #90934] Fri, 15 May 2015 06:02 Go to previous messageGo to next message
khyde is currently offline  khyde
Messages: 21
Registered: November 2013
Junior Member
On Thursday, May 14, 2015 at 7:15:46 PM UTC-4, Mike Galloy wrote:

>> Hello,
>>
>> Is there an IDL function that can calculate the distance between two
>> longitude/latitude coordinates (no map projection)? If not, does
>> anyone have code that does this? I don't want to duplicate effort if
>> there is already something out there.
>>
>> Thanks, KH
>>
>
> Yes, checkout MAP_2POINTS in the IDL distribution.
>
> Mike
> --
> Michael Galloy
> www.michaelgalloy.com
> Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com)

This is exactly what I needed. Thank you!
Re: Distance between coordinates [message #90943 is a reply to message #90933] Sat, 16 May 2015 17:23 Go to previous messageGo to next message
astr74323 is currently offline  astr74323
Messages: 4
Registered: May 2015
Junior Member
Hello Michael I have a problem in Code regard to gcirc.pro, It gave me incorrect of argument through IDL programme, How can I solve that?
Re: Distance between coordinates [message #90944 is a reply to message #90943] Sun, 17 May 2015 20:28 Go to previous messageGo to next message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
On Saturday, May 16, 2015 at 8:23:49 PM UTC-4, astr...@gmail.com wrote:
> Hello Michael I have a problem in Code regard to gcirc.pro, It gave me incorrect of argument through IDL programme, How can I solve that?

We can't tell you what you are doing wrong if we don't know what you are doing. You need to show us how you are calling gcirc.pro ( not a standard IDL procedure but in the IDL Astronomy library http://idlastro.gsfc.nasa.gov/ftp/pro/astro/gcirc.pro )

But here is how to get the same result as the example in the MAP_2POINTS documentation, the angular distance between Boulder and London.

B = [ -105.19, 40.02] ;Boulder Longitude, latitude in degrees.
L = [ -0.07, 51.30] ;London Longitude, latitude in degrees.

IDL> gcirc,2,b[0],b[1],l[0],l[1],dis

where we set the units (first) parameter to 2 ( RAx and DCx in degrees, DIS in arc seconds)

so the angular distance between Boulder and London in arc seconds and degrees is
IDL> print,dis,dis/3600.
244275.60 67.854333
Re: Distance between coordinates [message #90950 is a reply to message #90944] Mon, 18 May 2015 11:49 Go to previous messageGo to next message
astr74323 is currently offline  astr74323
Messages: 4
Registered: May 2015
Junior Member
بتاريخ الاثنين، 18 مايو، 2015 6:28:46 ص UTC+3، كتب wlandsman:
> On Saturday, May 16, 2015 at 8:23:49 PM UTC-4, astr...@gmail.com wrote:
>> Hello Michael I have a problem in Code regard to gcirc.pro, It gave me incorrect of argument through IDL programme, How can I solve that?
>
> We can't tell you what you are doing wrong if we don't know what you are doing. You need to show us how you are calling gcirc.pro ( not a standard IDL procedure but in the IDL Astronomy library http://idlastro.gsfc.nasa.gov/ftp/pro/astro/gcirc.pro )
>
> But here is how to get the same result as the example in the MAP_2POINTS documentation, the angular distance between Boulder and London.

>
> B = [ -105.19, 40.02] ;Boulder Longitude, latitude in degrees.
> L = [ -0.07, 51.30] ;London Longitude, latitude in degrees.
>
> IDL> gcirc,2,b[0],b[1],l[0],l[1],dis
>
> where we set the units (first) parameter to 2 ( RAx and DCx in degrees, DIS in arc seconds)
>
> so the angular distance between Boulder and London in arc seconds and degrees is
> IDL> print,dis,dis/3600.
> 244275.60 67.854333


Hello Wlandsman,

Colud you give me your email or Skype?

Beacuse I've many quetions

I look forward to hearing from you
Re: Distance between coordinates [message #90952 is a reply to message #90950] Mon, 18 May 2015 12:51 Go to previous messageGo to next message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
On Monday, May 18, 2015 at 2:49:42 PM UTC-4, astr...@gmail.com wrote:

> Hello Wlandsman,
>
> Colud you give me your email or Skype?
>
> Beacuse I've many quetions
>
> I look forward to hearing from you

Sorry, I can't help you, except to point you to a document on how to ask questions on Usenet

http://www.catb.org/esr/faqs/smart-questions.html
Re: Distance between coordinates [message #90953 is a reply to message #90952] Mon, 18 May 2015 14:42 Go to previous messageGo to next message
astr74323 is currently offline  astr74323
Messages: 4
Registered: May 2015
Junior Member
بتاريخ الاثنين، 18 مايو، 2015 10:51:16 م UTC+3، كتب wlandsman:
> On Monday, May 18, 2015 at 2:49:42 PM UTC-4, astr...@gmail.com wrote:
>
>> Hello Wlandsman,
>>
>> Colud you give me your email or Skype?
>>
>> Beacuse I've many quetions
>>
>> I look forward to hearing from you
>
> Sorry, I can't help you, except to point you to a document on how to ask questions on Usenet
>
> http://www.catb.org/esr/faqs/smart-questions.html

Ok, I have some terms
Re: Distance between coordinates [message #90954 is a reply to message #90952] Mon, 18 May 2015 14:48 Go to previous messageGo to next message
astr74323 is currently offline  astr74323
Messages: 4
Registered: May 2015
Junior Member
بتاريخ الاثنين، 18 مايو، 2015 10:51:16 م UTC+3، كتب wlandsman:
> On Monday, May 18, 2015 at 2:49:42 PM UTC-4, astr...@gmail.com wrote:
>
>> Hello Wlandsman,
>>
>> Colud you give me your email or Skype?
>>
>> Beacuse I've many quetions
>>
>> I look forward to hearing from you
>
> Sorry, I can't help you, except to point you to a document on how to ask questions on Usenet
>
> http://www.catb.org/esr/faqs/smart-questions.html



Ok, I have questions with regard to terms in gcirc.pro, Could you write comment at each command line if you can

On_error,2 ;Return to caller

npar = N_params()
IF (npar ne 6) and (npar ne 5) THEN BEGIN
print,'Calling sequence: GCIRC,U,RA1,DC1,RA2,DC2[,DIS]'
print,' U = 0 ==> Everything in radians'
print, $
' U = 1 ==> RAx decimal hours, DCx decimal degrees, DIS arc sec'
print,' U = 2 ==> RAx, DCx decimal degrees, DIS arc sec'
RETURN
ENDIF


d2r = !DPI/180.0d0
as2r = !DPI/648000.0d0
h2r = !DPI/12.0d0

; Convert input to double precision radians
CASE u OF
0: BEGIN
rarad1 = double(ra1)
rarad2 = double(ra2)
dcrad1 = double(dc1)
dcrad2 = double(dc2)
END
1: BEGIN
rarad1 = ra1*h2r
rarad2 = ra2*h2r
dcrad1 = dc1*d2r
dcrad2 = dc2*d2r
END
2: BEGIN
rarad1 = ra1*d2r
rarad2 = ra2*d2r
dcrad1 = dc1*d2r
dcrad2 = dc2*d2r
END
ELSE: MESSAGE, $
'U must be 0 (radians), 1 ( hours, degrees) or 2 (degrees)'
ENDCASE

deldec2 = (dcrad2-dcrad1)/2.0d
delra2 = (rarad2-rarad1)/2.0d
sindis = sqrt( sin(deldec2)*sin(deldec2) + $
cos(dcrad1)*cos(dcrad2)*sin(delra2)*sin(delra2) )
dis = 2.0d*asin(sindis)

IF (u ne 0) THEN dis = dis/as2r

IF (npar eq 5) && (N_elements(dis) EQ 1) THEN BEGIN
IF (u ne 0) && (dis ge 0.1) && (dis le 1000) $
THEN fmt = '(F10.4)' $
ELSE fmt = '(E15.8)'
IF (u ne 0) THEN units = ' arcsec' ELSE units = ' radians'
print,'Angular separation is ' + string(dis,format=fmt) + units
ENDIF

RETURN
END

Regards
Re: Distance between coordinates [message #90955 is a reply to message #90954] Mon, 18 May 2015 16:39 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
astr74323@gmail.com writes:

> Ok, I have questions with regard to terms in gcirc.pro, Could you write comment at each command line if you can

P.S. I'll buy you dinner and a beer for all your effort! ;-)

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: Distance between coordinates [message #90956 is a reply to message #90954] Mon, 18 May 2015 17:08 Go to previous message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
On Monday, May 18, 2015 at 5:48:14 PM UTC-4, astr...@gmail.com wrote:

>
>
> Ok, I have questions with regard to terms in gcirc.pro, Could you write comment at each command line if you can

OK, I'll continue for one more post.

What are you trying to accomplish? Why do you think that gcirc.pro will help you accomplish this?

Did you understand the example of finding the angular distance between Boulder and London?

Are there parts of gcirc.pro which you *do* understand?

Have you read articles on computing angular distance? such as
http://en.wikipedia.org/wiki/Great-circle_distance
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: How to ignore NaNs in the data array with function cgPercentile.pro or Percentile.pro?
Next Topic: Illegal operand error with window,/free

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

Current Time: Wed Oct 08 09:22:22 PDT 2025

Total time taken to generate the page: 0.00698 seconds