1

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.

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Feb 28, 2020 at 10:44
2
  • 2
    Try print type(lyr), what output? Try using MakeFeatureLayer Commented Feb 28, 2020 at 11:00
  • What's the full error message including line number? Commented Mar 1, 2020 at 0:10

1 Answer 1

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.

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
answered Feb 29, 2020 at 23:43
1

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.