I have a polygon geometry in SqlServer and i want to split that single polygon into two features via a line that i draw through it. How can i do that with sql? I don't want to lose ANY portion of the original polygon. So buffering the line and doing a difference is not going to get it done. Unless there is a way i can "put back" the lost edges from the diff.

SqlGeometry splitLineGeom = SqlGeometry.STGeomFromText(new SqlChars(splitLineWKT.ToCharArray()), Srid);
// buffer line and get the difference from the input
SqlGeometry bufferedSplitLine = splitLineGeom.STBuffer(0.001);
SqlGeometry resultGeom = inputGeom.STDifference(bufferedSplitLine);

1 Answer 1


We need to determine where the line intersects the edges of the polygon. We then need to edit the GEOM string to Add the split line in at the location determined. To do so, you will accept the beginning line segments until you get to the split location. When you get to the first intersected segment, you will alter that segment to end at the intersection point. Add the intersect segment. Edit the next segment to use the line intersection close point as the start point and then use the remaining line segments to close out the first polygon.

Rather than programatically generating the second polygon, clip the larger polygon with the newly created polygon and retain the external portion.

I will add diagrams later when I have time.

  • I will add the diagrams and an example tomorrow. Commented May 12, 2017 at 14:39

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.