3

I need to convert Sql Server geometry datatype to latitude /Longitude

I have just imported a shapefile to my table (geometry)

This query does not work:-

select 
 geom.Lat as [Latitude],
 geom.Long as [Longitude]
from dbo.special

Error I get is:

Could not find property or field 'Lat' for type 'Microsoft.SqlServer.Types.SqlGeometry' in assembly 'Microsoft.SqlServer.Types'.

This query returns Latitude and longitude but the format doesnot seem to match google maps:-

select U.name, Centroid.STY as Longitude, Centroid.STX as Latidude
 from
 ( select geom.STCentroid() as Centroid, NAME from dbo.special)

Also:-

SELECT ST_X (ST_Transform (geom, 4326)),
 ST_Y (ST_Transform (geom, 4326)) 
 FROM special 

gives

'ST_Transform' is not a recognized built-in function name.

Please suggest

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Oct 8, 2014 at 8:00
2
  • 1
    You have several questions here. Please choose the most important one and efit the question to ask only that. You can ask the other questions in separate Questions. Commented Oct 8, 2014 at 11:35
  • Hi, I need to convert a geometry datatype to Latitude\Longitude. And then I have mentions a few ways i tried but failed. Like the first query gives an error which i dont understand. Could you please tell me what i am doing wrong Commented Oct 8, 2014 at 11:49

2 Answers 2

3

This work for me:

 select 
 [GEOM].[STY] as [Latitude],
 [GEOM].[STX] as [Longitude]
 FROM [dbo].[SPECIAL]
answered Nov 30, 2018 at 10:37
2

Try using brackets around Lat and Long:

select 
[geom].[Lat] as [Latitude],
[geom].[Long] as [Longitude]
from dbo.special
answered Dec 8, 2014 at 23:00
1
  • This did not work. Could not find property or field 'Lat' for type 'Microsoft.SqlServer.Types.SqlGeometry' in assembly 'Microsoft.SqlServer.Types'. Commented Sep 22, 2016 at 19:29

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.