Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I convert Geometry data into a Geography data in MS SQL Server 2008?

How can I convert some Geometry data into Geography data in MS SQL Server 2008?

like image 694
Pure.Krome Avatar asked Nov 11 '08 04:11

Pure.Krome


People also ask

What is difference between geography and geometry in SQL Server?

The connecting edge between two vertices in a geometry type is a straight line. However, the connecting edge between two vertices in a geography type is a short great elliptic arc between the two vertices.

Is there a SQL function that can convert data types?

SQL Server automatically converts the data from one data type to another. For example, when a smallint is compared to an int, the smallint is implicitly converted to int before the comparison proceeds. GETDATE() implicitly converts to date style 0. SYSDATETIME() implicitly converts to date style 21.

Is geography a data type in SQL?

The geography spatial data type, geography, is implemented as a . NET common language runtime (CLR) data type in SQL Server. This type represents data in a round-earth coordinate system. The SQL Server geography data type stores ellipsoidal (round-earth) data, such as GPS latitude and longitude coordinates.


1 Answers

Yes you can but the geometry datatype is more forgiving than the geography in my experience. So there is some data you might have in geometry that you can't convert.

This article from Spatial Ed was very helpful explaining how to fix data problems and also has some sample queries to convert from Geom to Geog.

like image 161
wonderchook Avatar answered Oct 10 '22 09:10

wonderchook