Select to view content in your preferred language

Applying Symbology to Raster Layer – Excluding Color for First Class

276
0
02-28-2025 12:30 PM
Labels (1)
LaDC
by
New Contributor

I am working with a TIFF file that I add as a raster layer in ArcGIS Pro. I apply symbology from an existing layer file, where the Primary Symbology is "Classify", and the classification method is Natural Breaks (Jenks).

However, I want the first class to have no color (transparent), and I’m facing issues with different methods of applying symbology.

My Current Workflow (Python)

  1. I load the raster and add it as a layer in an ArcGIS Pro project (.aprx).
  2. I apply symbology from an existing layer file (.lyrx) using ApplySymbologyFromLayer.
  3. The issue:
    • Using MAINTAIN: The symbology applies correctly, but the legend follows the original layer file.
    • Using UPDATE: The symbology applies but does not retain my modifications, including the transparent first class.

Here is the code:

# Apply symbology from an existing layer file
if symbology_layer and os.path.isfile(symbology_layer):
arcpy.management.ApplySymbologyFromLayer(raster_layer, symbology_layer, "#", "MAINTAIN")
print(f"Applied symbology from {symbology_layer}")
else:
print(f"Warning: Symbology layer not found at {symbology_layer}. Using default colors.")

# Modify raster symbology if applicable
sym = raster_layer.symbology


What is the best way to ensure that the first class is transparent while correctly applying symbology?

Should I modify the raster_layer.symbology directly after applying the .lyrx file?

Is there a better approach using arcpy or another method in ArcGIS Pro?

Any insights or best practices would be greatly appreciated!

0 Kudos
0 Replies