Distance between coordinates [message #90933] |
Thu, 14 May 2015 13:57  |
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 #90944 is a reply to message #90943] |
Sun, 17 May 2015 20:28   |
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   |
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 #90954 is a reply to message #90952] |
Mon, 18 May 2015 14:48   |
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 #90956 is a reply to message #90954] |
Mon, 18 May 2015 17:08  |
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
|
|
|