Get style of the layer using Arcpy

2012
5
Jump to solution
01-18-2021 06:44 PM
PhongTrần
New Contributor II

Hello,

I am trying to extract the style from the selected layer using Arcpy; but, it seems like there are no properties like color, size, font, etc,...

I run this code on the Python console in ArcMap:

 

mxd = arcpy.mapping.MapDocument("CURRENT")
layers = arcpy.mapping.ListLayers(mxd)

exampleLayer = layers[0] # This is Feature layer
# I want to get properties like color, size,... from the layer
# But it is not supported

 

 

I am hoping someone can help me out! 

Many thank!

0 Kudos
2 Solutions

Accepted Solutions
DanPatterson
MVP Esteemed Contributor
0 Kudos
PhongTrần
New Contributor II

Thanks for your help, it looks like I have to use arcpy.mp (Python 3) instead of arcpy.mapping (Python 2) to read these properties like color, size, or font.

It means I have to use ArcGIS Pro instead of ArcGIS Desktop because of this 

View solution in original post

5 Replies
jcarlson
MVP Esteemed Contributor

Refer to the arcpy documentation for the Layer class. You'll see that by calling various properties, like exampleLayer.symbology and exampleLayer.symbologyType, you can access the layer's properties you're looking for.

- Josh Carlson
Kendall County GIS
0 Kudos
PhongTrần
New Contributor II

Thanks for your quick response, but I have tried it before.

In my case, the exampleLayer.symbology is UniqueValuesSymbology . It has properties like description, labels, value, and the value field. But what I want is properties like color, size, font,...

0 Kudos
DanPatterson
MVP Esteemed Contributor

It won't be easy if at all.... here is the path to follow in the help

UniqueValueRenderer—ArcGIS Pro | Documentation

Item—ArcGIS Pro | Documentation

Symbol—ArcGIS Pro | Documentation


... sort of retired...
0 Kudos
PhongTrần
New Contributor II

Thanks for your help, it looks like I have to use arcpy.mp (Python 3) instead of arcpy.mapping (Python 2) to read these properties like color, size, or font.

It means I have to use ArcGIS Pro instead of ArcGIS Desktop because of this 

DanPatterson
MVP Esteemed Contributor

Thats right... CIM has only been recently introduced and not backported to ArcMap.

Time to move on, python 2.7 is done in any event and ArcMap will be terminal soon 😉


... sort of retired...