<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>
That works great. Thanks for all the help.<BR>
<BR><BR>> Date: Thu, 20 Mar 2008 13:25:35 -0700<BR>> From: kneufeld@refractions.net<BR>> To: postgis-users@postgis.refractions.net<BR>> Subject: Re: [postgis-users] How to get the distance between geometry inmeters?<BR>> <BR>> Ah. So your first attempt is incorrect. When you first create your <BR>> geometries, you need to set the srid of your new geometries to the <BR>> projection they are currently in. Since your input is lat/long, you need <BR>> to set the srid of your new geometries to the lat/long projection. <BR>> *Then* you can transform your geometries into 26912 and query for things <BR>> like distance.<BR>> <BR>> Try this:<BR>> select AddGeometryColumn('table','geocode', 26912, 'POINT', 2);<BR>> update table<BR>> set geocode = transform(PointFromText('POINT(' || longitude || ' ' || <BR>> latitude || ')', 4269), 26912);<BR>> <BR>> -- or better, since going through the text representation introduces <BR>> coordinate drifting.<BR>> select AddGeometryColumn('table','geocode', 26912, 'POINT', 2);<BR>> update table<BR>> set geocode = transform(setsrid(MakePoint(longitude, latitude), 4269), <BR>> 26912);<BR>> <BR>> then distance(geocode, geocode) will return meters.<BR>> <BR>> I hope this clarifies things.<BR>> Cheers,<BR>> Kevin<BR>> <BR>> R H wrote:<BR>> > My explanation wasn't that great. Below is what I did.<BR>> > <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 <BR>> > || ')', 26912);<BR>> > distance(geocode, geocode) returns degrees<BR>> > <BR>> > ALTER TABLE property DROP COLUMN geocode<BR>> > <BR>> > 4269 projection in degrees<BR>> > select AddGeometryColumn('table','geocode', 4269, 'POINT', 2);<BR>> > update table<BR>> > set geocode = PointFromText('POINT(' || longitude || ' ' || latitude <BR>> > || ')', 4269);<BR>> > distance(transform(geocode, 26912), transform(geocode,26912)) returns <BR>> > meters<BR>> ><BR>> > <BR>> > I would prefer not to do the transform() if don't have to speed and <BR>> > accuracy reasons. Thanks for help. : }<BR>> > <BR>> _______________________________________________<BR>> postgis-users mailing list<BR>> postgis-users@postgis.refractions.net<BR>> http://postgis.refractions.net/mailman/listinfo/postgis-users<BR><BR></body>
</html>