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

Home » Public Forums » archive » Re: X/Y convert to lat/lon
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: X/Y convert to lat/lon [message #75637 is a reply to message #75635] Tue, 15 March 2011 08:38 Go to previous messageGo to previous message
Kenneth P. Bowman is currently offline  Kenneth P. Bowman
Messages: 585
Registered: May 2000
Senior Member
In article
<887457ef-3c22-404a-a958-176714fa2053@s18g2000vbe.googlegroups.com>,
teddyallen <teddyallen@yahoo.com> wrote:

> I am reluctant to post this since it seems like a very easy task, but
> unfortunately, I cannot manage to figure it out on my own nor with any
> online search help. ( I am away from home and my trusty IDL books are
> not on pdf....bummer!)

I use this function frequently,

Ken Bowman




FUNCTION INDEX_OF_NEAREST, x, x0

;+
;NAME:
; INDEX_OF_NEAREST
;PURPOSE:
; This function finds the index of the element of x whose value is
; nearest to x0. This is primarily useful for finding the index of
; a point in an ordered 1-dimensional array. For example, if x is
; an array of latitudes, this function will return the index of the
; element of the array that is closest to the latitude x0.
; If there are multiple elements in x that are the same distance from
; x0, this function returns the first one.
;CATEGORY:
; Array utility.
;CALLING SEQUENCE:
; i = INDEX_OF_NEAREST(x, x0)
;INPUT:
; x : array of values to search.
; x0 : value to search for.
;KEYWORDS:
; None.
;OUTPUT:
; Index of element nearest to x0.
;MODIFICATION HISTORY:
; KPB, 1999-04.
;-

COMPILE_OPT IDL2

i = (WHERE(ABS(x - x0) EQ MIN(ABS(x - x0)), count))[0]

RETURN, i

END
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: journal files
Next Topic: color and tvellipse

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

Current Time: Fri Oct 10 15:09:19 PDT 2025

Total time taken to generate the page: 0.07686 seconds