AnsweredAssumed Answered

Question on ´GIS Tutorial for Python Scripting´ working with cursorsl

Question asked by Evanrees on Feb 24, 2015
Latest reply on Feb 24, 2015 by Evanrees

Hello,

 

I´m trying to work my way through the ´GIS Tutorial for Python Scripting´ by David Allen. Working with cursors (Tutorial 2.3) is giving me a hard time as there seem to be a number of ways to approach this subject, but I can´t make any sense of them. What confuses me most is the numbering in the syntax. Can anybody helmp me with Exercise 2.3? The problem seems to be a non-defined cursor name, but I´m lost here. This is the code I´ve come up with so far:

 

import arcpy

from arcpy import env

env.workspace = r"C:\EsriPress\GISTPython\Data\City of Oleander.gdb"

env.overwriteOutput = True

updateFC = "StreetLights"

with arcpy.da.UpdateCursor("StreetLights",["TYPE", "Buffer"]) as cursor:

    for row in cursor:

        TYPE = row[0]

        Buffer = row[1]

        if TYPE == "MV":

            Buffer = 125

        else:

            Buffer = 200

        cursor.updateRow(row)

        print "All done updating"

        del cursor

        del row

Outcomes