Re: [NOVICE] Function which gives back the nearest

From: Joe Conway <mail(at)joeconway(dot)com>
To: Bruno Wolff III <bruno(at)wolff(dot)to>
Cc: Virgile Beddok <virgile(dot)beddok(at)igd(dot)fraunhofer(dot)de>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>, pgsql-novice(at)postgresql(dot)org, pgsql-advocacy(at)postgresql(dot)org
Subject: Re: [NOVICE] Function which gives back the nearest
Date: 2005-03-28 17:23:15
Message-ID: 42483D83.4030209@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-advocacy pgsql-novice

Bruno Wolff III wrote:
> On Mon, Mar 28, 2005 at 18:32:09 +0200,
> Virgile Beddok <virgile(dot)beddok(at)igd(dot)fraunhofer(dot)de> wrote:
>
>>I just want to know if there is an existing and implemented function, or
>>tree, in Postgres which allows me to directly perform a "nearest neighbour
>>search" on multidimensional vectors.
>
>
> How are you measuring distance? (i.e. Euclidean distance isn't the only
> metric that you could be using.)
>
> Earthdistance has functions for doing this using geodesics on the surface
> of a sphere.
>
> For 2D, I think there is a function on "point"s that uses Euclidean
> distance.
>
> I don't think this is the hard part of your problem. It is easy to create
> a metric function and get the point corresponding to the minimal value
> using a sort. Being able to limit the sets of points looked at is the
> hard part.

You might want to look into using R:
http://www.bioconductor.org/CRAN/
(see "Packages")

perhaps through PL/R:
http://www.joeconway.com/plr/

or RdbiPgSQL:
http://www.bioconductor.org/repository/release1.5/package/html/RdbiPgSQL.html

Joe

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Tad Marko 2005-03-28 17:54:29 createlang problem with 8, what is correct?
Previous Message Bruno Wolff III 2005-03-28 17:22:23 Re: [NOVICE] Function which gives back the nearest neighbours

Browse pgsql-advocacy by date

  From Date Subject
Next Message Josh Berkus 2005-03-28 21:08:15 PG Graphics are up.
Previous Message Bruno Wolff III 2005-03-28 17:22:23 Re: [NOVICE] Function which gives back the nearest neighbours

Browse pgsql-novice by date

  From Date Subject
Next Message Bruce Momjian 2005-03-28 22:36:49 Re: initial password
Previous Message Bruno Wolff III 2005-03-28 17:22:23 Re: [NOVICE] Function which gives back the nearest neighbours