So I have a Geography type spatial column in SQL Server. This represents lat/long coordinates as a single point
Values look like this (as a string)
POINT (-96.63 32.97)
What I want to do is expand it into a circle/polygon by a specific number of miles.
I think STBuffer
is the command I want, but I have no idea how to use it expand the radius by X number of miles.
My goal is to then later do STContains
on it to see if some other geography object is contained inside of it. Something like this:
WHERE L.SPATIAL_OBJ.STContains(IBL.SPATIAL_OBJ) = 1
I figured it out. It looks like this. I would do it as a function.
CREATE FUNCTION [dbo].[udf_mile_ring]
(
@lat FLOAT,
@lon FLOAT,
@miles int
)
RETURNS GEOGRAPHY
AS
BEGIN
DECLARE @meters FLOAT = @miles / 0.000621371;
RETURN GEOGRAPHY::Point(@lat, @lon, 4326).STBuffer(@meters);
END
GO