<div dir="ltr"><span><font size="2" color="#0000ff" face="Arial"><span style="color: rgb(0, 0, 0);"></span></font></span>It works to get the spheroid from the spatial_ref_sys:<br><br>select substring(srtext from position('SPHEROID' in srtext) for position(',AUTHORITY' in srtext)-position('SPHEROID' in srtext))||']'<br>
from spatial_ref_sys<br>where srid = 4326<br>--result: 'SPHEROID["WGS 84",6378137,298.257223563]'<br><br>You can even get the srid from one of the geometries yourself, and pass it to the function.<br>the sql is a bit awkward, but it's proving the concept that counts:<br>
<br>select distance_spheroid(transform(centroid(l1.the_geom), 4326), transform(centroid(l2.the_geom), 4326), (substring(sfs.srtext from position('SPHEROID' in sfs.srtext) for position(',AUTHORITY' in sfs.srtext)-position('SPHEROID' in sfs.srtext))||']'::text)::spheroid )/1000 as thedistance<br>
from table1 l1<br>join table1 l2 ON (l1.locid=1 AND l2.locid = 2)<br>join spatial_ref_sys sfs ON (sfs.srid = srid(l1.the_geom))<br><br><br>But i think there should be a version of distance_sphere that does this for you.<br>
<br>cheers,<br><br>WBL<br clear="all"><br>-- <br>"Patriotism is the conviction that your country is superior to all others because you were born in it." - George Bernard Shaw<br>
</div>