Teradata distance between two geo-coordinates using ST_SPHERICALDISTANCE

General
Fan

Teradata distance between two geo-coordinates using ST_SPHERICALDISTANCE

I have read that in Teradata Version 13 and onward you can use ST_SPHERICALDISTANCE for calculating geo-distance.

I've written a simple test query in Teradata:

 

 Select

  Cast('POINT(-35.0000, 150.0000)' As ST_GEOMETRY) As location1,

  Cast('POINT(-35.0000, 149.0000)' As ST_GEOMETRY) As location2,

  location1.ST_SPHERICALDISTANCE(location2) As Distance_In_km

 

But received following error: Teradata row not delivered (trget): 13 OGRGeometryFactoryX::createFromWkt failed.

 

Is this an issue with the query or configuration? Thanks


Accepted Solutions
Junior Contributor

Re: Teradata distance between two geo-coordinates in using ST_SPHERICALDISTANCE

Simply remove the comma within the point definition :)

 

Select
Cast('POINT(-35.0000 150.0000)' As ST_GEOMETRY) As location1,
Cast('POINT(-35.0000 149.0000)' As ST_GEOMETRY) As location2,
location1.ST_SPHERICALDISTANCE(location2) As Distance_In_km

Btw, another way to create a point:

NEW ST_GEOMETRY('POINT(-35.0000 150.0000)')
1 ACCEPTED SOLUTION
2 REPLIES
Junior Contributor

Re: Teradata distance between two geo-coordinates in using ST_SPHERICALDISTANCE

Simply remove the comma within the point definition :)

 

Select
Cast('POINT(-35.0000 150.0000)' As ST_GEOMETRY) As location1,
Cast('POINT(-35.0000 149.0000)' As ST_GEOMETRY) As location2,
location1.ST_SPHERICALDISTANCE(location2) As Distance_In_km

Btw, another way to create a point:

NEW ST_GEOMETRY('POINT(-35.0000 150.0000)')
Fan

Re: Teradata distance between two geo-coordinates in using ST_SPHERICALDISTANCE

Thanks @dnoeth the query works now!

But one thing I found is that ST_SPHERICALDISTANCE didn't return the distance in unit of km or m. How would I convert to km?

See wolframalpha.com/input/?i=lat-35+lon149+to+lat-35+lon150

(sorry for the cross posting)