[postgis-users] Re: st_dwithin in SRID 4269
Sean Fulton
seanasy at gmail.com
Sat Apr 25 07:57:58 PDT 2009
On 2009-04-25 09:50:55 -0400, Sachin Srivastava
<sachin.srivastava1984 at gmail.com> said:
>
> I am a newbie, could somebody explain what distance transformation should i
> use to eliminate discrepancy in results for the following 2 queries
>
> 1) SELECT * from table1 where st_dwithin(geom1, geom2, distance);
> *(Note, geom1 and geom2 are in SRID 4269)
> *
> 2) SELECT * from table1 where st_dwithin(transform(geom1, 2163),
> transform(geom2,2163), distance);
> *
> Note:Here distance is in meters
>
> The things that i understood so far are, distance has to be in the same SRID
> as the two geoms, I knew distance in meters, so the second query will give
> me correct results however what transformation should i do in the first
> query distance value to get the same result as of query 2.
Sachin,
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.
Sean
More information about the postgis-users
mailing list