Asked • 03/18/19

Trying to convert geometry to geography keep failing in MSSQL 2012?

In MSSQL I have LineString in Geometry type. When I try to convert it to geography using : GEOGRAPHY::STGeomFromText(geom.MakeValid().STUnion(geom.MakeValid().STStartPoint().MakeValid()).STAsText(),4326) I still get error that Msg 6522, Level 16, State 1, Line 19 A .NET Framework error occurred during execution of user-defined routine or aggregate "geography":System.ArgumentException: 24200: The specified input does not represent a valid geography instance. Use MakeValid to convert the instance to a valid instance. Note that MakeValid may cause the points of a spatial instance to shift slightly.System.ArgumentException: at Microsoft.SqlServer.Types.SqlGeography..ctor(GeoData g, Int32 srid) at Microsoft.SqlServer.Types.SqlGeography.GeographyFromText(OpenGisType type, SqlChars taggedText, Int32 srid) Any idea how I can convert it to geography ? Any idea how I can share the LineString ? Its very long (exceeding this post body length)

1 Expert Answer

By:

Rize S. answered • 03/23/23

Tutor
New to Wyzant

Master's in MISM, 25 yrs Exp: SQL Specialist

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.