0

I dont know how the distance is differed based on WGS84 and Web Mercator.

Sample:

SELECT *, 

ST_Distance(
    the_geom::geography,
    CDB_LatLng(35.68879039,
        139.74517892)::geography
  ) / 1000 AS dist, 

 ST_Distance(
    ST_Transform(
      CDB_LatLng(
        35.68879039,
        139.74517892),
      3857),
    the_geom_webmercator
    ) / 1000 AS distance 

FROM tblrc_geom_jp

WHERE ST_DWithin(ST_Transform(CDB_LatLng(35.68879039, 139.74517892), 3857),the_geom_webmercator,1000 / cos(35.68879039 * pi()/180))

Results:

Record 1: 
 .........
dist: 0.89083829568,
distance: 1.09980160229206

Record2:
..........
dist: 0.46739726238,
distance: 0.575471921344686

Why there is a difference in distance? My assumption is I should get the same distance value for dist and distance column.

  • 3
    The latter query makes the measument in projected space and EPSG:3857 is unsuitable for area and length measurements because of huge distortions. See support.esri.com/en/technical-article/000011356. With the geography data type PostGIS knows internally how to deal with the real World that is spheric. – user30184 Dec 27 '18 at 9:46
  • Thanks for your input. As per above query I have to find list of properties within 1km radius to the given point along with distance between two points. is it safe to use ST_Distance( the_geom::geography, CDB_LatLng(35.68879039, 139.74517892)::geography ) / 1000 AS dist, Kindly help me to alter the query based on my requirements. – user134207 Dec 28 '18 at 3:02

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.