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
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,758 questions
{count} votes