Latitude, longitude and distance

For questions and discussion related to reading in and working with data.
Roddy Dog
Posts: 5
Joined: Wed Nov 08, 2006 7:21 pm

Latitude, longitude and distance

Unread post by Roddy Dog »

I have latitude and longitude coordinates for a range of cities. Can RATS compute the bilateral distances between them? If so, advice would be appreciated. Many thanks.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Latitude, longitude and distance

Unread post by TomDoan »

The (great circle) distance is relatively straightforward once the latitude and longitude are converted to radians. In what format do you have them now?
Roddy Dog
Posts: 5
Joined: Wed Nov 08, 2006 7:21 pm

Re: Latitude, longitude and distance

Unread post by Roddy Dog »

Hi Tom, I have the latitude and longitude data in decimal degrees.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Latitude, longitude and distance

Unread post by TomDoan »

See https://www.movable-type.co.uk/scripts/latlong.html. If you have latitude as running from -90 (South) to +90 (North), then you convert to radians by multiplying those by %PI/180. If you have longitude from -180 to +180, similarly convert to radians by multiplying by %PI/180. The ATAN2(y,x) function in the Javascript code is the RATS function %ATAN(y/x). (ATAN2 is designed to handle x=0).
Post Reply