Splitting large amount of features

196
0
09-20-2019 05:46 AM
AdamG
by
New Contributor II

We are publishing a geoprocessing service that will split a large amount of features in a file geodatabase.  The script uses the arcpy.defense.SplitFeatures() method, a ResourceSrf layer or a user passed in shapefile grid to split the features, so any features that fall within the grid or ResourceSrf should be split by the grid/ResourceSrf cell size.  

The issue we are facing is that some features are split, while others are not, particularly polygon features.  I am wondering if this is the best approach to splitting a large amount of features? Of course the documentation for this method is sparse at best.  Below is the code that splits the features.  Any help, information, or insight into splitting features would be greatly appreciated!

def splitter(gdb_to_split, use_alt_surface):
    gdb_exchange_folder = os.path.join(r'F:\Exchange\Rework_Temp', gdb_to_split[:-4])
    gdb_to_split = os.path.join(gdb_exchange_folder, gdb_to_split)
    gdb_to_split_tds = os.path.join(gdb_to_split, 'TDS')

    if use_alt_surface:
        gdb_resource_srf = os.path.join(gdb_exchange_folder, 'clip_shape.shp')
    else:
        gdb_resource_srf = os.path.join(gdb_to_split, 'TDS', 'ResourceSrf')

    physio_srf = os.path.join(gdb_to_split_tds, 'PhysiographySrf')

    target_features = r''
    arcpy.env.workspace = gdb_to_split_tds
    fcl = arcpy.ListFeatureClasses()
    for fclass in fcl:
        desc = arcpy.Describe(fclass)
        if desc.shapeType in ('Polygon', 'Polyline') and desc.name not in ('ResourceSrf', 'MetadataSrf', 'PhysiographySrf'):
            target_features += os.path.join(gdb_to_split_tds, fclass) + ';'
    target_features = target_features[:-1]
    

    arcpy.management.MakeFeatureLayer(gdb_resource_srf, "split_shape")
    arcpy.management.SelectLayerByLocation("split_shape", "ARE_IDENTICAL_TO", gdb_resource_srf)

    arcpy.CheckOutExtension('defense')
    arcpy.defense.SplitFeatures("split_shape", target_features)

    arcpy.Delete_management("split_shape")
0 Kudos
0 Replies