Distance() always returns "cartesian distance" in whatever units it is fed.  If it is fed data that is in meters -- the output will be in meters.  If it is fed degrees -- the output will be in degrees and totally useless.  I don't quite understand the problem that you are having<br>
<br><div class="gmail_quote">On Thu, Mar 20, 2008 at 11:15 AM, R H <<a href="mailto:enoop@hotmail.com">enoop@hotmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">




<div>
Thanks for the reply.  I think I got it figured out.  The projections I was putting into distance() where in meters.  I used a projection that is in degrees and then transformed to meters.  It appears to be working now.<br>

 <br>
I'm not sure I understand why?<br>
This is what I had previously<br>
geom = sird(26912) meter projection<br>
 <br>
select distance(geom,geom) returns cartesian distance<br>
select distance(transform(geom, 26912), transform(geom, 26912)) returns cartesian distance<br>
 <br>
then I changed geom = sird(4269) degree projection<br>
select distance(transform(geom, 26912), transform(geom, 26912)) returns meter<br>
 <br>
How are any of these statements different?  Based on order of operations isn't the inner most parentheses executed first?  Therefore being exactly the same as the first select?  I guess it's working so I will stop worrying about it.<br>

<blockquote>
<hr>
From: <a href="mailto:lr@pcorp.us" target="_blank">lr@pcorp.us</a><div class="Ih2E3d"><br>To: <a href="mailto:postgis-users@postgis.refractions.net" target="_blank">postgis-users@postgis.refractions.net</a><br></div><div class="Ih2E3d">
Subject: RE: [postgis-users] How to get the distance between geometry inmeters?<br></div>Date: Thu, 20 Mar 2008 05:37:30 -0400<div><div></div><div class="Wj3C7c"><br><br>



<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial">RH,</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial">Yes this is the same as putting 2 geoms with the <b>same </b>meter projection into ST_Distance.  The transform effectively flattens out a small section of space so you are measuring in cartesian space which is actually what you want to do since it simplifies the math.</font></span></div>

<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial">Your example below <font color="#000000">transform(st_distance(geom,geom),srid)  </font></font></span></div>
<div dir="ltr" align="left"><span><font face="Arial">should give you an error since you are effectively taking a distance (which would be in double precision) and then trying to transform that.  You can only transform geometries not distances.</font></span></div>

<div dir="ltr" align="left"><span><font face="Arial"></font></span> </div>
<div dir="ltr" align="left"><span><font face="Arial">What sort of error are you getting with ST_Distance and ST_DWithin?  Keep in mind that both your geometries have to be in the same meter projection otherwise an error would be thrown.</font></span></div>

<div dir="ltr" align="left"><span><font face="Arial"></font></span> </div>
<div dir="ltr" align="left"><span><font face="Arial">Hope that helps,</font></span></div>
<div dir="ltr" align="left"><span><font face="Arial">Leo & Regina</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial"></font></span> </div><br>
<div dir="ltr" align="left" lang="en-us">
<hr>
<font face="Tahoma"><b>From:</b> <a href="mailto:postgis-users-bounces@postgis.refractions.net" target="_blank">postgis-users-bounces@postgis.refractions.net</a> [mailto:<a href="mailto:postgis-users-bounces@postgis.refractions.net" target="_blank">postgis-users-bounces@postgis.refractions.net</a>] <b>On Behalf Of </b>R H<br>
<b>Sent:</b> Wednesday, March 19, 2008 6:03 PM<br><b>To:</b> PostGIS Users Discussion<br><b>Subject:</b> RE: [postgis-users] How to get the distance between geometry inmeters?<br></font><br></div>
<div></div>isn't this the same as putting two geom w/ a meter projection into st_distance(), st_distance() still returns a <font face="URWPalladioL-Roma">cartesian distance not a distances in meters?  Wouldn't you need to do something like...</font><br>
transform(st_distance(geom,geom),srid)???  <br> <br>I only ask because I am having a simular problem.  My projections are in a meter projection, but I can't get st_distance() or st_dwithin() to use meters?  any thoughts?<br>
<br><br>
<blockquote>
<hr>
Subject: RE: [postgis-users] How to get the distance between geometry in meters?<br>Date: Wed, 19 Mar 2008 06:56:24 -0400<br>From: <a href="mailto:robe.dnd@cityofboston.gov" target="_blank">robe.dnd@cityofboston.gov</a><br>
To: <a href="mailto:postgis-users@postgis.refractions.net" target="_blank">postgis-users@postgis.refractions.net</a><br><br>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial">You'll need to transform to a meter based projection to do that.  If for example you are in the U.S, SRID 2163 US National Atlas Equal Area works pretty good for measurement.  It is not as accurate as UTM or State Plane, but its pretty good and covers all of US I believe and probably works for some of Canada as well (not sure about non-continental e.g. Hawaii, Alaska).  </font></span></div>

<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial">
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial">e.g.</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial">SELECT road.rd_name, ht.ht_name, ST_Distance(ST_Transform(roads.the_geom,2163) , ST_Transform(hotel.the_geom,2163))  as dist_meters</font></span></div>

<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial">FROM road, hotel</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial">WHERE <some criteria here></font></span></div></font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial">If you are somewhere else and your locations are within that projection, you can use that.  Look at the utmzone function in the wiki that will help you determing the right UTM zone SRID for your data</font></span></div>

<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial"><a href="http://postgis.refractions.net/support/wiki/index.php?plpgsqlfunctions" target="_blank">http://postgis.refractions.net/support/wiki/index.php?plpgsqlfunctions</a></font></span></div>

<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial">So you would use something liek</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial">SELECT utmzone(ST_Centroid(the_geom)) as srid</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial">to get the right UTM zone SRID</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial"></font></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial">Hope that helps,</font></span></div>
<div dir="ltr" align="left"><span><font color="#0000ff" face="Arial">Regina</font></span></div>
<div><span><font color="#0000ff" face="Arial"></font></span> </div>
<div><span><font color="#0000ff" face="Arial"></font></span> </div>
<div dir="ltr" align="left"><br></div>
<div dir="ltr" align="left" lang="en-us">
<hr>
<font face="Tahoma"><b>From:</b> <a href="mailto:postgis-users-bounces@postgis.refractions.net" target="_blank">postgis-users-bounces@postgis.refractions.net</a> [mailto:<a href="mailto:postgis-users-bounces@postgis.refractions.net" target="_blank">postgis-users-bounces@postgis.refractions.net</a>] <b>On Behalf Of </b>Sinboy Chang<br>
<b>Sent:</b> Wednesday, March 19, 2008 3:09 AM<br><b>To:</b> <a href="mailto:postgis-users@postgis.refractions.net" target="_blank">postgis-users@postgis.refractions.net</a><br><b>Subject:</b> [postgis-users] How to get the distance between geometry in meters?<br>
</font><br></div>
<div></div>
<div>i want to get the distance between geometry,just like road or hotel poi,but ST_Distance() return the result in <i>cartesian dintance.</i></div>
<div>So how can get the distance() by meters?</div>
<hr size="1">

<br><b>The substance of this message, including any attachments, may be confidential, legally privileged and/or exempt from disclosure pursuant to Massachusetts law. It is intended solely for the addressee. If you received this in error, please contact the sender and delete the material from any computer. </b><br>

<hr size="1">

<p><br><b><font color="#339900">Help make the earth a greener place. If at all possible resist printing this email and join us in saving paper. <br></font></b><br><br></p></blockquote></div></div></blockquote></div>
<br>_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>
<a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>************************************<br>David William Bitner