9

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(x y)', 4326).STBuffer(z).STIntersects(geography::STGeomFromText('POINT(' + CAST(v.Longitude as varchar(max)) + ' ' + CAST(v.Latitude as varchar(max)) + ')', 4326)) = 1

3 Answers3

9

The unit of measurement depends on the spatial reference system in use. See this system view for details:

SELECT * FROM sys.spatial_reference_systems;

gmadd
  • 1,146
  • 9
  • 18
Chris
  • 91
  • 1
  • 1
  • 4
    Even though the original question specified geography, I arrived here looking generally for STBuffer unit of measure (geometry or geography). To save someone else looking further, for geometry, the unit of measure is the coordinate system of the geometry. So if you are using Lat/Long, geometry.STBuffer(1) would be 1 whole degree, not 1 meter. 1 degree is huge in comparison -- about 69 miles. – David Storfer Oct 17 '13 at 06:19
  • Which just goes to show you that if you're trying to represent points on the globe, geography is the correct data type to use (not geometry)! – Ben Thul Jun 01 '15 at 03:20
6

STBuffer is in meters. More info here.

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

(i.e. 5 miles / 0.0006213712 = 8,046.72 meters)

Mark Bowytz
  • 1,322
  • 1
  • 10
  • 14
  • 2
    Weird the term "meter" only shows up in the *example*, and not in the description of the `distance` parameter. – Crescent Fresh Jun 04 '10 at 13:58
  • Distance all arround the world is calculated in Meters/Kilometers/etc. I think that only USA still uses the imperial system (inch/foot/miles). – Nordes Oct 25 '10 at 09:54
  • It depends on your spatial reference system and whether you are using the geography or geometry datatype! – jport Nov 03 '21 at 18:11
1

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
Colonel_Old
  • 852
  • 9
  • 15