简体   繁体   English

SQL Server 2008 Geography .STBuffer() 距离测量单位

[英]SQL Server 2008 Geography .STBuffer() distance measurement units

I'm working with a geographic point using lat/long and need to find other points in our database within a 5 mile radius of that point.我正在使用经纬度处理地理点,需要在我们的数据库中找到该点 5 英里半径内的其他点。 However, I can't seem to find out what the "units" are for STBuffer, it doesn't seem to conform to feet, miles, meters, kilometers, etc. The documentation only refers to them as "units", any suggestions?但是,我似乎无法找出 STBuffer 的“单位”是什么,它似乎不符合英尺、英里、米、公里等。文档仅将它们称为“单位”,任何建议? Thanks谢谢

[...] from geography::STGeomFromText('POINT(xy)', 4326).STBuffer(z).STIntersects(geography::STGeomFromText('POINT(' + CAST(v.Longitude as varchar(max)) + ' ' + CAST(v.Latitude as varchar(max)) + ')', 4326)) = 1 [...] 来自 geography::STGeomFromText('POINT(xy)', 4326).STBuffer(z).STIntersects(geography::STGeomFromText('POINT(' + CAST(v.Longitude as varchar(max)) + ' ' + CAST(v.Latitude as varchar(max)) + ')', 4326)) = 1

The unit of measurement depends on the spatial reference system in use.测量单位取决于使用的空间参考系统。 See this system view for details:有关详细信息,请参阅此系统视图:

SELECT * FROM sys.spatial_reference_systems;

STBuffer is in meters. STBuffer 以米为单位。 More info here.更多信息在这里。

To convert, miles to meters, divide the number of miles by 0.0006213712要将英里转换为米,请将英里数除以 0.0006213712

(ie 5 miles / 0.0006213712 = 8,046.72 meters) (即 5 英里 / 0.0006213712 = 8,046.72 米)

For anyone visiting this page who is confused by why their buffer distances may not be appearing in meters, it may be because you are using the geometry data type versus the geography data type.对于访问此页面的任何人来说,他们对为什么他们的缓冲区距离可能没有以米为单位出现感到困惑,这可能是因为您使用的是几何数据类型而不是地理数据类型。 In my case, it was clear that geography operates with meters, while geometry does not (degrees it appears?) even if the spatial reference system is set correctly for geometry.就我而言,很明显,地理以米为单位运行,而几何不(它出现的度数?),即使为几何正确设置了空间参考系统。

To convert latitude and longitude to a geography point:要将纬度和经度转换为地理点:

geography::Point(latitude, longitude, 4326) -- 4326 is WGS-84 EPSG Projection

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM