I am using ArcMap 10.4.

I am creating a Python Toolbox which runs through a series of calculations and geoprocessing tools. The Toolbox is an update of an old VBA script I ran in ArcMap 9.3, where it ran perfectly. I am updating it to run in ArcMap and Pro.

One of the functions used is intersecting a user defined polygon with a larger base layer. This base layer contains a number of fields, including a code which I use to apply a Symbology to it.

I am having an issue assigning the symbology of the larger Polygon Layer to the smaller intersected Polygon using the arcpy.ApplySymbologyFromLayer_management statement.

See an example of the base layer below: enter image description here

Running the Toolbox produces this result: enter image description here

The blue area should be the speckled the white and brown from the first picture. I thought maybe there was an issue with the attribute code I was using to assign the symbology, but when I used the "Import Symbology" under the Symbology Tab, the correct symbology was displayed.

The attribute for the symbology is a 5 digit number, it is static, so will never change.

The symbology itself is the "Unique Value" option. The code I am using is below. I have already imported arcpy and completed the intersection before this code runs.

    #File to symbolise
    Sym_In = FileN
    #Location of the lyr file to use
    Sym_Lay = r"C:\Data\Layer_v2.lyr"
    #Even if I put the field containing the code in here...nothing changes
    Sym_Field = ""
    arcpy.ApplySymbologyFromLayer_management (Sym_In , Sym_Lay)

Is there a way to get the result of the applysymbologyfromlayer to match the "Import Symbology" button in the layer properties?

  • Is the Sym_In layer symbolized by multiple attributes, or does it have a normalization field? Or is it a straightforward "Unique values" symbology? – Tom May 7 '18 at 18:17
  • @Tom straight forward unique values. Just one potential thing, I was thinking about... I have combined some of the unique values into a group. Could this be the issue? I didn't think it would because the value occurs in both datasets, so would form part of the original layer file. – Keagan Allan May 7 '18 at 19:27
  • Try changing the source of the layer instead. I've used that and it worked well. – dslamb May 7 '18 at 19:34
  • @dslamb so change the source of the intersected layer to that of the original layer? Thereby forcing the lyr symbology to be read by the intersected layer? Maybe. I'll try that. – Keagan Allan May 7 '18 at 19:36

Your Answer

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

Browse other questions tagged or ask your own question.