Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was provided with a polygon defined in WKT which has 4741 points and am able to insert it as a geography data type within a database in SQL Server 2008. However, when I view it using the spatial viewer it takes up the entire viewer and looks like a large rectangle. When I look at the same shape in Quantum GIS the shape looks like what I would expect (it is kind of a funky shape). I executed the STNumGeometries() method on the geography shape in SQL Server and it returned 1 so SQL Server thinks it is valid, but does not appear to be able to correctly understand the shape. Is there anything obvious that could be causing this issue?

The boundaries of the shape should be something like:


What I'm seeing in the SQL Server Spatial viewer is:

-180, 81
180, 81
180, -90
-80, -90
-180, 81

Any assistance woudl be greatly appreciated.

share|improve this question
Do you override the projection in qgis? – johanvdw Apr 25 '12 at 22:10
What is the query that you are using in SQL Server Management Studio to view the shape? What is the output of .STIsValid() on the geography? What about STSrid? – Kelso Apr 26 '12 at 6:02
@johanvdw I'm not sure what you mean by "overriding the projection". I imported a WKT file as a layer into QGIS and specified the SRID that I'm using in SQL Server (4326). – jwmajors81 Apr 26 '12 at 13:02
@Kelso The query that I'm executing looks like the following. select geography::STPolyFromText9'POLYGON ((-87.495199 38.781979, ..., -87.495199 38.781979))', 4236); When I execute STSrid on my shape I get back 4326. When I try to use STIsValid() of the geography I get back 1. – jwmajors81 Apr 26 '12 at 13:03
up vote 4 down vote accepted

It appears that the object I was provided was defined "inside-out" and that in order to get it to show up properly, I need to use the ReorientObject() method to fix my shape. I found this information on a blog post by Alastair Aitchison He provided the following code to properly display the data:

            geog4202.EnvelopeAngle() >= 90 THEN geog4202.ReorientObject()
     END AS geog4202  
 FROM rbasin_polygon; 

I found this information on the "The Solution" section of his article.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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