[英]How to convert the SQL geometry type to latitude (-90,90) and longitude (-180,180) in mssql?
I have a list of data with geometry column in the format of 0x6A7F0000010D340AF
.我有一个带有几何列的数据列表,格式为
0x6A7F0000010D340AF
。
I wand to retrieve the latitude and longitude in the range of (-90,90)
and (-180,180)
.我想检索
(-90,90)
和(-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.但是,它返回
5058449.313
范围内的纬度和经度值。
Any idea what I should do?知道我应该做什么吗? Can I also use Python to do the conversion?
我也可以使用 Python 进行转换吗? How can I get the
CRS
from the geom?如何从 geom 获取
CRS
?
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假设我知道
CRS
,我可以使用此代码从(Y,X)
检索到的latitude
和longitude
select geom.STY as lat, geom.STX as lon
from Table;
STX and STY return X-coordinate and Y-coordinate property of a Point instance. STX 和 STY 返回 Point 实例的 X 坐标和 Y 坐标属性。 here is what you need:
这是你需要的:
SELECT
geom.Long AS [Longitude]
,geom.Lat AS [Latitude]
FROM [Table]
Someone else has posted a proposed answer and the ensuing conversation has boiled down to "use geography
instead of geometry
".其他人发布了一个建议的答案,随后的对话归结为“使用
geography
而不是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.
在不知道这一点的情况下,您(和我们)所能做的就是推测/猜测。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.