4

Given a polygon (no multipolygons, or holes) what is the best way to explode it into lines using T-SQL. The end results is I need a record for each line that makes up the polygon.

1
  • 1
    Damn it - was so hoping there would be an answer here :(
    – Pure.Krome
    Commented Aug 14, 2013 at 2:45

1 Answer 1

2

It's late answer, but better late than never.

I had same problem and solved it by using STCurveN() for getting Nth line. But, this function doesn't work with polygons, so I converted polygon into LineString using STBoundary(). Now, STCurveN() works great and you can do whatever you want with it.

geometry::STGeomFromWKB([WKBGeom],0).STBoundary().STCurveN(Index)

This is an example of using all of this. You can make loop, put counter instead of 'Index' and get all lines from polygon in a result set.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.