<?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: SelectLayerByLocation with Python Cursor in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/selectlayerbylocation-with-python-cursor/m-p/526081#M17536</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I do have an ArcInfo license. There may be more than one way to accomplish this, but my current solution is getting it done for me. I haven't looked at the Identity option.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I do appreciate the responses.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Charlton&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 02 Nov 2010 11:03:36 GMT</pubDate>
    <dc:creator>CharltonLewis</dc:creator>
    <dc:date>2010-11-02T11:03:36Z</dc:date>
    <item>
      <title>SelectLayerByLocation with Python Cursor</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/selectlayerbylocation-with-python-cursor/m-p/526076#M17531</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm really interested if anyone has done this successfully.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In Python 2.5, I need to iterate through a point feature layer (searchcursor) and select the underlying record in a polygon feature layer. This just isn't working for me. From what I've come across online, "&amp;lt;cursor&amp;gt;.shape" should be used as the select layer parameter. There could be multiple points in one polygon, so I need to identify and create a polygon for each point.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It seems straightforward, but I'm not getting any selection. If I print the value of the cursor.shape, this is what I get:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;geoprocessing describe geometry object object at 0x009DA5D8&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Heres a sample of the code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;while pointCurRow:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print pointCurRow.X_COORD&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print pointCurRow.shape&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;rows = gp.selectLayerByLocation(polyFeatLayer, "INTERSECT", pointCurRow.shape)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;row = rows.Next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print "row count = " + str(row.GetCount)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The error that results is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Traceback (most recent call last):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;File "C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py" , line 310, in RunScript&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;exec codeObject in __main__.__dict__&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;File "C:\ArcGIS\Python Scripts\test_program.py", line 61, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;row = rows.Next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;AttributeError: 'str' object has no attribute 'Next'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance for any help.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Oct 2010 16:47:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/selectlayerbylocation-with-python-cursor/m-p/526076#M17531</guid>
      <dc:creator>CharltonLewis</dc:creator>
      <dc:date>2010-10-26T16:47:37Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByLocation with Python Cursor</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/selectlayerbylocation-with-python-cursor/m-p/526077#M17532</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Charlton,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think you've got a couple of problems here. The error message indicates to me that your cursor object was not opened correctly. You don't show that part of the code, so I don't know for sure.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;According to the documentation The gp.SelectLayerByLocation requires a 'Feature Layer' datatype for the 'select features' parameter. I don't think you can use a shape from a cursor, though that would be really nice.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One option would be to set up a loop using the number of points (GetCount). &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Within the loop, create a point feature layer using a query against the point featureclass on FID or OBJECTID. The point featurelayer containing a single point could then be used in your SelectLayerByLocation. Delete the featurelayer immediately after the SelectLayerByLocation and then do whatever you want with the selected polygon(s) in the other featurelayer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;GetCount works on a featurelayer or featureclass, not on a cursor record.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It's not clear to me what your ultimate goal is, but there are other geoprocessing options that would allow you to select all polygons that intersect with the points in one operation rather than iterating through each point.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-Steve&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Nov 2010 17:01:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/selectlayerbylocation-with-python-cursor/m-p/526077#M17532</guid>
      <dc:creator>StevePeaslee</dc:creator>
      <dc:date>2010-11-01T17:01:27Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByLocation with Python Cursor</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/selectlayerbylocation-with-python-cursor/m-p/526078#M17533</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Steve, thanks much for your reply. While searching for the correct way to do this, I came across a reference to "SelectLayerByLocation" with the "JOIN_ONE_TO_MANY" option.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This does exactly what I need which is to select and save multiple polygons for multiple points that fall within a polygon feature.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Nov 2010 18:32:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/selectlayerbylocation-with-python-cursor/m-p/526078#M17533</guid>
      <dc:creator>CharltonLewis</dc:creator>
      <dc:date>2010-11-01T18:32:37Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByLocation with Python Cursor</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/selectlayerbylocation-with-python-cursor/m-p/526079#M17534</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Wouldn't the standard "Identity" tool do what you need?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Nov 2010 20:47:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/selectlayerbylocation-with-python-cursor/m-p/526079#M17534</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2010-11-01T20:47:59Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByLocation with Python Cursor</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/selectlayerbylocation-with-python-cursor/m-p/526080#M17535</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Wouldn't the standard "Identity" tool do what you need?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Identity requires ArcInfo, which unfortunatly isn't part of every installation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Fortunatly a mix of python, patience and time can be used to create tools similar to many of those requiring the ArcInfo license.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Nov 2010 06:20:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/selectlayerbylocation-with-python-cursor/m-p/526080#M17535</guid>
      <dc:creator>NiklasNorrthon</dc:creator>
      <dc:date>2010-11-02T06:20:07Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByLocation with Python Cursor</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/selectlayerbylocation-with-python-cursor/m-p/526081#M17536</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I do have an ArcInfo license. There may be more than one way to accomplish this, but my current solution is getting it done for me. I haven't looked at the Identity option.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I do appreciate the responses.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Charlton&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Nov 2010 11:03:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/selectlayerbylocation-with-python-cursor/m-p/526081#M17536</guid>
      <dc:creator>CharltonLewis</dc:creator>
      <dc:date>2010-11-02T11:03:36Z</dc:date>
    </item>
  </channel>
</rss>

