I have a layer file and I need to apply unique value categories to that layer based on the field present in attribute table of that layer

I tried using:

input = arcpy.GetParameterAsText(0)
output = arcpy.GetParameterAsText(1)
symbologyFields = {"VALUE_FIELD", "#", "symbol"}
arcpy.ApplySymbologyFromLayer_management (input, output,symbologyFields)

But this code shows an error that ApplySymbologyFromLayer_management can accept only two arguments. But I took this code from ArcGIS tool reference site http://pro.arcgis.com/en/pro-app/tool-reference/data-management/apply-symbology-from-layer.htm

What actually I need is to color my polygons using the values in the attribute table field.


I can say that apply symbology by going into properties tab and click on categories and the unique values and select the field. This I am in need of doing it with the help of code.

Can anyone help regarding this?

  • For questions that involve code we ask that you show us where you are stuck with your own code by including a code snippet in your question. There is an edit button beneath your question which will enable you to do that and a {} button that enables you to format any highlighted code nicely. – PolyGeo Mar 21 '18 at 8:56
  • 1
    Welcome to GIS SE. As a new user, please take the Tour. In addition to a more thorough code snippet, please make sure that you include the exact errors you encountered (formatted as ASCII text, so it's legible on all devices and free text searchable) – Vince Mar 21 '18 at 9:15
  • Try to changing symbologyFields = {"VALUE_FIELD", "#", "symbol"} to symbologyFields = ["VALUE_FIELD", "#", "symbol"]. There should be no curlybrackets – BERA Mar 21 '18 at 10:09

The documentation for Apply Symbology From Layer with ArcGIS Pro shows this syntax (four parameters):

ApplySymbologyFromLayer_management (in_layer, in_symbology_layer, {symbology_fields}, {update_symbology})

while the documentation for Apply Symbology From Layer with ArcMap shows this syntax (two parameters):

ApplySymbologyFromLayer_management (in_layer, in_symbology_layer)

You are working with ArcMap but referring to the documentation from ArcGIS Pro.

  • ok sir thank you for confirmation. please help us to color the polygons based on the unique values in the field – Shiva Mar 21 '18 at 10:19
  • That is a different question, and so should be asked as a new one, after correcting your code for the number of allowed arguments. – PolyGeo Mar 21 '18 at 10:29

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.