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.

  • Do you override the projection in qgis?
    – johanvdw
    Commented Apr 25, 2012 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
    Commented Apr 26, 2012 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
    Commented Apr 26, 2012 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
    Commented Apr 26, 2012 at 13:03

1 Answer 1


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 http://alastaira.wordpress.com/2012/01/27/ring-orientation-bigger-than-a-hemisphere-polygons-and-the-reorientobject-method-in-sql-server-2012/. 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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