HI all - Currently I'm getting:
Runtime error
Traceback (most recent call last):
File "<string>", line 14, in <module>
AttributeError: 'module' object has no attribute 'updateCursor'
from the following code:
# Move points based up current lat/lon
#grab stuff you need
import arcpy, os#filepath
filepath = r"C:\Users\joanna.grossman\AppData\Roaming\ESRI\Desktop10.4\ArcCatalog\AGR_SecureProd__AGR_Admin.sde"#get feature class, feidds
fc = "GDB_AGR_SECURE.AGR_ADMIN.ApiariesWGS_20160927"
lat = "Latitude"
lon = "Longtitude"#create curser on fc
cursor = arcpy.da.updateCursor(fc, ["SHAPE@XY"])
row = cursor.next()#get points
pnt = arcpy.Point()while row:
x = row.getValue(lon)
y = row.getValue(lat)
xy = (x,y)
#pnt = arcpy.Point(xy)
#pnt_geometry = arcpy.PointGeometry(pnt)
print x
print xy
#print(pnt_geometry.getGeohash(6))
#row.shape = pnt
cursor.updateRow([xy])
row = cursor.next()
I'm a total Python/arcpy noob. Would really appreciate your feedback.
Solved! Go to Solution.
Capitalize the 'u'.
cursor = arcpy.da.UpdateCursor(fc, ["field"])
wow. Thanks!
I think Mitch Holley has identified the issue causing the error you posted. Here's the documentation for UpdateCursor. However, I think you will have some additional issues with how you're using the UpdateCursor. Check out the code samples in the help documentation for some guidance.
Blake is spot on. You are mixing the usage patterns of the old cursors and newer Data Access cursors. Specifically, getValue() doesn't apply with the newer Data Access cursors.
okay. I'm learning things! So the way to get a value now is to grab it from a stack of fields?
Yeah, if you're trying to update geometries based on a Lat and Long field. It would look something like this:
I don't have to create a point or anything?
Like any of this...
pnt = arcpy.Point(xy)
pnt_geometry = arcpy.PointGeometry(pnt)
?
I encourage you to read Accessing data using cursors. Mitch is using "tokens" to access the spatial object. The tokens are a form of shortcut/optimization that can be used to simplify working with geometry objects in data tables.
will do - thank you!