<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>
My explanation wasn't that great.&nbsp; Below is what I did.<BR>
&nbsp;<BR>
26912 projection is in meters (right?)<BR>select AddGeometryColumn('table','geocode', 26912, 'POINT', 2);<BR>
update table<BR>set geocode = PointFromText('POINT(' || longitude || ' ' || latitude || ')', 26912);<BR>
distance(geocode, geocode) returns degrees<BR>
&nbsp;<BR>
ALTER TABLE property DROP COLUMN geocode<BR>
&nbsp;<BR>
4269 projection in degrees<BR>select AddGeometryColumn('table','geocode', 4269, 'POINT', 2);<BR>
update table<BR>set geocode = PointFromText('POINT(' || longitude || ' ' || latitude || ')', 4269);<BR>
distance(transform(geocode, 26912), transform(geocode,26912)) returns meters<BR>
<BR>&nbsp;<BR>
I would prefer not to do the transform() if don't have to speed and accuracy reasons.&nbsp; Thanks for help. : }<BR>
&nbsp;<BR>
<BR>&gt; Date: Thu, 20 Mar 2008 11:07:34 -0700<BR>&gt; From: kneufeld@refractions.net<BR>&gt; To: postgis-users@postgis.refractions.net<BR>&gt; Subject: Re: [postgis-users] How to get the distance between geometry inmeters?<BR>&gt; <BR>&gt; Hi R H,<BR>&gt; <BR>&gt; Are you certain that your input geometries are in a meter projection? <BR>&gt; David is correct. Distance() always returns the cartesian distance in <BR>&gt; the *same* units as the input. It's impossible to input something in <BR>&gt; meters in this function and get something in degrees.<BR>&gt; <BR>&gt; Looking at your SQL you posted earlier, I have the suspicion that your <BR>&gt; input geometries are in lat/long (4269) and you simply updated the srid <BR>&gt; of the geometries to be 26912, thinking that this would change the <BR>&gt; projection of your geometries. Am I off here? To verify, can you post <BR>&gt; the ewkt representation of a small geometry here?<BR>&gt; <BR>&gt; Cheers,<BR>&gt; Kevin<BR>&gt; <BR>&gt; R H wrote:<BR>&gt; &gt; sorry in the example I said "returns cartesian distance", I meant <BR>&gt; &gt; degrees. So my input was in a meter projection and was returning degrees.<BR>&gt; &gt;<BR>&gt; &gt; ------------------------------------------------------------------------<BR>&gt; &gt; Date: Thu, 20 Mar 2008 12:08:11 -0500<BR>&gt; &gt; From: david.bitner@gmail.com<BR>&gt; &gt; To: postgis-users@postgis.refractions.net<BR>&gt; &gt; Subject: Re: [postgis-users] How to get the distance between<BR>&gt; &gt; geometry inmeters?<BR>&gt; &gt;<BR>&gt; &gt; Distance() always returns "cartesian distance" in whatever units<BR>&gt; &gt; it is fed. If it is fed data that is in meters -- the output will<BR>&gt; &gt; be in meters. If it is fed degrees -- the output will be in<BR>&gt; &gt; degrees and totally useless. I don't quite understand the problem<BR>&gt; &gt; that you are having<BR>&gt; &gt;<BR>&gt; &gt; On Thu, Mar 20, 2008 at 11:15 AM, R H &lt;enoop@hotmail.com<BR>&gt; &gt; &lt;mailto:enoop@hotmail.com&gt;&gt; wrote:<BR>&gt; &gt;<BR>&gt; &gt; Thanks for the reply. I think I got it figured out. The<BR>&gt; &gt; projections I was putting into distance() where in meters. I<BR>&gt; &gt; used a projection that is in degrees and then transformed to<BR>&gt; &gt; meters. It appears to be working now.<BR>&gt; &gt; <BR>&gt; &gt; I'm not sure I understand why?<BR>&gt; &gt; This is what I had previously<BR>&gt; &gt; geom = sird(26912) meter projection<BR>&gt; &gt; <BR>&gt; &gt; select distance(geom,geom) returns cartesian distance<BR>&gt; &gt; select distance(transform(geom, 26912), transform(geom,<BR>&gt; &gt; 26912)) returns cartesian distance<BR>&gt; &gt; <BR>&gt; &gt; then I changed geom = sird(4269) degree projection<BR>&gt; &gt; select distance(transform(geom, 26912), transform(geom,<BR>&gt; &gt; 26912)) returns meter<BR>&gt; &gt; <BR>&gt; &gt; How are any of these statements different? Based on order of<BR>&gt; &gt; operations isn't the inner most parentheses executed first? <BR>&gt; &gt; Therefore being exactly the same as the first select? I guess<BR>&gt; &gt; it's working so I will stop worrying about it.<BR>&gt; &gt;<BR>&gt; &gt; ------------------------------------------------------------------------<BR>&gt; &gt; From: lr@pcorp.us &lt;mailto:lr@pcorp.us&gt;<BR>&gt; &gt;<BR>&gt; &gt; To: postgis-users@postgis.refractions.net<BR>&gt; &gt; &lt;mailto:postgis-users@postgis.refractions.net&gt;<BR>&gt; &gt; Subject: RE: [postgis-users] How to get the distance<BR>&gt; &gt; between geometry inmeters?<BR>&gt; &gt; Date: Thu, 20 Mar 2008 05:37:30 -0400<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt; RH,<BR>&gt; &gt; <BR>&gt; &gt; Yes this is the same as putting 2 geoms with the *same<BR>&gt; &gt; *meter projection into ST_Distance. The transform<BR>&gt; &gt; effectively flattens out a small section of space so you<BR>&gt; &gt; are measuring in cartesian space which is actually what<BR>&gt; &gt; you want to do since it simplifies the math.<BR>&gt; &gt; <BR>&gt; &gt; Your example below transform(st_distance(geom,geom),srid) <BR>&gt; &gt; should give you an error since you are effectively taking<BR>&gt; &gt; a distance (which would be in double precision) and then<BR>&gt; &gt; trying to transform that. You can only transform<BR>&gt; &gt; geometries not distances.<BR>&gt; &gt; <BR>&gt; &gt; What sort of error are you getting with ST_Distance and<BR>&gt; &gt; ST_DWithin? Keep in mind that both your geometries have<BR>&gt; &gt; to be in the same meter projection otherwise an error<BR>&gt; &gt; would be thrown.<BR>&gt; &gt; <BR>&gt; &gt; Hope that helps,<BR>&gt; &gt; Leo &amp; Regina<BR>&gt; &gt; <BR>&gt; &gt; <BR>&gt; &gt;<BR>&gt; &gt; ------------------------------------------------------------------------<BR>&gt; &gt; *From:* postgis-users-bounces@postgis.refractions.net<BR>&gt; &gt; &lt;mailto:postgis-users-bounces@postgis.refractions.net&gt;<BR>&gt; &gt; [mailto:postgis-users-bounces@postgis.refractions.net<BR>&gt; &gt; &lt;mailto:postgis-users-bounces@postgis.refractions.net&gt;]<BR>&gt; &gt; *On Behalf Of *R H<BR>&gt; &gt; *Sent:* Wednesday, March 19, 2008 6:03 PM<BR>&gt; &gt; *To:* PostGIS Users Discussion<BR>&gt; &gt; *Subject:* RE: [postgis-users] How to get the distance<BR>&gt; &gt; between geometry inmeters?<BR>&gt; &gt;<BR>&gt; &gt; isn't this the same as putting two geom w/ a meter<BR>&gt; &gt; projection into st_distance(), st_distance() still returns<BR>&gt; &gt; a cartesian distance not a distances in meters? Wouldn't<BR>&gt; &gt; you need to do something like...<BR>&gt; &gt; transform(st_distance(geom,geom),srid)??? <BR>&gt; &gt; <BR>&gt; &gt; I only ask because I am having a simular problem. My<BR>&gt; &gt; projections are in a meter projection, but I can't get<BR>&gt; &gt; st_distance() or st_dwithin() to use meters? any thoughts?<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt; ------------------------------------------------------------------------<BR>&gt; &gt; Subject: RE: [postgis-users] How to get the distance<BR>&gt; &gt; between geometry in meters?<BR>&gt; &gt; Date: Wed, 19 Mar 2008 06:56:24 -0400<BR>&gt; &gt; From: robe.dnd@cityofboston.gov<BR>&gt; &gt; &lt;mailto:robe.dnd@cityofboston.gov&gt;<BR>&gt; &gt; To: postgis-users@postgis.refractions.net<BR>&gt; &gt; &lt;mailto:postgis-users@postgis.refractions.net&gt;<BR>&gt; &gt;<BR>&gt; &gt; You'll need to transform to a meter based projection<BR>&gt; &gt; to do that. If for example you are in the U.S, SRID<BR>&gt; &gt; 2163 US National Atlas Equal Area works pretty good<BR>&gt; &gt; for measurement. It is not as accurate as UTM or<BR>&gt; &gt; State Plane, but its pretty good and covers all of US<BR>&gt; &gt; I believe and probably works for some of Canada as<BR>&gt; &gt; well (not sure about non-continental e.g. Hawaii,<BR>&gt; &gt; Alaska). <BR>&gt; &gt; <BR>&gt; &gt; e.g.<BR>&gt; &gt; <BR>&gt; &gt; SELECT road.rd_name, ht.ht_name,<BR>&gt; &gt; ST_Distance(ST_Transform(roads.the_geom,2163) ,<BR>&gt; &gt; ST_Transform(hotel.the_geom,2163)) as dist_meters<BR>&gt; &gt; FROM road, hotel<BR>&gt; &gt; WHERE &lt;some criteria here&gt;<BR>&gt; &gt; <BR>&gt; &gt; If you are somewhere else and your locations are<BR>&gt; &gt; within that projection, you can use that. Look at the<BR>&gt; &gt; utmzone function in the wiki that will help you<BR>&gt; &gt; determing the right UTM zone SRID for your data<BR>&gt; &gt; <BR>&gt; &gt; http://postgis.refractions.net/support/wiki/index.php?plpgsqlfunctions<BR>&gt; &gt; <BR>&gt; &gt; So you would use something liek<BR>&gt; &gt; SELECT utmzone(ST_Centroid(the_geom)) as srid<BR>&gt; &gt; <BR>&gt; &gt; to get the right UTM zone SRID<BR>&gt; &gt; <BR>&gt; &gt; <BR>&gt; &gt; Hope that helps,<BR>&gt; &gt; Regina<BR>&gt; &gt; <BR>&gt; &gt; <BR>&gt; &gt;<BR>&gt; &gt; ------------------------------------------------------------------------<BR>&gt; &gt; *From:* postgis-users-bounces@postgis.refractions.net<BR>&gt; &gt; &lt;mailto:postgis-users-bounces@postgis.refractions.net&gt;<BR>&gt; &gt; [mailto:postgis-users-bounces@postgis.refractions.net<BR>&gt; &gt; &lt;mailto:postgis-users-bounces@postgis.refractions.net&gt;]<BR>&gt; &gt; *On Behalf Of *Sinboy Chang<BR>&gt; &gt; *Sent:* Wednesday, March 19, 2008 3:09 AM<BR>&gt; &gt; *To:* postgis-users@postgis.refractions.net<BR>&gt; &gt; &lt;mailto:postgis-users@postgis.refractions.net&gt;<BR>&gt; &gt; *Subject:* [postgis-users] How to get the distance<BR>&gt; &gt; between geometry in meters?<BR>&gt; &gt;<BR>&gt; &gt; i want to get the distance between geometry,just like<BR>&gt; &gt; road or hotel poi,but ST_Distance() return the result<BR>&gt; &gt; in /cartesian dintance./<BR>&gt; &gt; So how can get the distance() by meters?<BR>&gt; &gt; ------------------------------------------------------------------------<BR>&gt; &gt;<BR>&gt; &gt; *The substance of this message, including any<BR>&gt; &gt; attachments, may be confidential, legally privileged<BR>&gt; &gt; and/or exempt from disclosure pursuant to<BR>&gt; &gt; Massachusetts law. It is intended solely for the<BR>&gt; &gt; addressee. If you received this in error, please<BR>&gt; &gt; contact the sender and delete the material from any<BR>&gt; &gt; computer. *<BR>&gt; &gt; ------------------------------------------------------------------------<BR>&gt; &gt;<BR>&gt; &gt; *Help make the earth a greener place. If at all<BR>&gt; &gt; possible resist printing this email and join us in<BR>&gt; &gt; saving paper.<BR>&gt; &gt; *<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt; _______________________________________________<BR>&gt; &gt; postgis-users mailing list<BR>&gt; &gt; postgis-users@postgis.refractions.net<BR>&gt; &gt; &lt;mailto:postgis-users@postgis.refractions.net&gt;<BR>&gt; &gt; http://postgis.refractions.net/mailman/listinfo/postgis-users<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt; -- <BR>&gt; &gt; ************************************<BR>&gt; &gt; David William Bitner <BR>&gt; &gt;<BR>&gt; &gt; ------------------------------------------------------------------------<BR>&gt; &gt;<BR>&gt; &gt; _______________________________________________<BR>&gt; &gt; postgis-users mailing list<BR>&gt; &gt; postgis-users@postgis.refractions.net<BR>&gt; &gt; http://postgis.refractions.net/mailman/listinfo/postgis-users<BR>&gt; &gt; <BR>&gt; _______________________________________________<BR>&gt; postgis-users mailing list<BR>&gt; postgis-users@postgis.refractions.net<BR>&gt; http://postgis.refractions.net/mailman/listinfo/postgis-users<BR><BR></body>
</html>