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'm using Microsoft.SqlServer.Types to do intersections on polygons.

SqlChars scFullSwath = new SqlChars(new SqlString(fullSwath));
SqlGeography fullSwathGeom = SqlGeography.STGeomFromText(scFullSwath, 4326); //Error out on big polygons

According to the documentation:

This geography data type method supports FullGlobe instances or spatial instances that are larger than a hemisphere.

This is an example of a valid polygon that works:

POLYGON((14.1977984372468 49.7086179545186,14.0975789966719 49.490931050796,12.5900898047007 45.9899553708373,11.2416180142584 42.4725018717541,10.0189326479206 38.9414519482468,8.89701484835269 35.3990096092695,7.85664665475729 31.8469172968655,6.88278698469561 28.2865986360566,6.79081552980762 27.9386602738175,13.5662986089156 26.3473709096527,13.6780927958767 26.689514921038,14.8759019115514 30.1864100426377,16.1814448369554 33.6666019429789,17.6150918852402 37.1268498599495,19.2025294573402 40.5631314224601,20.9765131252558 43.9703521754743,22.979305680181 47.3419272187238,23.1129487986833 47.550807797626,14.1977984372468 49.7086179545186))

enter image description here enter image description here enter image description here

As you can see it has correct "ring orientation" as mentioned by others on how to solve this problem.

Problematic Polygon:

POLYGON((14.1977984372468 49.7086179545186,14.0975789966719 49.490931050796,12.5900898047007 45.9899553708373,11.2416180142584 42.4725018717541,10.0189326479206 38.9414519482468,8.89701484835269 35.3990096092695,7.85664665475729 31.8469172968655,6.88278698469561 28.2865986360566,5.9634518930894 24.7192549336294,5.08892530812995 21.1459314523495,4.25119070563764 17.5675630126313,3.44351321077389 13.985005924225,2.66012537113857 10.3990599134859,1.89598509474054 6.81048335641945,1.1465837262999 3.22000326571774,0.407788590200467 -0.371677988700824,-0.324291851935639 -3.96387852745089,-1.05342955105917 -7.55593436365933,-1.78339318076703 -11.1471976352728,-2.51806681006348 -14.7370348965234,-3.26157909469963 -18.3248253652926,-4.01845238057626 -21.9099575448643,-4.79378397261009 -25.4918242201927,-5.59347616002234 -29.0698144501277,-6.42453876771587 -32.6433010407778,-7.29549969159991 -36.211621758752,-8.21697775205904 -39.774051024648,-9.20250398028347 -43.3297576050588,-10.2697317463825 -46.8777402574098,-11.4422726186086 -50.4167283166232,-12.7525722806525 -53.9450245293382,-14.2465807422689 -57.460247128251,-15.9916555981513 -60.9588899763672,-18.0905888714589 -64.4355326552956,-20.7079207471342 -67.8813344075985,-24.1225654627664 -71.2809433475941,-28.8408188355059 -74.6055692800629,-35.8463883696685 -77.7924382401655,-47.2063856590074 -80.7065857738326,-66.9785058803618 -83.0052691165418,-97.9750390100537 -83.9384177606558,-128.643556044951 -82.9375576334944,-148.00391894514 -80.6054307189309,-159.139108412103 -77.6779603190499,-166.029981462794 -74.4857156018706,-170.684840043845 -71.1595774540993,-174.061735811063 -67.7603847042112,-176.654974376848 -64.3161893679373,-178.737627762043 -60.8419881952857,179.528828146465 -57.3464295623487,178.043316526901 -53.8348168444905,176.739494352815 -50.3105766671909,175.572040277034 -46.7760308036764,174.508913762508 -43.2328270400433,173.526773241969 -39.6821924739992,172.608150515157 -36.1250880589781,171.739644782635 -32.5623067842119,170.910730829305 -28.9945370682842,170.112949405406 -25.4224048384334,169.339341980169 -21.846501773014,168.58404528169 -18.2674039867933,167.841992255889 -14.6856847908136,167.10868448838 -11.1019226955191,166.380012729174 -7.51670676722884,165.941432353483 -5.35533773778457,159.776665988585 -6.57902683369825,160.177433883186 -8.72380367556899,160.822079257621 -12.2824960195651,161.443414585553 -15.8408809387369,162.043430549844 -19.398296263682,162.623815450699 -22.9541494522971,163.185982448494 -26.5079178675654,163.73108551617 -30.0591498688561,164.26002344831 -33.6074656910582,164.773430063532 -37.1525586793143,165.271646700603 -40.6941960473808,165.754670150563 -44.2322194161788,166.222063966029 -47.7665451784619,166.672811789969 -51.2971640454233,167.105074008517 -54.8241408276084,167.515774078978 -58.3476136686714,167.899867192761 -61.8677941701833,168.248975202488 -65.3849687010856,168.548650592718 -68.899502591151,168.772353767069 -72.4118497117796,168.86640163402 -75.9225678964884,168.706491743022 -79.4152462878817,167.927467291569 -82.8961624959035,164.732805578133 -86.3800283841654,90.7183887585475 -89.5255796637184,0.869476212320378 -86.5107511675832,-2.53511419326111 -83.0263801264859,-3.35347936173547 -79.5441534398354,-3.52714539202692 -76.0510262182095,-3.43943131235962 -72.5383029542796,-3.21903289869946 -69.0235405384683,-2.9212128486995 -65.5061918147878,-2.57316966777165 -61.9858166317077,-2.18966563058102 -58.4620663215801,-1.77924490961034 -54.9346738854397,-1.34704681853976 -51.4034493155988,-0.896205077108871 -47.8682781762759,-0.428595677041346 -44.329121290399,0.0547408943611908 -40.786015213663,0.553351609541117 -37.2390723089532,1.06722155761446 -33.6884808125902,1.59668364420096 -30.1345044451656,2.14236556311945 -26.5774814836359,2.70516170545828 -23.0178236671284,3.28622299594447 -19.4560147963763,3.88696070360683 -15.8926094397698,4.50906229046143 -12.3282317178813,5.15451864742359 -8.76357458301829,5.82566311373916 -5.19940031270823,6.5252236911824 -1.63654187123703,7.25639066630586 1.92409340837588,8.02290309530139 5.48151764590984,8.82915889854057 9.03465271716534,9.6803551482695 12.5823158658826,10.5826675131422 16.1231989255446,11.5434812953803 19.6558394558106,12.5716910643249 23.1785804132512,13.6780927958767 26.689514921038,14.8759019115514 30.1864100426377,16.1814448369554 33.6666019429789,17.6150918852402 37.1268498599495,19.2025294573402 40.5631314224601,20.9765131252558 43.9703521754743,22.979305680181 47.3419272187238,23.1129487986833 47.550807797626,14.1977984372468 49.7086179545186))

enter image description here

KML Version for google earth.

When I give it this polygon that is longer than a hemisphere it fails and errors out:

Error:

24205: The specified input does not represent a valid geography instance because it exceeds a single hemisphere. Each geography instance must fit inside a single hemisphere. A common reason for this error is that a polygon has the wrong ring orientation.

Documentation said it can handle FullGlobe so what's the problem?

enter image description here

share|improve this question
    
starting points? geography::STGeomFromWKB(geom.STUnion(geom.STStartPoint()).STAsBinary(), geom.STSrid) - beginningspatial.com/fixing_invalid_geography_data –  Mapperz Jul 26 '12 at 21:44

1 Answer 1

This happens when the ring orientation is not correct. Geometry is more tolerant than Geography. I was doing bulk uploads in the database using ETLs and I was first updating my geometry from text and then using my populated geometry column to update the geography type.

This link helped me a lot and maybe of use to you too http://www.beginningspatial.com/fixing_invalid_geography_data

Hope this helps.

share|improve this answer
    
Thanks but, as i mentioned in my question, my ring orientation is correct. This is also illustrated in with numbers on an uploaded image. –  CaptDragon Aug 14 '12 at 12:46

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.