Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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:

-89.25521,39.22638
-87.49851,38.84994
-87.97533,38.21419
-89.17156,38.11799
-89.25521,39.22638

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
add comment

1 Answer 1

up vote 3 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 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:

SELECT   
    CASE
        WHEN 
            geog4202.EnvelopeAngle() >= 90 THEN geog4202.ReorientObject()
        ELSE 
            geog4202    
     END AS geog4202  
 FROM rbasin_polygon; 

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

share|improve this answer
add comment

Your Answer

 
discard

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.