I need to create new feature classes from all layers in an .mxd, and also create a new .lyr file for each of the newly created feature classes that retains the symbology of the original map layer. The script works for most files, but fails on layers that have network element feature types- Junctions and Edges.
It creates the new feature class on these layer types, but fails on creating the layer file. This is because the original map layer is of feature type: "simple junction" for instance, and the newly created feature class doesn't retain that type. It is now feature type: "simple." When I try to apply symbology I then get the error- 000968: The symbol layer does not match the input layer.
I either need to:
- Find a way to maintain the feature type if it's a network element layer. I've tried using the FeatureClassToFeatureClass tool, and CopyFeatures tool, and neither has worked.
or
- Identify the layers that have a network element feature type so that I can deal with them in another way. I have tried using both the describe and layer properties, and haven't found a way to identify these layers.
Relevant portion of code causing the error:
if not arcpy.Exists(fc_outname):
arcpy.AddMessage("Creating feature class: {}".format(fc_outname))
out_path, out_name = os.path.split(fc_outname)
arcpy.FeatureClassToFeatureClass(clipped, out_path, out_name)
#Create .lyr file
if not arcpy.Exists(lyr_outname):
arcpy.AddMessage("Creating .lyr file: {}\n".format(lyr_outname))
lyr = arcpy.MakeFeatureLayer_management(fc_outname, lyr_disp)
arcpy.ApplySymbologyFromLayer_management(lyr, v)
arcpy.SaveToLayerFile_management(lyr, lyr_outname)
Using ArcGIS 10.5
