<?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: arcpy.Geometry's Intersect method - how does it work? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-geometry-s-intersect-method-how-does-it-work/m-p/299109#M23173</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;From ArcGIS Resources: "touches(second_geometry): indicates if the boundaries of the geometries intersect"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So I hoped that would be enough for intersect to return to me the point where their boundaries intersect..&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes, adding a small distance to get a result from intersect has been my solution so far. I even applied code to calculate the added distance to be as small as possible. Though, I have hoped for another solution that is more accurate.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 07 Oct 2013 13:54:31 GMT</pubDate>
    <dc:creator>JosteinSvegården</dc:creator>
    <dc:date>2013-10-07T13:54:31Z</dc:date>
    <item>
      <title>arcpy.Geometry's Intersect method - how does it work?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-geometry-s-intersect-method-how-does-it-work/m-p/299107#M23171</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm creating a script to find the coordinates of the point on a polyline that is at shortest distance from another point. Since the script can only use an ArcGIS Desktop Basic license, I can not use any of the Near-tools. So, I try to use the ArcPy Geometry class to do the calculations.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;First, I calculate the distance between the point and the polyline:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;distance = Point1.distanceTo(Polyline1)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then I try to find the actual nearest point on the polyline by creating a buffer with radius distance around the point and then do an intersect between the buffer polygon and the polyline:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;Buffer1 = Point1.buffer(distance)
IntersectPoint = Buffer1.intersect(Polyline1, 1)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The intersect does not return any geometry even though a run of &lt;/SPAN&gt;&lt;PRE class="plain" name="code"&gt;Buffer1.touches(Polyline1)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;SPAN&gt; returns a True value, indicating that the features intersect. What am I not gettig here? Any idea woud be appreciated&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Oct 2013 07:43:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-geometry-s-intersect-method-how-does-it-work/m-p/299107#M23171</guid>
      <dc:creator>JosteinSvegården</dc:creator>
      <dc:date>2013-10-07T07:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.Geometry's Intersect method - how does it work?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-geometry-s-intersect-method-how-does-it-work/m-p/299108#M23172</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jostein,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note the operator "touches". It just touches the line. There is no area overlap to intersect.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You could add a tiny extra distance to "distance" (what are your geometry coordinates?), then there will be an overlap.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Neil&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Oct 2013 13:01:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-geometry-s-intersect-method-how-does-it-work/m-p/299108#M23172</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2013-10-07T13:01:07Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.Geometry's Intersect method - how does it work?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-geometry-s-intersect-method-how-does-it-work/m-p/299109#M23173</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;From ArcGIS Resources: "touches(second_geometry): indicates if the boundaries of the geometries intersect"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So I hoped that would be enough for intersect to return to me the point where their boundaries intersect..&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes, adding a small distance to get a result from intersect has been my solution so far. I even applied code to calculate the added distance to be as small as possible. Though, I have hoped for another solution that is more accurate.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Oct 2013 13:54:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-geometry-s-intersect-method-how-does-it-work/m-p/299109#M23173</guid>
      <dc:creator>JosteinSvegården</dc:creator>
      <dc:date>2013-10-07T13:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.Geometry's Intersect method - how does it work?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-geometry-s-intersect-method-how-does-it-work/m-p/299110#M23174</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;find the coordinates of the point on a polyline that is at shortest distance from another point&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think what you would want to do is to actually get the &lt;/SPAN&gt;&lt;SPAN style="text-decoration:underline;"&gt;two&lt;/SPAN&gt;&lt;SPAN&gt; vertices along the polyline that are closest to the point (pnts b and c in the ASCII art below). Once you know the x,y pairs of these three points (corners of a triangle) you can then derive all sorts of other values, including the one you are looking for (coordinates of pnt d). The angle of adc and adb is of course 90 degrees. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; . a

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
b ._____________._____. c

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; d

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:21:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-geometry-s-intersect-method-how-does-it-work/m-p/299110#M23174</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2021-12-11T14:21:44Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.Geometry's Intersect method - how does it work?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-geometry-s-intersect-method-how-does-it-work/m-p/299111#M23175</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I'm creating a script to find the coordinates of the point on a polyline that is at shortest distance from another point. Since the script can only use an ArcGIS Desktop Basic license, I can not use any of the Near-tools. So, I try to use the ArcPy Geometry class to do the calculations.&lt;BR /&gt;&lt;BR /&gt;First, I calculate the distance between the point and the polyline:&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;distance = Point1.distanceTo(Polyline1)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;Then I try to find the actual nearest point on the polyline by creating a buffer with radius distance around the point and then do an intersect between the buffer polygon and the polyline:&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Buffer1 = Point1.buffer(distance)
IntersectPoint = Buffer1.intersect(Polyline1, 1)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;The intersect does not return any geometry even though a run of &lt;PRE class="lia-code-sample line-numbers language-none"&gt;Buffer1.touches(Polyline1)&lt;/PRE&gt; returns a True value, indicating that the features intersect. What am I not gettig here? Any idea woud be appreciated&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you only need the distance, this may be fairly straight forward. Having looked into this before (trying to move points to the closest edge segment of a polygon) it is however a bit more complicated than at face value.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But this article here &lt;/SPAN&gt;&lt;A href="http://math.ucsd.edu/~wgarner/math4c/derivations/distance/distptline.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;http://math.ucsd.edu/~wgarner/math4c/derivations/distance/distptline.htm&lt;/A&gt;&lt;SPAN&gt; is a great place to start. The basic equation is given towards the bottom:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Shortest distance from y=m*x + b to (x1, y1):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;|y1 - m*x1 - b| / root(m^2 + 1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To get the point of intersection, you then need to "draw" a line with the inverse slope, and intersect it with your original line. To do this you will need to solve for the new y-intercept, and handle two special cases:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Original slope was undefined (vertical eg X = 2): new line equation is Y = Y1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Original slope was 0 (horizontal eg Y = 2): new line equation is X = X1&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;On intersecting two lines:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://www.wikihow.com/Algebraically-Find-the-Intersection-of-Two-Lines" rel="nofollow noopener noreferrer" target="_blank"&gt;http://www.wikihow.com/Algebraically-Find-the-Intersection-of-Two-Lines&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Good luck!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:21:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-geometry-s-intersect-method-how-does-it-work/m-p/299111#M23175</guid>
      <dc:creator>DouglasSands</dc:creator>
      <dc:date>2021-12-11T14:21:47Z</dc:date>
    </item>
  </channel>
</rss>

