<?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: Find which side of a line a point is on (update) in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/find-which-side-of-a-line-a-point-is-on/m-p/474764#M37178</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have found a geoprocessing tool which returns the side :&lt;/SPAN&gt;&lt;STRONG&gt; LocateFeaturesAlongRoutes&lt;/STRONG&gt;&lt;SPAN&gt; has a postive or negative distance to indicate the left or right side of a route.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There is an optional flag to measure the side from the route direction or arc direction.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So all you have to do is build a route system with an id of each arc for the route_id and then use it to find the side.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 11 Apr 2013 07:10:50 GMT</pubDate>
    <dc:creator>KimOllivier</dc:creator>
    <dc:date>2013-04-11T07:10:50Z</dc:date>
    <item>
      <title>Find which side of a line a point is on</title>
      <link>https://community.esri.com/t5/python-questions/find-which-side-of-a-line-a-point-is-on/m-p/474756#M37170</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;How can I find which side of a line a point which isnt on the line falls. I have a road and need to see which side of the line a point is so I know which field to pull a value from between R_ESN and L_ESN. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, long time no post. The forums are looking snazzy these days!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Feb 2012 18:21:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/find-which-side-of-a-line-a-point-is-on/m-p/474756#M37170</guid>
      <dc:creator>ChrisMathers</dc:creator>
      <dc:date>2012-02-15T18:21:47Z</dc:date>
    </item>
    <item>
      <title>Re: Find which side of a line a point is on</title>
      <link>https://community.esri.com/t5/python-questions/find-which-side-of-a-line-a-point-is-on/m-p/474757#M37171</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This spatial query is a glaring gap in ArcGIS tools. The function is available in Avenue (for ArcView 3.x)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But we have Python integrated in ArcGIS and even NUMPY, so anything is possible now!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;What you have to do is use the NEAR tool with the option of adding the X,Y coordinates of the intersection with the line.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;With this intersection point and the original point you can calculate the side of the polyline using a &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://en.wikipedia.org/wiki/Cross_product" rel="nofollow" target="_blank"&gt;vector cross product&lt;/A&gt;&lt;SPAN&gt; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; You use the sign of the vector product for an indication of left/right. To generate a simplified vector of the polyline for this you will need the lastPoint of the polyline as well, which is easy enough to get from the shape properties. Having the lastPoint gives you the direction of the polyline.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To see how this works, just remember the Right Hand Rule. Hold out your right hand and spread your thumb and first two fingers perpendicular as a 3D axis. If the first finger is the polyline, the second finger the point, then the thumb pointing up (+ve) indicates the point is on the left. Turn your hand upside down so the second finger is on the right, then the thumb pointing down is now negative (-ve).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Numpy has a cross product function (to save us the headache of matrix arithmetic.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import numpy as np a = np.array([1,0,0])&amp;nbsp;&amp;nbsp; b = np.array([0,1,0])&amp;nbsp;&amp;nbsp; print np.cross(a,b)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There are a couple of &lt;/SPAN&gt;&lt;STRONG&gt;assumptions&lt;/STRONG&gt;&lt;SPAN&gt; that are critical for this vector algebra to work as expected.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="text-decoration:underline;"&gt;&lt;STRONG&gt;No multipart shapes&lt;BR /&gt;No curves&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I agree with another poster that these are evil additions to the data model that break most analysis tools.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;# LeftRight.py # Vector Cross Product # to find which side a point is of a polyline # Kim Ollivier 18 Feb 2012&amp;nbsp; import numpy as np&amp;nbsp; # Get the points from original point, Near and shape.lastPoint # eg xPnt = (1,20) intPnt = (11,9) lastPnt = (5,20) # make two 3D vectors relative to the intersection point # for a local origin at the intersection point a = np.array([xPnt[0]-intPnt[0],xPnt[1]-intPnt[1],0])&amp;nbsp;&amp;nbsp; b = np.array([lastPnt[0]-intPnt[0],lastPnt[1]-intPnt[1],0])&amp;nbsp;&amp;nbsp; c = np.cross(a,b) if c[2] &amp;gt; 0: &amp;nbsp;&amp;nbsp;&amp;nbsp; print "Side is left" else: &amp;nbsp;&amp;nbsp;&amp;nbsp; print "Side is right" print c&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;I haven't written a general tool for this, but it would be a good candidate for the Resource Centre (now deprecated). Maybe ArcScripts could be reinstated?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Competition anyone?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Feb 2012 19:29:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/find-which-side-of-a-line-a-point-is-on/m-p/474757#M37171</guid>
      <dc:creator>KimOllivier</dc:creator>
      <dc:date>2012-02-17T19:29:04Z</dc:date>
    </item>
    <item>
      <title>Re: Find which side of a line a point is on</title>
      <link>https://community.esri.com/t5/python-questions/find-which-side-of-a-line-a-point-is-on/m-p/474758#M37172</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I know this is the Python forum, but I wanted to mention that in ArcObjects that the QueryPointAndDistance method of the ICurve interface reports not only the Near Point, but also reports the distance along the line where the near point fell (as either a percentage of the line or a linear distance), the distance of offset from the line, and the side of the line the point falls on (left/right) in one operation.&amp;nbsp; It is very efficient and cool, and potentially worth the trouble of learning how to use ArcObjects within Python if you need to do a lot of linear analysis.&amp;nbsp; It works with the evil true curves also and polylines of any shape.&amp;nbsp; I have used it with Address Range validation and assignment and other Linear Referencing operations.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Feb 2012 02:27:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/find-which-side-of-a-line-a-point-is-on/m-p/474758#M37172</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2012-02-18T02:27:01Z</dc:date>
    </item>
    <item>
      <title>Re: Find which side of a line a point is on</title>
      <link>https://community.esri.com/t5/python-questions/find-which-side-of-a-line-a-point-is-on/m-p/474759#M37173</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the help Kimo. Im going to have to look into ArcObjects eventually. I dont even have time to get on here anymore much less learn a new language!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Feb 2012 17:41:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/find-which-side-of-a-line-a-point-is-on/m-p/474759#M37173</guid>
      <dc:creator>ChrisMathers</dc:creator>
      <dc:date>2012-02-20T17:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: Find which side of a line a point is on</title>
      <link>https://community.esri.com/t5/python-questions/find-which-side-of-a-line-a-point-is-on/m-p/474760#M37174</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I just want to compliment Richards answer. When a python script is run from within ArcGIS as a scripting tool it's possible to call arcobjects within the calculate field tool. I've used this approach sometimes when I wanted to access the fine grade geometry tools that ArcObjects has. The &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;QueryPointAndDistance&lt;/SPAN&gt;&lt;SPAN&gt; method on IPolyline is certainly a very useful bit of wizardry I use it regularly!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2012 08:35:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/find-which-side-of-a-line-a-point-is-on/m-p/474760#M37174</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2012-02-21T08:35:03Z</dc:date>
    </item>
    <item>
      <title>Re: Find which side of a line a point is on</title>
      <link>https://community.esri.com/t5/python-questions/find-which-side-of-a-line-a-point-is-on/m-p/474761#M37175</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I just want to compliment Richards answer. When a python script is run from within ArcGIS as a scripting tool it's possible to call arcobjects within the calculate field tool. I've used this approach sometimes when I wanted to access the fine grade geometry tools that ArcObjects has. The &lt;SPAN style="font-style:italic;"&gt;QueryPointAndDistance&lt;/SPAN&gt; method on IPolyline is certainly a very useful bit of wizardry I use it regularly!&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I did manage to get an example ArcObjects call running for 9.4 presented by Mark Cederholm, but everything has changed at 10.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Could you post a snippet to give us a hint? It would be a lot easier to use an existing function. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;What a pity that the Near tool (and many others) is only a subset of ArcObjects functionality.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Update&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mark has updated his demo for version 10 at &lt;/SPAN&gt;&lt;A href="http://www.pierssen.com/arcgis10/python.htm"&gt;http://www.pierssen.com/arcgis10/python.htm&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2012 18:22:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/find-which-side-of-a-line-a-point-is-on/m-p/474761#M37175</guid>
      <dc:creator>KimOllivier</dc:creator>
      <dc:date>2012-02-21T18:22:09Z</dc:date>
    </item>
    <item>
      <title>Re: Find which side of a line a point is on</title>
      <link>https://community.esri.com/t5/python-questions/find-which-side-of-a-line-a-point-is-on/m-p/474762#M37176</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Kimo,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It looks like I am going to have to apologies here. What I said is correct for ArcGIS 9.3 but ESRI has disappointingly removed this functionality from ArcGIS 10. I was not aware that they had killed this off until I just tried it. It's discussed &lt;/SPAN&gt;&lt;A href="http://www.ian-ko.com/free/EC10/EC10_intro.htm"&gt;here&lt;/A&gt;&lt;SPAN&gt; and it seems to be something to do with a limited version of VBA.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So unless you can figure out how to access arcobjects from python (here is a &lt;/SPAN&gt;&lt;A href="http://www.pierssen.com/arcgis/upload/misc/python_arcobjects.pdf"&gt;presentation&lt;/A&gt;&lt;SPAN&gt; that discusses this, you may have seen it already) you'll need to get to grips with ArcObjects in VB or c#.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It's a real shame that ESRI have removed this ability. From my developers point of view about the only thing ESRI have done good with the release of version 10 is the ESRIAddIn, this makes deploying buttons and toolbars developed in .Net a whole lot easier.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So sorry for getting your hopes up, thats "progress" for you...&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, 22 Feb 2012 08:26:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/find-which-side-of-a-line-a-point-is-on/m-p/474762#M37176</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2012-02-22T08:26:51Z</dc:date>
    </item>
    <item>
      <title>Re: Find which side of a line a point is on</title>
      <link>https://community.esri.com/t5/python-questions/find-which-side-of-a-line-a-point-is-on/m-p/474763#M37177</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It looks like Python wins over ArcObjects for development speed. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Which is exactly why I use it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I always mean to get back into C++ some day, but the huge 8.02 Object Model (still up on the wall) puts me off.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Since the cursor speed has been improved at 10.1 a script might be fast enough to be practical. The limitations I mentioned are only because of the shortcut to get the lastPoint for the line direction. You can eliminate these cases (if present) by exploding to a temporary layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If the next vertex (instead of the last) was retrieved then it would handle multi-parts and another tweak is possible for the unusual case of imbedded parametric curves. Or just explode them too. The answer could be put back on the original featureclass.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I will have to finish the snippet above to generalise it.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Feb 2012 06:40:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/find-which-side-of-a-line-a-point-is-on/m-p/474763#M37177</guid>
      <dc:creator>KimOllivier</dc:creator>
      <dc:date>2012-02-23T06:40:00Z</dc:date>
    </item>
    <item>
      <title>Re: Find which side of a line a point is on (update)</title>
      <link>https://community.esri.com/t5/python-questions/find-which-side-of-a-line-a-point-is-on/m-p/474764#M37178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have found a geoprocessing tool which returns the side :&lt;/SPAN&gt;&lt;STRONG&gt; LocateFeaturesAlongRoutes&lt;/STRONG&gt;&lt;SPAN&gt; has a postive or negative distance to indicate the left or right side of a route.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There is an optional flag to measure the side from the route direction or arc direction.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So all you have to do is build a route system with an id of each arc for the route_id and then use it to find the side.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Apr 2013 07:10:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/find-which-side-of-a-line-a-point-is-on/m-p/474764#M37178</guid>
      <dc:creator>KimOllivier</dc:creator>
      <dc:date>2013-04-11T07:10:50Z</dc:date>
    </item>
  </channel>
</rss>

