Hi everyone,
I'm writing a script to plot points and then delete rows that have a value of less than 5.
I am getting the following error on the cursor lines:
Traceback (most recent call last):
File "C:\Users\30030839\Favorites\Downloads\pyfinal2.py", line 32, in <module>
cursor = arcpy.da.UpdateCursor("C:\\Users\\30030839\\Desktop\\Python\\capacity_points_layer2", ["DEM"])
RuntimeError: cannot open 'C:\Users\30030839\Desktop\Python\capacity_points_layer2'
I'm not sure why this file isn't able to open. It's not being used in any application, and its folder is not open.I added the file to ArcMap previously to make sure the shapefile worked and that the attribute table exists, and it's fine. Does anyone know why I would be getting this error?
You are misunderstanding the documentation. A "layer" and "layer file" are not synonymous. Cursors can work on datasets directly or layers/views of datasets, cursors do not work directly against layer files. If you want to use a layer file, first use Make Feature Layer (if spatial) or Make Table View to create a layer and then pass that layer to the cursor.
Hi All,
Converting my layer to a feature class and referencing that feature class in the cursor worked!
Thank you so much for all of your help.
-AO
Final completed script with no errors: