How to find midpoint of a polyline

Shaun Gibbins 0 Reputation points
2024-04-25T11:02:46.91+00:00

How would you calculate the x,y of the midpoint of a polyline with MS SQL Server?

I can get start point and end point by using shape.STStartPoint().ToString() and shape.STEndPoint().ToString()
An arbitrary point using shape.STPointOnSurface().ToString() but can't seem to find a method to get the midpoint
For polygon I can use shape.STCentroid().ToString() but there doesn't seem to be a similar method for lines.

I am basically trying to achieve the same as the postGIS example in the attached screeny.

User's image

SQL Server | Other
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.