简体   繁体   中英

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. 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? 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

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. More info here.

To convert, miles to meters, divide the number of miles by 0.0006213712

(ie 5 miles / 0.0006213712 = 8,046.72 meters)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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