AnsweredAssumed Answered

Why isn't my search cursor working?

Question asked by NPNRDGIS on Sep 30, 2016
Latest reply on Sep 30, 2016 by esarow-esristaff

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!

 

#Import module and environment
import arcpy
from arcpy import env

env.environment = r"M:\NRD_Maps\Travis_Working\Training\GIS Tutorial for Python Scripting\GISTPython\Data\City of Oleander.gdb\Well_Data"
env.overwriteoutput = True

#Create variables with the name of the subject feature class
Lights = 'StreetLights'

#The buffer distance is dependant on the light types
#Check to see the light type
LightCursor = arcpy.da.SearchCursor(Lights,['Type'])
for row in LightCursor:
   Type = row[0]
#MV = 125 ft
#MVH = 160 ft
#SV = 100 ft
#SVH = 200 ft
   if Type == 'MV':
      Buffer = 125
   elif Type == 'MVH':
      Buffer = 160
   elif Type == 'SV':
      Buffer = 100
   else:
      Buffer = 200

#Perform the buffer
arcpy.Buffer_analysis(Lights, \
r"M:\NRD_Maps\Travis_Working\Training\GIS Tutorial for Python Scripting\GISTPython\MyExercises\MyAnswers.gdb\EX_2_3\lightBuffer", \
Buffer)
print "New buffer created"

Outcomes