<div dir="ltr"><div class="gmail_default"><span style="font-family:tahoma,sans-serif">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: </span></div><div class="gmail_default"><span style="font-family:tahoma,sans-serif"><br></span></div><div class="gmail_default"><font face="tahoma, sans-serif">select <a href="http://a.id">a.id</a>,<a href="http://b.id">b.id</a>, st_distance(a.geom,b.geom) d from points a cross join points b order by d desc limit 1;</font><br></div><div class="gmail_default"><font face="tahoma, sans-serif"><br></font></div><div class="gmail_default"><font face="tahoma, sans-serif">ofc that will take forever because it will have to create an m x n table (800 secs and counting...)</font></div><div class="gmail_default"><font face="tahoma, sans-serif"><br></font></div><div class="gmail_default"><font face="tahoma, sans-serif">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 :</font></div><div class="gmail_default"><font face="tahoma, sans-serif"><br></font></div><div class="gmail_default"><font face="tahoma, sans-serif"><div class="gmail_default">with f as </div><div class="gmail_default">( </div><div class="gmail_default">select a.geom,<a href="http://a.id">a.id</a> from </div><div class="gmail_default">points foo,</div><div class="gmail_default">(select ST_ExteriorRing (st_convexhull(st_collect(geom))) geom from points) bar </div><div class="gmail_default">where st_Dwithin(foo.geom,bar.geom,0.00000001)</div><div class="gmail_default">)</div><div class="gmail_default">select <a href="http://a.id">a.id</a>,<a href="http://b.id">b.id</a>, st_distance(a.geom,b.geom) d from f a cross join f b order by d desc limit 1;</div><div><br></div></font></div><div class="gmail_extra"><div class="gmail_default" style="font-family:tahoma,sans-serif">should give you the id of your targets and the distance between them</div><br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 26, 2015 at 2:54 PM, Jonathan Moules <span dir="ltr"><<a href="mailto:J.Moules@hrwallingford.com" target="_blank">J.Moules@hrwallingford.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div lang="EN-GB" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(60,60,60)">Hi List,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(60,60,60)">I have sets of points (up to 250,000 in a set) and I want to get the furthest distance between any of them.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(60,60,60)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(60,60,60)">In theory the simplest way is to use ST_MinimumBoundingCircle(ST_Collect(geography) and then get the diameter of that.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(60,60,60)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(60,60,60)">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).<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(60,60,60)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(60,60,60)">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.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(60,60,60)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(60,60,60)">Thanks,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(60,60,60)">Jonathan<u></u><u></u></span></p>
</div>
<br>
<hr>
<p style="font-family:arial;font-size:8pt"><b>HR Wallingford and its subsidiaries</b> 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.
<br>
If you have received this message in error please advise us immediately and destroy all copies of it.
<br>
<br>
HR Wallingford Limited<br>
Howbery Park, Wallingford, Oxfordshire, OX10 8BA, United Kingdom<br>
Registered in England No. 02562099<br>
</p>
<p></p>
<hr>
<p></p>
</div>
<br>_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" rel="noreferrer" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br></blockquote></div><br></div></div>