Skip to main content
Tweeted twitter.com/StackGIS/status/852787289130385408
added 13 characters in body
Source Link

I am searching distance between point and nearest road (OSM data). I wrote next SQL request:

SELECT osm_id, st_astext(geometry),  ST_DISTANCE(geometry::geography, ST_SetSRID(ST_POINT(37.72308, 55.47957), 4326), true) AS dist, roads.geometry::geography <-> ST_SetSRID(ST_MakePoint(37.72308, 55.47957),4326)  as op_dist
FROM roads ORDER BY ST_SetSRID(roads.geometry, 4326)::geography <-> ST_SetSRID(ST_MakePoint(37.72308, 55.47957),4326) ASC LIMIT 1;

result dist is: 27.830223659

I added this data to the QGIS and calculated distance with the meter instrument and it's show that the distance is 34.3 meters. enter image description here

What can be wrong and why?

PostGIS 2.2

I am searching distance between point and nearest road (OSM data). I wrote next SQL request:

SELECT osm_id, st_astext(geometry),  ST_DISTANCE(geometry::geography, ST_SetSRID(ST_POINT(37.72308, 55.47957), 4326), true) AS dist, roads.geometry::geography <-> ST_SetSRID(ST_MakePoint(37.72308, 55.47957),4326)  as op_dist
FROM roads ORDER BY ST_SetSRID(roads.geometry, 4326)::geography <-> ST_SetSRID(ST_MakePoint(37.72308, 55.47957),4326) ASC LIMIT 1;

result dist is: 27.830223659

I added this data to the QGIS and calculated distance with the meter instrument and it's show that the distance is 34.3 meters. enter image description here

What can be wrong and why?

I am searching distance between point and nearest road (OSM data). I wrote next SQL request:

SELECT osm_id, st_astext(geometry),  ST_DISTANCE(geometry::geography, ST_SetSRID(ST_POINT(37.72308, 55.47957), 4326), true) AS dist, roads.geometry::geography <-> ST_SetSRID(ST_MakePoint(37.72308, 55.47957),4326)  as op_dist
FROM roads ORDER BY ST_SetSRID(roads.geometry, 4326)::geography <-> ST_SetSRID(ST_MakePoint(37.72308, 55.47957),4326) ASC LIMIT 1;

result dist is: 27.830223659

I added this data to the QGIS and calculated distance with the meter instrument and it's show that the distance is 34.3 meters. enter image description here

What can be wrong and why?

PostGIS 2.2

Source Link

ST_DISTANCE return not same distance as QGIS

I am searching distance between point and nearest road (OSM data). I wrote next SQL request:

SELECT osm_id, st_astext(geometry),  ST_DISTANCE(geometry::geography, ST_SetSRID(ST_POINT(37.72308, 55.47957), 4326), true) AS dist, roads.geometry::geography <-> ST_SetSRID(ST_MakePoint(37.72308, 55.47957),4326)  as op_dist
FROM roads ORDER BY ST_SetSRID(roads.geometry, 4326)::geography <-> ST_SetSRID(ST_MakePoint(37.72308, 55.47957),4326) ASC LIMIT 1;

result dist is: 27.830223659

I added this data to the QGIS and calculated distance with the meter instrument and it's show that the distance is 34.3 meters. enter image description here

What can be wrong and why?