3

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.

http://desktop.arcgis.com/en/arcmap/10.3/manage-data/geometric-networks/essential-geometric-networks-vocabulary.htm

Feature Type: Simple Junction

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:

  1. 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

  1. 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

  • Turns out the layers are "network elements," not geometric networks. I've updated my question. Network elements make up geometric networks. The link you reference states, "A Geometric Network returns a dataType of "GeometricNetwork,"". The dataType of network elements is 'FeatureClass' however, so it doesn't work in my case. Thanks for your help. – Pdavis327 Aug 28 '19 at 14:35
3

In order to maintain the feature class as a geometric network type when copying, that feature class would have to participate in a geometric network, so one would need to be built in the output geodatabase. I'm not sure of your end goal here, but it seems like quite a bit of work just to get some symbology applied to layer.

To answer your question about identifying geometric network type layers:

for layer in layers:
  desc = arcpy.Describe(layer)
  if hasattr(desc, 'featureType'):
    if desc.featureType in ('SimpleJunction','SimpleEdge','ComplexEdge'):
      # do something different

As to what that # do something different might be, the solution is to modify the layer that you are using to apply symbology such that it matches the featureType of the layer you are trying to apply symbology to. Because you can't simply modify this property of the layer, one way to do this is to replace the data source.

v.replaceDataSource(lyr.workspacePath, "FILEGDB_WORKSPACE", lyr.datasetName)

Now layer 'v' will have the same featureType as layer 'lyr'. Note that you may want 'v' to be a duplicate, rather than change the one within your mxd.

  • Thanks for your help. All I ended up needing was desc.featureType. – Pdavis327 Aug 28 '19 at 14:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.