SSC-EWI-TD0069

ST_DISTANCE results are slightly different from ST_SPHERICALDISTANCE

This EWI is deprecated, please refer to SSC-FDM-TD0031 documentation

Severity

Low

Description

The Teradata function ST_SPHERICALDISTANCE calculates the distance between two spherical coordinates on the planet using the Haversine formula, on the other side, the Snowflake ST_DISTANCE function does not utilize the haversine formula to calculate the minimum distance between two geographical points.

Example Code

Input Code:

--The distance between New York and Los Angeles
Select Cast('POINT(-73.989308 40.741895)' As ST_GEOMETRY) As location1,
	Cast('POINT(40.741895 34.053691)' As ST_GEOMETRY) As location2,
	location1.ST_SPHERICALDISTANCE(location2) As Distance_In_km;

Output Code

--The distance between New York and Los Angeles
SELECT
	Cast('POINT(-73.989308 40.741895)' As GEOGRAPHY) As location1,
	Cast('POINT(40.741895 34.053691)' As GEOGRAPHY) As location2,
	!!!RESOLVE EWI!!! /*** SSC-EWI-TD0069 - ST_DISTANCE RESULTS ARE SLIGHTLY DIFFERENT FROM ST_SPHERICALDISTANCE ***/!!!
	ST_DISTANCE(
	location1, location2) As Distance_In_km;

Recommendations

Last updated