<br><br><div class="gmail_quote">2009/4/25 Sean Fulton <span dir="ltr"><<a href="mailto:seanasy@gmail.com">seanasy@gmail.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On 2009-04-25 09:50:55 -0400, Sachin Srivastava <<a href="mailto:sachin.srivastava1984@gmail.com" target="_blank">sachin.srivastava1984@gmail.com</a>> said:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
I am a newbie, could somebody explain what distance transformation  should i<br>
use to eliminate discrepancy in results for the following 2 queries<br>
<br>
1) SELECT * from table1 where st_dwithin(geom1, geom2, distance);<br>
*(Note, geom1 and geom2 are in SRID 4269)<br>
*<br>
2) SELECT * from table1 where st_dwithin(transform(geom1, 2163),<br>
transform(geom2,2163), distance);<br>
*<br>
Note:Here distance is in meters<br>
<br>
The things that i understood so far are, distance has to be in the same SRID<br>
as the two geoms, I knew distance in meters, so the second query will give<br>
me correct results however what transformation should i do in the first<br>
query distance value to get the same result as of query 2.<br>
</blockquote>
<br></div>
Sachin,<br>
<br>
I believe the answer is that you use query 2 that you provided.  Query 1 will always give you distance in degrees which is going to be meaningless.   You will never get meters out of Query 1 without transforming the coordinates as you did in Query 2.  You could try to convert the result of Query 1 from degrees to meters but that's really doing it backwards and I wouldn't trust the results.  Query 2 is the correct approach.<br>

<br>
 Sean<br>
<br>
<br>
_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@postgis.refractions.net" target="_blank">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>
</blockquote></div><br>Sean,<br>
<br>
Thanks a lot for your answer.<br>
<br>
1 degree is 1852 meters, so if i do distance/1852, in the Query1 i should get the correct results, but that is not happening.<br>
I guess that conversion has to do a lot with what SRID i am using. <br>
<br>
So what you suggest is the best way to find whether two geoms are at
'dist' distance apart.  Whether the following query will do in all
cases.<br>
<br>
SELECT * FROM table where st_dwithin(transform(geom1, 2163), transform(geom2, 2163), dist);<br>
<br>
Or It will again depend on which SRID i am using?<br>
<br>
<br>
<br clear="all"><br>-- <br>An Expert is the one who has made all the mistakes that are possible within a narrow field.<br>       ---------- Sachin <br>