Tuesday, 11 June 2019

arcgis desktop - Split feature class based on number of records arcpy


I am looking for a way to split a feature class into multiple feature classes based on the number of records, probably using python. E.g first 100, next 100, etc. I have so far only seen options to split by attributes.



Answer



As @klewis mentioned you could use the Split By Attribute feature:


Esri provides the following sample code that you could use as mentioned:


# Name: SplitByAttributes.py  
# Description: Use the SplitByAttributes tool to split a feature class by
# unique values.


# Import required modules
import arcpy

#Set local variables
in_feature_class = 'c:/data/base.gdb/ecology'
target_workspace = 'c:/data/output.gdb'
fields = ['REGION', 'ECO_CODE']

arcpy.SplitByAttributes_analysis(in_feature_class, target_workspace, fields)

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...