Reputation: 1
I have a list of data with geometry column in the format of 0x6A7F0000010D340AF
.
I wand to retrieve the latitude and longitude in the range of (-90,90)
and (-180,180)
. I have tried the following code:
select geom.STY as lat, geom.STX as lon
from Table;
However, it returns values in the range of 5058449.313
for latitude and longitude.
Any idea what I should do? Can I also use Python to do the conversion? How can I get the CRS
from the geom?
Update-Solution
Assuming that I know the CRS
, I can use this code to get the latitude
and longitude
from the (Y,X)
retrieved from
select geom.STY as lat, geom.STX as lon
from Table;
Upvotes: 0
Views: 1434
Reputation: 32737
Someone else has posted a proposed answer and the ensuing conversation has boiled down to "use geography
instead of geometry
". I agree!
But you also rightfully observe that you have what you have. And so my suggestion would be to get with whomever was responsible for writing the data and figure out how they stored latitude and longitude. That will get you a long way towards figuring out how to extract it from the extant data. Without knowing that, all you (and we) can do is speculate/guess.
Upvotes: 1
Reputation: 24603
STX and STY return X-coordinate and Y-coordinate property of a Point instance. here is what you need:
SELECT
geom.Long AS [Longitude]
,geom.Lat AS [Latitude]
FROM [Table]
Upvotes: 1