[postgis-users] Nearest neighbor in 3D
Hello All! This is my first post on the PostGIS mailing list:-). I would like to use the <-> to solve the nearest neighbor problem, but in 3D space. I tried to do this in 2D and it works perfectly, but apparently it doesn't cover the 3D case. Basically I have a table of 3D points (x, y, z) and would like to do: ORDER BY point <-> POINT(0 0 0) but the distance taken into account should be 3D Euclidean distance. Do I have to use ST_3DDistance() for it or is there a faster way? Thanks in advance! Regards, -- Bartosz Bekier ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] Nearest neighbor in 3D
Using ST_3DDistance will work and give you the right answer, but it will not be index assisted. The KNN operator <-> is only implemented against the 2D index currently. Paul On Fri, May 25, 2012 at 5:15 PM, Bartosz Bekier wrote: > Hello All! > > This is my first post on the PostGIS mailing list:-). > > I would like to use the <-> to solve the nearest neighbor problem, but in 3D > space. I tried to do this in 2D and it works perfectly, but apparently it > doesn't cover the 3D case. > > Basically I have a table of 3D points (x, y, z) and would like to do: > > ORDER BY point <-> POINT(0 0 0) > > but the distance taken into account should be 3D Euclidean distance. Do I > have to use ST_3DDistance() for it or is there a faster way? > > Thanks in advance! > > Regards, > -- > Bartosz Bekier > > > ___ > postgis-users mailing list > postgis-users@postgis.refractions.net > http://postgis.refractions.net/mailman/listinfo/postgis-users > ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] Nearest neighbor in 3D
Using ST_3DDistance will work and give you the right answer, but it will not be index assisted. The KNN operator <-> is only implemented against the 2D index currently. Paul On Fri, May 25, 2012 at 5:15 PM, Bartosz Bekier wrote: > Hello All! > > This is my first post on the PostGIS mailing list:-). > > I would like to use the <-> to solve the nearest neighbor problem, but in 3D > space. I tried to do this in 2D and it works perfectly, but apparently it > doesn't cover the 3D case. > > Basically I have a table of 3D points (x, y, z) and would like to do: > > ORDER BY point <-> POINT(0 0 0) > > but the distance taken into account should be 3D Euclidean distance. Do I > have to use ST_3DDistance() for it or is there a faster way? > > Thanks in advance! > > Regards, > -- > Bartosz Bekier > > > ___ > postgis-users mailing list > postgis-users@postgis.refractions.net > http://postgis.refractions.net/mailman/listinfo/postgis-users > ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] Nearest neighbor in 3D
2012/5/26 Paul Ramsey > Using ST_3DDistance will work and give you the right answer, but it > will not be index assisted. The KNN operator <-> is only implemented > against the 2D index currently. > Ok, I see, thanks for confirming that. I'll try to use ST_3Ddwithin() to limit the number of results, it seems to use the index. Regards, -- Bartosz ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users