For storing Geospatial data, Geometry field is used in SQL server or Oracle Spatial. I want to know is there any way where we can convert this geometry field into set of latitudes and longitudes.
Converting geometry field into set of google latlng
1.4k Views Asked by SPBeginer At
2
There are 2 best solutions below
0

If you can convert the Geometry field to a Geography data type (this article has some examples of how to do that), then you can select GeographyValue.Lat and GeographyValue.Long.
I'm assuming that the data in your geometry column is expressed using a projected coordinate reference system? If so, you'll have to unproject and/or transform it into the appropriate geographic coordinate reference system first. For Google Maps, this needs to be EPSG:4326 (WGS84)
Simply converting between the geometry and geography columns via WKT or WKB as suggested by paulH will not change the type of coordinates in which your data is expressed, and SQL Server provides no in-built transformation functions. Instead, you must make use of a third-party library such as Proj.NET (http://projnet.codeplex.com) which provides both projection and datum transformation functions using 7-parameter Helmert transforms. It's relatively easy to import this library and then create a SQLCLR procedure based on it to convert data between different SRIDs.
Once you've got a column of geography coordinate data in the correct SRID, you can select the latitude/longitude coordinate values of a given point using the Lat and Long properties.