[postgis-users] Re: st_dwithin in SRID 4269

Sachin Srivastava sachin.srivastava1984 at gmail.com
Sat Apr 25 08:40:33 PDT 2009


2009/4/25 Sean Fulton <seanasy at gmail.com>

> 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
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>

Sean,

Thanks a lot for your answer.

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.
I guess that conversion has to do a lot with what SRID i am using.

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.

SELECT * FROM table where st_dwithin(transform(geom1, 2163),
transform(geom2, 2163), dist);

Or It will again depend on which SRID i am using?




-- 
An Expert is the one who has made all the mistakes that are possible within
a narrow field.
      ---------- Sachin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20090425/58399bae/attachment.html>


More information about the postgis-users mailing list