Apply Symbology From Layer (Data Management)

Summary

Applies the symbology from a specified layer or layer file to the input. It can be applied to feature, raster, network analysis, TIN, and geostatistical layers.

Illustration

Apply Symbology From Layer tool illustration

Usage

  • The symbology layer must match the data type of the input layer. For example, a feature layer cannot be applied to a raster layer and vice versa.

  • The symbology can only be applied to features of the same geometry. For example, point symbology cannot be applied to a polygon layer.

  • In addition to symbology, the tool will transfer time field, 3D elevation and offset, label class, and HTML pop-up properties.

  • If the input is a feature class or dataset path, this tool will create and return a new layer with the result of the tool applied.

  • You can maintain or update the symbology ranges using the Update Symbology Ranges by Data parameter. Default symbology methods are dynamic. For example, the five-class Natural Breaks classification method from the symbology layer is applied to the input layer, and the range values are updated to reflect the Shape_Area values of the input layer. The Maintain ranges option will use the same values as the symbology layer. The Update ranges option will use the five-class Natural Breaks classification method from the input layer's Shape_Area field.

    The following methods are dynamic:

    • Unique values symbology to a feature
      • The unique values are updated to reflect the input layer's values.
      • If you do not want the unique values classification to be updated, choose the <all other values> default symbol in the symbology layer.
    • Graduated color symbology to a feature
      • The range values are updated to the values of the input layer.
      • If you do not want the range output to be updated, choose manual classification.
    • Classified value rendering to a raster
      • The range values are updated to reflect the values of the input layer.
      • If you do not want the range output to be updated, choose manual classification.

  • Setting the Update Symbology Ranges by Data parameter to Maintain ranges will copy the labels from the Symbology Layer value to the Input Layer value. If the parameter is set to Update ranges, the labels will be recomputed.

  • The symbology persists only for the duration of the layer. A layer can be retained by saving the ArcGIS AllSource session or by saving the layer to a layer file using the Save Layer To File tool.

    To see the symbology created in a script tool, the tool must include the layer as a derived output parameter. Similarly, the Updated Input Layer parameter value must be added as a derived model parameter model tool to see the symbology changes.

Parameters

LabelExplanationData Type
Input Layer

The layer to which the symbology will be applied.

Feature Layer; Raster Layer; Layer
Symbology Layer

The layer containing the symbology that will be applied to the input layer. Both .lyrx and .lyr files are supported.

Layer
Symbology Fields
(Optional)

The fields from the input layer that match the symbology fields used in the symbology layer. Symbology fields contain three properties:

  • Field type—The field type: symbology value, normalization, or other type.
  • Source field—The symbology field used by the symbology layer. Use a blank value or "#" if you do not know the source field and want to use the default.
  • Target field—The field from the input layer to use when applying the symbology.

Supported field types are as follows:

  • Value field—Primary field used to symbolize values
  • Normalization field—Field used to normalize quantitative values
  • Exclusion clause field—Field used for the symbology exclusion clause
  • Chart renderer pie size field—Field used to set the size of pie chart symbols
  • Rotation X expression field—Field used to set the rotation of symbols on the x-axis
  • Rotation Y expression field—Field used to set the rotation of symbols on the y-axis
  • Rotation Z expression field—Field used to set the rotation of symbols on the z-axis
  • Transparency expression field—Field used to set the transparency of symbols
  • Transparency normalization field—Field used to normalize transparency values
  • Size expression field—Field used to set the size or width of symbols
  • Color expression field—Field used to set the color of symbols
  • Primitive override expression field—Field used to set various properties on individual symbol layers

Value Table
Update Symbology Ranges by Data
(Optional)

Specifies whether symbology ranges will be updated.

  • DefaultSymbology ranges will be updated, except when the input layer is empty, when the symbology layer uses class breaks (for example, graduated colors or graduated symbols) and the classification method is manual or defined interval, or when the symbology layer uses unique values and the Show all other values option is checked.
  • Update rangesSymbology ranges will be updated.
  • Maintain rangesSymbology ranges will not be updated; they will be maintained.
String

Derived Output

LabelExplanationData Type
Updated Input Layer

The updated input layer.

Layer

arcpy.management.ApplySymbologyFromLayer(in_layer, in_symbology_layer, {symbology_fields}, {update_symbology})
NameExplanationData Type
in_layer

The layer to which the symbology will be applied.

Feature Layer; Raster Layer; Layer
in_symbology_layer

The layer containing the symbology that will be applied to the input layer. Both .lyrx and .lyr files are supported.

Layer
symbology_fields
[[field_type, source_field, target_field],...]
(Optional)

The fields from the input layer that match the symbology fields used in the symbology layer. Symbology fields contain three properties:

  • Field type—The field type: symbology value, normalization, or other type.
  • Source field—The symbology field used by the symbology layer. Use a blank value or "#" if you do not know the source field and want to use the default.
  • Target field—The field from the input layer to use when applying the symbology.

Supported field types are as follows:

  • VALUE_FIELD—Primary field used to symbolize values
  • NORMALIZATION_FIELD—Field used to normalize quantitative values
  • EXCLUSION_CLAUSE_FIELD—Field used for the symbology exclusion clause
  • CHART_RENDERER_PIE_SIZE_FIELD—Field used to set the size of pie chart symbols
  • ROTATION_XEXPRESSION_FIELD—Field used to set the rotation of symbols on the x-axis
  • ROTATION_YEXPRESSION_FIELD—Field used to set the rotation of symbols on the y-axis
  • ROTATION_ZEXPRESSION_FIELD—Field used to set the rotation of symbols on the z-axis
  • TRANSPARENCY_EXPRESSION_FIELD—Field used to set the transparency of symbols
  • TRANSPARENCY_NORMALIZATION_FIELD—Field used to normalize transparency values
  • SIZE_EXPRESSION_FIELD—Field used to set the size or width of symbols
  • COLOR_EXPRESSION_FIELD—Field used to set the color of symbols
  • PRIMITIVE_OVERRIDE_EXPRESSION_FIELD—Field used to set various properties on individual symbol layers

Value Table
update_symbology
(Optional)

Specifies whether symbology ranges will be updated.

  • DEFAULTSymbology ranges will be updated, except in the following situations:
  • UPDATESymbology ranges will be updated.
  • MAINTAINSymbology ranges will not be updated; they will be maintained.
String

Derived Output

NameExplanationData Type
out_layer

The updated input layer.

Layer

Code sample

ApplySymbologyFromLayer example 1 (Python window)

The following Python window script demonstrates how to use the ApplySymbologyFromLayer function in immediate mode.

import arcpy
arcpy.env.workspace = "C:/data.gdb"
arcpy.management.ApplySymbologyFromLayer("sf_points", "sf_points_water.lyrx")
ApplySymbologyFromLayer example 2 (stand-alone script)

The following shows how to use the ApplySymbologyFromLayer function in a stand-alone script.

# Import system modules
import arcpy

# Set the current workspace
arcpy.env.workspace = "C:/data.gdb"

# Set layer to apply symbology to
inputLayer = "sf_points"

# Set layer that output symbology will be based on
symbologyLayer = "water_symbols_pnt.lyrx"

# Apply the symbology from the symbology layer to the input layer
arcpy.management.ApplySymbologyFromLayer(inputLayer, symbologyLayer)
ApplySymbologyFromLayer example 3 (stand-alone script)

The following shows how to use the ApplySymbologyFromLayer function in a stand-alone script.

# Import system modules
import arcpy

# Set the current workspace
arcpy.env.workspace = "C:/data.gdb"

# Set layer to apply symbology to
inputLayer = "InlandEmpireBlocks"

# Set layer that output symbology will be based on
symbologyLayer = "USCensusBlocks.lyrx"

# The symbology layer is symbolized by population normalized by area.
# Symbolize the input by Pop2014 field normalized to Square Miles
symbologyFields = [["VALUE_FIELD", "#", "Pop2014"], 
                   ["NORMALIZATION_FIELD", "#", "SQ_MILES"]]

# Apply the symbology from the symbology layer to the input layer
arcpy.management.ApplySymbologyFromLayer(inputLayer, symbologyLayer, 
                                         symbologyFields)
ApplySymbologyFromLayer example 3 (script tool)

In a script tool, apply symbology to multiple derived output feature layers. The example tool has the following parameters:

  • Input layers
    • Data type: Feature Layer (multivalue)
    • Type: Required
    • Direction: Input
  • Symbology
    • Data type: Feature Layer
    • Type: Required
    • Direction: Input
  • Derived output
    • Data type: Feature Layer (multivalue)
    • Type: Derived
    • Direction: Output

# Import system modules
import os
import arcpy

# Get Parameters
layers = arcpy.GetParameter(0)  # Accepts Feature Layers (multivalue)
sym = arcpy.GetParameter(1)  # Accepts a Feature Layer

# Apply symbology to each input layer, store the result objects in a list
results = []
for layer in layers:

    # Derive the name of the output featureclass
    layername = arcpy.Describe(layer).baseName
    outfeature = os.path.join(arcpy.env.scratchGDB, layername + "_out")

    # Copy feature to get output. This step can be replaced by other
				# steps that produce or manipulate a featureclass.
    arcpy.management.CopyFeatures(layer, outfeature)

				# Apply symbology to the final output
    res = arcpy.management.ApplySymbologyFromLayer(outfeature, sym)

    # Append multivalue feature
    results.append(res)

# Set the symbology of the derived output parameter using the 
# list of result objects
arcpy.SetParameter(2, results)

Related topics