There is no longitude with the number 181
Main Topics
Browse All TopicsHi,
I have a pair of coordinates, in latitude longitude. Looks like:
pt1( lat, lon );
pt2( lat, lon );
The two points are the upper left, and lower right corners of a rectangle. I want to find the width and height of the rectangle, in lat/lon.
I'm a little confused as the right way to do this, because the points are on a sphere - I always want to get the smallest width/height. For example, if the two points are:
(50, -179)
(51, 181)
I'd like to see the width as 3, not 357. Not sure if that's clear, or if I'm thinking about this correctly,
Thanks
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Notice that if the first of these coordinates is the upper left, and the second is the lower right of the rectangle, then a width that spans over 360 degrees, and a height that spans over 359 degrees is correct.
>> (50, -179)
>> (51, 181)
Maybe you meant to have (51, 179) as the upper left, and (50, -179) as the lower right ? Giving a rectangle with a width spanning two degrees, and a height spanning 1 degree.
To calculate the actual distance, use the great-circle distance, by using the Haversine formula for example. This site explains it quite clearly :
http://www.movable-type.co
Business Accounts
Answer for Membership
by: thehagmanPosted on 2009-10-28 at 15:04:14ID: 25688813
If the points are (x,y) and (u,v) then the height of your "rectangle" is
| x - u |
and the width is
min{ |y-v|, 360 - |y-v| }