ThinkGeo.com    |     Documentation    |     Premium Support

Move Vertex to closest line

Is there a function I can use to move a vertex on layer A so it overlaps the closest line on layer B.


My situation is I divide a polygon into multiple sections which exist on another layer and sometimes the vertices of some of these sub polygons are off by the slightest of margins.  I would like to run a routine to automatically see if the vertices share the same outer boundary and if not then adust the vertices of the sub polygons to align with the overall polygon border on layer A.


Does that make sense?



To sum it up, I’m trying to fix slivers between two polygons.  One of these polygons happens to be inside the other.

  From your description, I suppose you have a situation like in the picture below with one polygon overlapping another polygon:




And, you want to have the blue polygon, let say, alining with the red polygon to no longer have the overlapping (sliver). The result would be like this:




 To do this, you need to use the GetDifference geometric function. So the code would be like this:



 



MultipolygonShape newMultiplepolygonShape = (MultipolygonShape)BluePolygonShape.GetDifference(RedPolygonShape);

 I isolated the code to show only the geometric part. If you are dealing with some layers with various features in them, you need to write the logic for accomplishing that in a loop etc.


I hope this will help.