Straight lines on a sphere

by Morten 1/12/2008 9:39:00 AM

There was a question in the Sql Server Spatial/Katmai forums about why a straight line on a sphere didn't "look straight".

Katmai both have planar and spherical geometry types. The spherical type makes it easier to handle things like straight lines, distances and areas over large distances, and depending on which type you choose, you can get very different results.

Consider traveling on a straight line from Vancouver to Frankfurt. They are both located roughly at latitude 50°N. So the line would follow latitude 50°N right? Well that's true for a planar coordinate system:

So according to The Flat Earth Society (who actually believes the Earth is flat) the green line above shows the shortest distance between the two cities. But what we are actually seeing is an artifact of working with a planar coordinate system depicting a world that is not planar.

Using a spheric coordinate system, we get a different result. When looking at this line in a projected coordinate system, like the Mercator projection I've used here, the line doesn't look straight (left image below). However if we look at this in a 3D view (right image), it becomes apparent that the "curved line" is actually the shortest line between the two cities.

The difference between using the two geometry types gets really apparent when you try to find the shortest distance from New York to the line in the two coordinate systems. In the planar case, Quebec is approximately the point where the line is the closest to New York. In the spherical case, the line never gets closer to New York than from Vancouver where it started out.

Another way that I like to think of why following a latitude is not the shortest route, is imagining two guys standing a few feet from the North Pole with the pole between them. Which way is the shortest path between them: Walking straight over the pole or following the latitude at 89.999°N around it? Now imagine how this line would look on a map.

We can extend this further and have the two men go further and further away from each other.  If one man gets a little further south than the other, the line wouldn't pass the pole, but go by just next to the it - it still wouldn't follow the latitude. Since the North Pole is just a point we humans "made up", we can abstract it and think of a pole in the ground anywhere on Earth. The bottom line is that the North Pole and the latitudes are all imaginary, and doesn't really exist, and definitely doesn't help describing the shortest distance.

Only at Equator would it be a good idea to follow the latitude, which is because this is the only latitude that is a great circle, and it so happens to be that any straight line between two points will describe parts of a great circle. Longitudes however are all great circles, and the line between the two men describe parts of a longitude. The reason we think that the horizontal line between Vancouver and Germany is the shortest path, is simply because we have to project the round Earth onto a flat piece of paper, and this causes all sorts of things to get distorted.

Currently rated 5.0 by 5 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Spatial References | SqlServer Spatial

Related posts

Comments

1/12/2008 7:55:38 PM

Dave Smith

If you visualize a big knife, which plunges into the earth at location "a" - and penetrates directly to the center of the earth, and then slices directly to location "b" - that slice then represents a plane formed with point "a", point "b" and the center of the earth, which intersects the spheroid. The line of intersection is the great circle route.

A simplest approach toward the math is in spherical trigonometry - with tools like Yahoo, Google and Virtual Earth using a mapping of lat/long back and forth between flat, rectangular cartesian space to a simple sphere, instead of a more complex mapping, it amounts to trigonometric relationships. There are a number of excellent resources dealing with spherical trigonometry, which are quite accessible to anyone with a good understanding of trig - for more advanced work, consider NGS Manual No. 5 and other resources, which delve into projections, geoids and ellipsoids.

Dave Smith

1/14/2008 5:28:22 PM

TiPi

Great explanation, specially thanks for going to the trouble of creating the images to better illustrate the text.

Thanks also go to Dave for the leads to spherical trigonometry.

TiPi

1/31/2008 8:54:20 PM

Mike Kretzler

Quibble: Shouldn't "and areas on a large scale" say "small scale" instead, at least if we're talking about map scale?

Mike Kretzler us

1/31/2008 9:11:06 PM

Morten

Hehe I see your point. In this case I didn't mean mapscale (and why is it we came up with this confusing term anyway?). I'll change the text to avoid the confusion.

Morten us

2/24/2008 7:35:48 AM

Andre Tude

Is there "CurveString" and/or "curve polygon "in Sql Server 2008 ?

Andre Tude br

2/24/2008 7:45:24 AM

Morten

No, Microsoft implemented OGC's "Simple Features Specification" which only deal with linear line-segments.
The spec does have room for extending it with curves (the abstract super-class of LineString is actually 'Curve'), but the specific implementation of various types of curves never made it into the spec.

Just to be sure you are not mixing things: This blogpost doesn't deal with curved lines, it deals with how straight lines are represented on a globe (which might make them look like curves but they are in fact straight).

Morten us

3/20/2008 11:05:50 PM

BlueB

Now, the Earth is neither flat nor spherical, wherefore it is necessary to decide on a model when working with geodetic coordinates as well. I read here (escuelle.blogspot.com/.../...-sql-server-2008.html) that SQL Server 2008 will not support coordinate transformations and that only WGS84 will be supported. Do you have any information on that?

BlueB se

3/20/2008 11:30:31 PM

Morten

SQLServer2008 supports most datums. It's true that it cannot convert between them, but the datum definition is there, and it uses the SRID of the feature to determine the distance between two points for the geodetic datatype. If you change the SRID to a one that uses a different datum, you will see different values in you distance, area and buffer queries.

Morten us

3/21/2008 10:38:11 AM

BlueB

Ah! Didn't know that. Well, that changes things. I have never needed on-the-fly coordinate transformations myself, but being able to specify different coordinate systems is crucial imho. Thank's for the info!

BlueB se

Comments are closed

Powered by BlogEngine.NET 1.3.1.0

About the author

Morten Nielsen Morten Nielsen
Wanna-be
<--That's me
E-mail me Send mail

Calendar

<<  July 2008  >>
MoTuWeThFrSaSu
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

View posts in large calendar

Recent posts

Recent comments

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

Sign in