Welcome to the Harris Geospatial product documentation center. Here you will find reference guides, help documents, and product libraries.

  >  Docs Center  >  Libraries  >  JBIU  >  MATCH_SPH






    For each angular point in one vector, determines the closest angular match
    from another vector. Method is to take the list returned by
    MATCHALL_SPH and narrow it down to the closest match.



Calling Sequence

    Result = MATCH_SPH(Ra1, Dec1, Ra2, Dec2, Sphrad)


    Ra1: Vector of longitude coordinates, in degrees.
    Dec1: Vector of latitude coordinates, in degrees.
    Ra2: Vector of longitude coordinates, in degrees.
    Dec2: Vector of latitude coordinates, in degrees.
    Sphrad: Maximum angular distance, in degrees. Matches outside
            of this radius are ignored.

Keyword Parameters

    MINDIST: Optional output containing an array of the actual distance
              to the closest match for each element of Ra1, Dec1.
    ONE_TO_ONE: Enforces one-to-one matching. By default, matching can
                be many-to-one, i.e. one entry in Ra2,Dec2 can be the
                closest match to several entries in Ra1,Dec1. If
                /ONE_TO_ONE is given, then each multiple entry in Ra2,Dec2
                is first assigned to its closest point in Ra1,Dec1. Then any
                entries in Ra1,Dec1 that have lost their match are assigned
                the next closest point within Sphrad. This process is
                iterated until all points in Ra1,Dec1 are matched to a
                unique point in Ra2,Dec2 or there are no more points
                within Sphrad


    The function returns an array with one entry for each Ra1, Dec1
    element containing the index in Ra2, Dec2 that is closest, or -1 if
    there are none within Sphrad.


    n1 = 25
    n2 = 10
    seed = 43L
    ra1 = randomn(seed, n1)
    dec1 = randomn(seed, n1)
    ra2 = randomn(seed, n2)
    dec2 = randomn(seed, n2)
    result1 = match_sph(ra1, dec1, ra2, dec2, 1.)
    result2 = match_sph(ra1, dec1, ra2, dec2, 1., /one_to_one)
    plot, psym=1, ra1, dec1, xrange=[-3,3], yrange=[-3,3], title='Default'
    oplot, psym=4, ra2, dec2
    for i=0l,n1-1 do if result1[i] ne -1 then oplot, [ra1[i],ra2[result1[i]]], $
    plot, psym=1, ra1, dec1, xrange=[-3,3], yrange=[-3,3], title='/ONE_TO_ONE'
    oplot, psym=4, ra2, dec2
    for i=0l,n1-1 do if result2[i] ne -1 then oplot, [ra1[i],ra2[result2[i]]], $

Modification History

    Written by: Jeremy Bailin
    10 June 2008 Public release in JBIU as WITHINSPHRAD
    24 April 2009 Vectorized as WITHINSPHRAD_VEC
    25 April 2009 Polished to improve memory use
    9 May 2009 Radical efficiency re-write as WITHINSPHRAD_VEC3D borrowing
                  heavily from JD Smith's MATCH_2D
    13 May 2009 Removed * from LHS index in final remapping for speed
    23 August 2010 Modified to only return closest match as WITHINSPHRAD_CLOSEST
                  (importing some stuff back from MATCH_2D)
    8 Sept 2010 Renamed MATCH_SPH. Added /ONE_TO_ONE option, and modified
                  to explicitly call MATCHALL_SPH and then cull.
    13 April 2011 Fixed to work around cumulative total 1-element array bug.

© 2018 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us