Re: [pgsql-advocacy] Function which gives back the nearest - Mailing list pgsql-novice

From Joe Conway
Subject Re: [pgsql-advocacy] Function which gives back the nearest
Date
Msg-id 42483D83.4030209@joeconway.com
Whole thread Raw
In response to Re: [pgsql-advocacy] Function which gives back the nearest neighbours  (Bruno Wolff III <bruno@wolff.to>)
List pgsql-novice
Bruno Wolff III wrote:
> On Mon, Mar 28, 2005 at 18:32:09 +0200,
>   Virgile Beddok <virgile.beddok@igd.fraunhofer.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

pgsql-novice by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: [pgsql-advocacy] Function which gives back the nearest neighbours
Next
From: Bruce Momjian
Date:
Subject: Re: initial password