<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>
sorry in the example I said "returns cartesian distance", I meant degrees.  So my input was in a meter projection and was returning degrees.<BR><BR>
<BLOCKQUOTE>
<HR>
Date: Thu, 20 Mar 2008 12:08:11 -0500<BR>From: david.bitner@gmail.com<BR>To: postgis-users@postgis.refractions.net<BR>Subject: Re: [postgis-users] How to get the distance between geometry inmeters?<BR><BR>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=EC_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=EC_gmail_quote style="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">lr@pcorp.us</A> 
<DIV class=EC_Ih2E3d><BR>To: <A href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</A><BR></DIV>
<DIV class=EC_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=EC_Wj3C7c><BR><BR>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff>RH,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff>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 face=Arial color=#0000ff></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff>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 face=Arial color=#0000ff></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff></FONT></SPAN> </DIV><BR>
<DIV lang=en-us dir=ltr align=left>
<HR>
<FONT face=Tahoma><B>From:</B> <A href="mailto:postgis-users-bounces@postgis.refractions.net">postgis-users-bounces@postgis.refractions.net</A> [mailto:<A href="mailto:postgis-users-bounces@postgis.refractions.net">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">robe.dnd@cityofboston.gov</A><BR>To: <A href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</A><BR><BR>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff>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 face=Arial color=#0000ff></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff>e.g.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff>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 face=Arial color=#0000ff>FROM road, hotel</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff>WHERE <some criteria here></FONT></SPAN></DIV></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff>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 face=Arial color=#0000ff></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff><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 face=Arial color=#0000ff></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff>So you would use something liek</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff>SELECT utmzone(ST_Centroid(the_geom)) as srid</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff>to get the right UTM zone SRID</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff>Hope that helps,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff>Regina</FONT></SPAN></DIV>
<DIV><SPAN><FONT face=Arial color=#0000ff></FONT></SPAN> </DIV>
<DIV><SPAN><FONT face=Arial color=#0000ff></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><BR></DIV>
<DIV lang=en-us dir=ltr align=left>
<HR>
<FONT face=Tahoma><B>From:</B> <A href="mailto:postgis-users-bounces@postgis.refractions.net">postgis-users-bounces@postgis.refractions.net</A> [mailto:<A href="mailto:postgis-users-bounces@postgis.refractions.net">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">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>

<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><BR></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 </BLOCKQUOTE></body>
</html>