Calculating the midpoint in a line segment


  • Hello All,

    I need to calculate the mid point of a line segment. Right now I calculated the intersected portion of a line with facility like this, PS is the pipeline table and fc is the facility table.

    ps.gmlocation.STIntersection(fc.gmlocation) as PLIntersection

    Now, How to calculate the midpoint of PLIntersection?

    Any suggestions would greatly help.


    Tuesday, July 02, 2013 3:32 PM


  • Assumming thatPLIntersection is a LineString (which it appears to be), then you could try something like:

    dbo.LocateAlongGeog(PLIntersection, PLIntersection.STLength()/2)

    This assumes that you are using the Geography data type.  If you are using the Geometry data type, use dbo.LocateAlongGeom().

    Note that dbo.LocateAlongGeog() and dbo.LocateAlongGeom() are functions provided in the SQL Server Spatial Tools Project on CodePlex.  These tools were developed by the SQL Server Spatial Team and are free of charge.

    - Ed

    Ed Katibah Spatial Ed Blog

    Friday, July 05, 2013 4:15 PM