I am trying to split a feature layer by rows. I've previously some time ago been able to use the below script, however now when I use it, it returns:
Python ERROR 000840: The value is not a Feature Layer
import arcpy
outputNum = 5000000
outputFCName = "Flows"
def listSplit(myList, n):
for i in xrange(0, len(myList), n):
yield myList[i:i + n]
arcpy.env.workspace = r"C:\...\Database.gdb" #The dots are replaced with a proper path
lyr = arcpy.mapping.Layer("Layername")
arcpy.SelectLayerByAttribute_management(lyr, "CLEAR_SELECTION")
fList = list()
with arcpy.da.SearchCursor(lyr, "OID@") as cursor:
for row in cursor:
fList.append(row[0])
listGroup = listSplit(fList, outputNum)
for x in listGroup:
lyr.setSelectionSet("NEW", x)
arcpy.CopyFeatures_management(lyr, arcpy.CreateUniqueName(outputFCName))
The reason for splitting is that I have a dataset with 24.000.000 rows, which I would prefer in smaller parts.
1 Answer 1
The culprit would be lyr = arcpy.mapping.Layer("Layername")
which returns a Result object not a Layer.
You can try lyr = arcpy.mapping.Layer("Layername")[0]
or MakeFeatureLayer
as suggested.
-
Related Q&A (mostly about ArcGIS Pro but with arcpy.mapping in an answer) is at gis.stackexchange.com/questions/279298/…2020年03月01日 00:07:39 +00:00Commented Mar 1, 2020 at 0:07
Explore related questions
See similar questions with these tags.
print type(lyr)
, what output? Try using MakeFeatureLayer