You can cross join to create the cartesian product of them and use it to calculate the distance of each with regards to the other:
select a.id,b.id, st_distance(a.geom,b.geom) d from points a cross join points b order by d desc limit 1; ofc that will take forever because it will have to create an m x n table (800 secs and counting...) As I see it the two points with the furthest distance between them should touch the borders of you datasets convexhull. So you can filter out those inside the boundaries and do the calculations with the remaining points along the borders : with f as ( select a.geom,a.id from points foo, (select ST_ExteriorRing (st_convexhull(st_collect(geom))) geom from points) bar where st_Dwithin(foo.geom,bar.geom,0.00000001) ) select a.id,b.id, st_distance(a.geom,b.geom) d from f a cross join f b order by d desc limit 1; should give you the id of your targets and the distance between them On Fri, Jun 26, 2015 at 2:54 PM, Jonathan Moules <j.mou...@hrwallingford.com > wrote: > Hi List, > > I have sets of points (up to 250,000 in a set) and I want to get the > furthest distance between any of them. > > > > In theory the simplest way is to use > ST_MinimumBoundingCircle(ST_Collect(geography) and then get the diameter of > that. > > > > The problem is – I don’t seem to be able to get the diameter of that > circle (which would give me the distance I want). > > > > Does anyone have any thoughts on this? Is there a good way to get the > diameter? Or some other way of getting the distance I desire. > > > > Thanks, > > Jonathan > > ------------------------------ > > *HR Wallingford and its subsidiaries* uses faxes and emails for > confidential and legally privileged business communications. They do not of > themselves create legal commitments. Disclosure to parties other than > addressees requires our specific consent. We are not liable for > unauthorised disclosures nor reliance upon them. > If you have received this message in error please advise us immediately > and destroy all copies of it. > > HR Wallingford Limited > Howbery Park, Wallingford, Oxfordshire, OX10 8BA, United Kingdom > Registered in England No. 02562099 > > ------------------------------ > > > _______________________________________________ > postgis-users mailing list > postgis-users@lists.osgeo.org > http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users >
_______________________________________________ postgis-users mailing list postgis-users@lists.osgeo.org http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users