Calculate coordinates from starting point using distance and direction in SQL Server

I need help figuring out how to calculate a new coordinate point when I have a starting location, a direction angle, and a specific distance. I’m working with SQL Server’s geography data type but can’t find a built-in OGC function that does this calculation.

Basically, I want to find the exact lat/long coordinates if I travel a certain distance in a specific direction from my current position. For example, if I’m at a known coordinate and I go 3 miles in a northeast direction, what would be the resulting latitude and longitude?

Before I start writing custom Haversine formulas or other complex math functions, does anyone know if there’s an easier way to do this in SQL Server? Any suggestions would be really helpful.

SQL Server’s geography data type has methods for calculating new coordinates. You can use STBuffer with STPointOnSurface, but that gets messy with all the geometric handling. Easier approach: use the geography::Point function with calculated lat/long values. Convert your angle to radians and use trig functions to get the new coordinates. You’ll need to calculate lat/long offsets based on your distance and angle. For better accuracy over longer distances, factor in Earth’s curvature - the geography type handles this automatically when you define points in decimal degrees. I’ve found it helps to wrap these calculations in a dedicated function so you can reuse them across different queries.

try stdistance and stintersection methods. create a circle with stbuffer around ur starting point using ur distance as radius, then intersect it with a line pointing where u wanna go. it’s a bit hacky but works without writing custom math functions.

interesting! are u using geographic projections or treating it like flat? earth’s curvature messes with calculations over long distances. what accuracy does ur project need?