<?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: Why isn't my search cursor working? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/why-isn-t-my-search-cursor-working/m-p/376368#M29729</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I second &lt;A href="https://community.esri.com/migrated-users/19932"&gt;Darren Wiens&lt;/A&gt;'&amp;nbsp;assessment. From the looks of it you want a data access update cursor. Make sure to put the line&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;cursor&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;updateRow&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;row&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;at the end of each iteration through the cursor. This will update the table with your specified values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Micah&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 30 Sep 2016 17:44:20 GMT</pubDate>
    <dc:creator>MicahBabinski</dc:creator>
    <dc:date>2016-09-30T17:44:20Z</dc:date>
    <item>
      <title>Why isn't my search cursor working?</title>
      <link>https://community.esri.com/t5/python-questions/why-isn-t-my-search-cursor-working/m-p/376366#M29727</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am working through a tutorial book and trying to create a buffer based on a search cursor. When I run the script it creates a buffer but all of the buffers are at 100 rather than what I have set as the output parameters for the buffer. any help would be great. Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Import module and environment&lt;BR /&gt;import arcpy&lt;BR /&gt;from arcpy import env&lt;BR /&gt; &lt;BR /&gt;env.environment = r"M:\NRD_Maps\Travis_Working\Training\GIS Tutorial for Python Scripting\GISTPython\Data\City of Oleander.gdb\Well_Data"&lt;BR /&gt;env.overwriteoutput = True&lt;/P&gt;&lt;P&gt;#Create variables with the name of the subject feature class&lt;BR /&gt;Lights = 'StreetLights'&lt;BR /&gt; &lt;BR /&gt;#The buffer distance is dependant on the light types&lt;BR /&gt;#Check to see the light type&lt;BR /&gt;LightCursor = arcpy.da.SearchCursor(Lights,['Type'])&lt;BR /&gt;for row in LightCursor:&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;Type = row[0]&lt;BR /&gt;#MV = 125 ft&lt;BR /&gt;#MVH = 160 ft&lt;BR /&gt;#SV = 100 ft&lt;BR /&gt;#SVH = 200 ft&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;if Type == 'MV':&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Buffer = 125&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;elif Type == 'MVH':&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Buffer = 160&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;elif Type == 'SV':&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Buffer = 100&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;else:&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Buffer = 200&lt;BR /&gt; &lt;BR /&gt;#Perform the buffer&lt;BR /&gt;arcpy.Buffer_analysis(Lights, \&lt;BR /&gt;r"M:\NRD_Maps\Travis_Working\Training\GIS Tutorial for Python Scripting\GISTPython\MyExercises\MyAnswers.gdb\EX_2_3\lightBuffer", \&lt;BR /&gt;Buffer)&lt;BR /&gt;print "New buffer created"&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Sep 2016 17:02:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-isn-t-my-search-cursor-working/m-p/376366#M29727</guid>
      <dc:creator>TravisPreston2</dc:creator>
      <dc:date>2016-09-30T17:02:45Z</dc:date>
    </item>
    <item>
      <title>Re: Why isn't my search cursor working?</title>
      <link>https://community.esri.com/t5/python-questions/why-isn-t-my-search-cursor-working/m-p/376367#M29728</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The parameters for &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/tools/analysis-toolbox/buffer.htm"&gt;Buffer &lt;/A&gt;are (input, output, buffer distance or field, ...). Since you provide a buffer distance (e.g. 100) not a field, it uses that distance. If you want to use different distances, you would need to write the distance to a field using an &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-data-access/updatecursor-class.htm"&gt;Update Cursor&lt;/A&gt;&amp;nbsp;or possibly &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/calculate-field.htm"&gt;Field Calculator&lt;/A&gt;&amp;nbsp;and use that field for the third parameter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not sure whether your Buffer is executed within the Search Cursor or outside because we can't see your indentation. If inside, Buffer will run for each feature, overwriting the file each time, leaving you with the last run. If outside, Buffer will run once, using the last value as the buffer distance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Sep 2016 17:15:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-isn-t-my-search-cursor-working/m-p/376367#M29728</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2016-09-30T17:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: Why isn't my search cursor working?</title>
      <link>https://community.esri.com/t5/python-questions/why-isn-t-my-search-cursor-working/m-p/376368#M29729</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I second &lt;A href="https://community.esri.com/migrated-users/19932"&gt;Darren Wiens&lt;/A&gt;'&amp;nbsp;assessment. From the looks of it you want a data access update cursor. Make sure to put the line&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;cursor&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;updateRow&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;row&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;at the end of each iteration through the cursor. This will update the table with your specified values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Micah&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Sep 2016 17:44:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-isn-t-my-search-cursor-working/m-p/376368#M29729</guid>
      <dc:creator>MicahBabinski</dc:creator>
      <dc:date>2016-09-30T17:44:20Z</dc:date>
    </item>
    <item>
      <title>Re: Why isn't my search cursor working?</title>
      <link>https://community.esri.com/t5/python-questions/why-isn-t-my-search-cursor-working/m-p/376369#M29730</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The "Buffer" command as you're using it doesn't work on a feature-by-feature basis.&amp;nbsp; It buffers every feature in your feature class by a fixed distance, in your case, buy 100 meters.&amp;nbsp; If I read the indentation correctly in your code, what is happening is this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For each feature in the cursor:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Get the Light type&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set the buffer distance based on light type&lt;/P&gt;&lt;P&gt;next feature&lt;/P&gt;&lt;P&gt;Run "Buffer"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The last feature you read in the cursor just happens to be type "SV", so you get an output where all the&amp;nbsp; lights are buffered by a distance of 100.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Darren points you in the right direction:&amp;nbsp; You will need to add a field to your lights layers, then fill it with the buffer distance for each light type.&amp;nbsp; Then, when you run the buffer command, give it this field instead of a fixed distance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Sep 2016 18:04:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-isn-t-my-search-cursor-working/m-p/376369#M29730</guid>
      <dc:creator>EarlSarow</dc:creator>
      <dc:date>2016-09-30T18:04:03Z</dc:date>
    </item>
  </channel>
</rss>

