2

I am using a SQL Server 2012 database. I have noticed that geometries and geographies interpret WKTs differently. For instance, if I construct a square polygon, clockwise:

DECLARE @geom Geometry=geometry::STGeomFromText('POLYGON((-30 -45, -30 45, 30 45, 30 -45, -30 -45))', 4326)
DECLARE @geog Geography=geography::STGeomFromText('POLYGON((-30 -45, -30 45, 30 45, 30 -45, -30 -45))', 4326)

The geometry will be interpreted (as intended) as the original square (inwards): geometry

But the geography will be interpreted as the complement of the square (outwards): enter image description here

Is this standard (and can you find a reference to why this is so)? And if so, how is it possible to construct a geography from a WKT?

1

This is not a "complement of the square", just a great circle route. It's a feature of the GEOGRAPHY type to compute great circle routes on the spheroid. You can read more about it here. The only way to follow a parallel would be to use an insane number of vertices between the meridians.

  • I think you misunderstood me: I am not annoyed at the shape of it. The problem is that in one case (geometry) the polygon defines the area inside the square, whereas in the other case (geography) the polygon defines the area outside the square... – Mac Sep 20 '13 at 17:59
  • Ahh. The change in colors threw me off. The orientation of your ring is correct (left hand rule), but SQL-Server is misinterpreting it. Try flipping the rotation of your ring to be right-hand rule. Alternatively, try casting from a Geometry type. – Vince Sep 20 '13 at 18:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.