<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to remove self intersections in polylines using ArcObjects? in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-remove-self-intersections-in-polylines/m-p/534026#M14409</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I remember a colleague addressing this issue with the output of a stream digitizer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(using FORTRAN 77 with ArcInfo 4.03 object code, in 1988 [The more things change...]).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The "knots" could be removed by identifying the segments that changed direction&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;by nearly 180 degrees. You could speed up your solution (and make it handle multiple&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;occurances) by passing through the vertex list once, calculating the orientation of &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;segments from A to B ( atan2(By-Ay,Bx-Ax) ) and B to C ( tan2(Cy-By,Cx-Bx) ) and&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;looking for an absolute delta greater than 165-170 degrees. If you organize the loops&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;right, you'll only need to call atan2 nverts-1 times (sliding the A B C designations across &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;the length of the line). O(N) beats O(N^2) every time.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;- V&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;PS: You should also look for coincident points (Cy-By == 0 &amp;amp;&amp;amp; Cx-Bx == 0) while you're at it...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 04 Oct 2012 14:38:11 GMT</pubDate>
    <dc:creator>VinceAngelo</dc:creator>
    <dc:date>2012-10-04T14:38:11Z</dc:date>
    <item>
      <title>How to remove self intersections in polylines using ArcObjects?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-remove-self-intersections-in-polylines/m-p/534024#M14407</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a river network and a tool I am creating is failing because there are self intersections in the polylines that make up the river network (see attached image of a good example of a polyline with this problem, these can be less than a meter in length so very hard to spot visually, unless zoomed right in).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now I've written some code that can go through the entire network and identify these "offending" polylines.&amp;nbsp; I use the ITopologicalOperator and ask if it IsSimple, a &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;False&lt;/SPAN&gt;&lt;SPAN&gt; tells me that the polyline has a self-intersection.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So I have a programmatic way of find these on mass but what I am unsure is how to fix these programmatically on mass. I need to remove these loops.&amp;nbsp; As they are so small a simple deletion of a vertex will resolve this (don't care which one) and I have been doing that manually. I want to automate this but I can't figure out how to resolve it in ArcObjects. Has anyone tried to do this and willing to share their technique?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Duncan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Oct 2012 22:16:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-remove-self-intersections-in-polylines/m-p/534024#M14407</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2012-10-03T22:16:43Z</dc:date>
    </item>
    <item>
      <title>I worked out a solution</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-remove-self-intersections-in-polylines/m-p/534025#M14408</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I managed to "dream up" a solution overnight! I wrap the polyline with a pointcollection interface and systematically remove a vertex and test if it still has a self intersection. Eventually it will remove a vertex that will stop it being self intersecting. I then go back to the original polyline and remove that specific vertex, et Voila!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't know if this is a slick solution to the problem but it works. The only limitation I can think of is that this method expects the self intersection to be generated by only one erroneous vertex, which in my case is typically the problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Duncan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Oct 2012 12:29:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-remove-self-intersections-in-polylines/m-p/534025#M14408</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2012-10-04T12:29:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove self intersections in polylines using ArcObjects?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-remove-self-intersections-in-polylines/m-p/534026#M14409</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I remember a colleague addressing this issue with the output of a stream digitizer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(using FORTRAN 77 with ArcInfo 4.03 object code, in 1988 [The more things change...]).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The "knots" could be removed by identifying the segments that changed direction&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;by nearly 180 degrees. You could speed up your solution (and make it handle multiple&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;occurances) by passing through the vertex list once, calculating the orientation of &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;segments from A to B ( atan2(By-Ay,Bx-Ax) ) and B to C ( tan2(Cy-By,Cx-Bx) ) and&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;looking for an absolute delta greater than 165-170 degrees. If you organize the loops&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;right, you'll only need to call atan2 nverts-1 times (sliding the A B C designations across &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;the length of the line). O(N) beats O(N^2) every time.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;- V&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;PS: You should also look for coincident points (Cy-By == 0 &amp;amp;&amp;amp; Cx-Bx == 0) while you're at it...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Oct 2012 14:38:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-remove-self-intersections-in-polylines/m-p/534026#M14409</guid>
      <dc:creator>VinceAngelo</dc:creator>
      <dc:date>2012-10-04T14:38:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove self intersections in polylines using ArcObjects?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-remove-self-intersections-in-polylines/m-p/534027#M14410</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;1988! Now you are just showing off! :)Your solution was what I was expecting but it blows my mind, definitely going away to have a good think about it.Many thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Oct 2012 00:12:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-remove-self-intersections-in-polylines/m-p/534027#M14410</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2012-10-05T00:12:26Z</dc:date>
    </item>
  </channel>
</rss>

