1

So the ApplySymbologyFromLayer_management() tool doesn't seem to like me, at least when I try to use it in a script. I have a Field_Boundary2.lyr file that has a "hollow" fill color and a black outline for a polygon boundary. In ArcMap, when I import this layer's symbology onto another layer, it looks like this:

hollow field boundary

But if I try to use it with arcpy.ApplySymbologyFromLayer() in a script, it gives me this:

non-hollow field boundary

Here's the code:

        df = arcpy.mapping.ListDataFrames(mxd,"dfElevation")[0]
        fc1 = arcpy.mapping.Layer(fcGrid)
        arcpy.ApplySymbologyFromLayer_management(fc1, arcpy.mapping.Layer(symbologyTemplatePath + "Elevation.lyr"))
        arcpy.mapping.AddLayer(df,fc1,"BOTTOM")
        fc2 = arcpy.mapping.Layer(fcBound)
        arcpy.ApplySymbologyFromLayer_management(fc1, arcpy.mapping.Layer(symbologyTemplatePath + "Field_Boundary2.lyr"))
        arcpy.mapping.AddLayer(df,fc2,"TOP")

From the picture above you can see that the "Elevation.lyr" symbology is being imported correctly, but not the "Field_Boundary2.lyr". Any idea why this might be happening?

  • Don't forget to save the map file: mxd.save() – Emil Brundage Jan 21 '15 at 22:47
  • Actually, it looks like your variable fc1 should be fc2 in line 6? – Emil Brundage Jan 21 '15 at 22:52
  • @EmilBrundage That's it! Thanks for catching that for me! – GISUser9 Jan 21 '15 at 23:29
  • Cool, posted it as an answer. – Emil Brundage Jan 21 '15 at 23:30
1

In line 6, change fc1 to fc2.

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

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.