Question

Hi i am trying to create an geography area our of North-West lat & long, South-east lat&long But i get this exception when i run query with these co-ordinates.

Select (geography::STGeomFromText('POLYGON((-0.534717 0.524190,0.426951 0.524190,0.426951 -0.578706,-0.534717 -0.578706,-0.534717 0.524190))', 4326))

A .NET Framework error occurred during execution of user-defined routine or aggregate "geography": 
Microsoft.SqlServer.Types.GLArgumentException: 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. To create a larger than hemisphere geography instance, upgrade the version of SQL Server and change the database compatibility level to at least 110.
Microsoft.SqlServer.Types.GLArgumentException: 
   at Microsoft.SqlServer.Types.GLNativeMethods.GeodeticIsValid(GeoData& g, Double eccentricity, Boolean forceKatmai)
   at Microsoft.SqlServer.Types.SqlGeography.IsValidExpensive(Boolean forceKatmai)
   at Microsoft.SqlServer.Types.SqlGeography..ctor(GeoData g, Int32 srid)
   at Microsoft.SqlServer.Types.SqlGeography.GeographyFromText(OpenGisType type, SqlChars taggedText, Int32 srid)
.
Was it helpful?

Solution

You've got the incorrect ring orientation, so your polygon is "inside-out". You should use this instead:

SELECT geography::STGeomFromText('POLYGON ((0.426951 0.52419, -0.534717 0.52419, -0.534717 -0.578706, 0.426951 -0.578706, 0.426951 0.52419))', 4326);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top