Scott Abraham
asked on
sql 2012 geometry to lat long in wgs84
I have a query which extracts latitude and longitude from a geometry field in a table.
SELECT TOP 10 *
, Geom.STX as [Latitude]
, Geom.STY as [Longitude]
FROM LOCATIONS_ALL_ACTIVE
The property of the GEOM field is GEOM(geometry, null)
It produces this:
LOC Latitude Longitude
1709036 2566110.742 971741.23
1480125 2546663.063 1004989.767
1473797 2517822.745 961433.929
1473851 2499826.1 901428.05
1469381 2546028.5 954613.67
1469322 2498035.41 927803.9
1475057 2497484.54 938479.25
1473436 2505412.3 917097.54
1800985 2537353.598 939850.052
1473819 2550003.19 962727.89
I am trying to get these coordinates to work with a web service and they are telling me it needs to be in a wgs84 projection. The above coordinates place it an ocean
SELECT TOP 10 *
, Geom.STX as [Latitude]
, Geom.STY as [Longitude]
FROM LOCATIONS_ALL_ACTIVE
The property of the GEOM field is GEOM(geometry, null)
It produces this:
LOC Latitude Longitude
1709036 2566110.742 971741.23
1480125 2546663.063 1004989.767
1473797 2517822.745 961433.929
1473851 2499826.1 901428.05
1469381 2546028.5 954613.67
1469322 2498035.41 927803.9
1475057 2497484.54 938479.25
1473436 2505412.3 917097.54
1800985 2537353.598 939850.052
1473819 2550003.19 962727.89
I am trying to get these coordinates to work with a web service and they are telling me it needs to be in a wgs84 projection. The above coordinates place it an ocean
GEOMETRY is a coordinate in a plane. WGS84 is a coordinate in a sphere. WGS84 coordinates are also a latitude/longitude pair.
The problem is: What is the origin of your GEOMETRY values? When you don't know this, then it's a really hard task to get the projection right. Cause there are different transformations possible, which have a different precision.
Also, what does "The above coordinates place it an ocean." mean? Sounds like you need to provide an altitude in that web service.
The problem is: What is the origin of your GEOMETRY values? When you don't know this, then it's a really hard task to get the projection right. Cause there are different transformations possible, which have a different precision.
Also, what does "The above coordinates place it an ocean." mean? Sounds like you need to provide an altitude in that web service.
ASKER
Our coordinates are in northing/easting NAD83. I can use OGR2OGR for the conversion. I just thought maybe I was missing an easy way to do it inside of an SQL query.
I don't know an easy one, cause I haven't done conversion on that level.
My approach would be CLR-function doing this, but this requires some C# skills.
My approach would be CLR-function doing this, but this requires some C# skills.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
1. Determine the current coordinate system (if you don't know already).
2. Find a way to do the conversion, and test it manually to see if you get to the right location.
3. Find a way to do the conversion automatically (preferably within SQL Server).
If you don't know the answer to 1, you could ask in the 'GIS & GPS Programming' if anyone can help you out. Just mention a few of the coordinates and to what location they refer and someone might know the answer.