SQL Server 2008 Spatial - What shape is a square?

You think this an odd title, a square is a square. Well whilst that is the case in a planar 2D world in a 3 spatial world where the square is drawn on a sphere.

This is one of the areas that catches most people out.

If you define a polygon  with corners at (0,0) (0,50) (90,50) (90, 0). So this starts on the equator at Greenwich and then moves north until the 50 longitude, then moves to a point a quarter round the world again on longitude 50 and back to the equator on latitude 90.

On first glance you would think that the line from (0,50) to (90,50) follows ring that defines longitude 50, and this is the error. The line between these two points is actually the shortest distance between, which is part of  great circle. Morten has done a great blogpost on this Straight lines on a sphere .

What is a shame is that both Mortens Shape to Shapefile to SqlServer 2008 to WPF and Virtual earth both draw the polygon as though it followed the ring of longitude. What this leads to is confusion over when shapes intersect

This forum post illustrates the issue perfectly along with some images from Steven Hemingray that displays the issue Geography .STIntersects() incorrect if polygon is big

If you are likely to be working with Spatial data covering the earth I suggest you buy a globe to enable you to visualise the world.



-
Published Sunday, January 13, 2008 11:05 PM by simonsabin

Comments

Monday, January 14, 2008 9:50 AM by GrumpyOldDBA

# re: SQL Server 2008 Spatial - What shape is a square?

although I find this interesting I'm still trying to decide how relevant the spatial stuff is for most applications and users.

Tuesday, January 15, 2008 3:46 AM by Morten

# re: SQL Server 2008 Spatial - What shape is a square?

"What is a shame is that both Mortens Shape to Shapefile to SqlServer 2008 to WPF and Virtual earth both draw the polygon as though it followed the ring of longitude. What this leads to is confusion over when shapes intersect"

The application is displaying the result on a flat screen, and thus HAS to project it onto a flat screen. It's no secret that this will cause distortions. For longitude/latityde type of data it will output in the Place Carrée Projection.

If you want it to "sub-divide" the line so you get a more accurate projection of the feature, do a very small buffer on it.

Saturday, January 19, 2008 9:52 AM by Morten

# re: SQL Server 2008 Spatial - What shape is a square?

"What is a shame is that both Mortens Shape to Shapefile to SqlServer 2008 to WPF and Virtual earth both draw the polygon as though it followed the ring of longitude"

Just an update on this... the tool now correctly curves linestrings so they follow a great circle.

Thursday, January 24, 2008 9:43 AM by SQL Server, BizTalk Server, le 64 bits et au-delà !...

# SQL SERVER 2008, DonnEES SPATIALES : QUELQUES subtilités !

La représentation de données géométriques (points, lignes, polygones) sur une surface