locked
Is there any way to get the middle point of a line in T-SQL? RRS feed

  • Question

  • Hi guys, I have a problem with getting the middle point of a line by distance. Example I have a linestring with only 2 coordinates start and end. Let it be 6,7km long, the middle of it is 3,35km far from the start or the end point. So I need the coordinates of that middle point even if that point is not in the original linestring.

    I was searching on the forum over days since I started to work with spatial datas and found a bunch of amazing information about everything, but none of them was good solution for this problem.

    Just for fun fact, I have about 80.000 linestring which are built up by 2 or more points /and I will have way much more later/, so I'm looking for a solution which is good for both type of linestring regardless of the shape.


    • Edited by hadobas Tuesday, March 19, 2019 9:08 AM
    Tuesday, March 19, 2019 9:08 AM

All replies

  • Hi hadobas,

     

    I found a thread similar to your question, I hope this will help you. Please refer tohttps://social.msdn.microsoft.com/Forums/sqlserver/en-US/4e9f687e-ee26-437a-9b71-765d381171b6/calculate-the-middle-of-a-linestring?forum=sqlspatial

     

    Best regards,

    Dedmon Dai



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com


    Wednesday, March 20, 2019 5:50 AM
  • Hi Dedmon Dai,

    Tbh I checked all of them earlier. None was perfect for the task what I have. And I'm afraid never will be till MS don't implement a function which is directly created to solve this problem.

    Meanwhile we are using the STPointOnSurface function for now which gives back the middle point of a 2 pointed linestring geom but for multipointed ones... I afraid it's not good as I checked in QGIS.

    Wednesday, March 27, 2019 3:36 PM
  • I have a similar problem. Does anyone else have a solution?
    Thursday, March 28, 2019 8:22 AM