HowTo: Modify the symbology of a feature or a raster programmatically using Python
【相关信息】
Article ID: 43409
Software:
ArcGIS for Desktop Advanced 10.1, 10.2, 10.2.1, 10.2.2, 10.1 SP1, 10.3
ArcGIS for Desktop Standard 10.1, 10.2, 10.2.1, 10.2.2, 10.1 SP1, 10.3
ArcGIS for Desktop Basic 10.1, 10.2, 10.2.1, 10.2.2, 10.1 SP1, 10.3
Platforms:
Windows Server 2008, Windows 7, Windows 8, Server 2008 R2
【问题描述】
The symbology property of a feature or a layer is a read-only property unless the symbology type is
Graduated Colors,
Graduated Symbols,
Raster Classified, or
Unique Values. Therefore, if the symbology type does not fall in any of these four categories, the symbology property cannot be modified directly. It can only be modified using a preexisting .lyr file or a arcpy layer object that has the desired symbology.
This article describes two ways to apply symbology from an existing layer file.
To access the symbology property of a feature or raster, a layer object must be created either using the
arcpy.mapping module or
Make Feature Layer (Data Management).
Article ID: 43409
Software:
ArcGIS for Desktop Advanced 10.1, 10.2, 10.2.1, 10.2.2, 10.1 SP1, 10.3
ArcGIS for Desktop Standard 10.1, 10.2, 10.2.1, 10.2.2, 10.1 SP1, 10.3
ArcGIS for Desktop Basic 10.1, 10.2, 10.2.1, 10.2.2, 10.1 SP1, 10.3
Platforms:
Windows Server 2008, Windows 7, Windows 8, Server 2008 R2
【问题描述】
The symbology property of a feature or a layer is a read-only property unless the symbology type is
Graduated Colors,
Graduated Symbols,
Raster Classified, or
Unique Values. Therefore, if the symbology type does not fall in any of these four categories, the symbology property cannot be modified directly. It can only be modified using a preexisting .lyr file or a arcpy layer object that has the desired symbology.
This article describes two ways to apply symbology from an existing layer file.
To access the symbology property of a feature or raster, a layer object must be created either using the
arcpy.mapping module or
Make Feature Layer (Data Management).
1 个回复
EsriSupport
赞同来自:
Method 1 Using UpdateLayer (arcpy.mapping):
import arcpy
mxd = arcpy.mapping.MapDocument(r'C:\temp\sample.mxd')
df = arcpy.mapping.ListDataFrames(mxd, "Counties")[0]
updateLayer = arcpy.mapping.ListLayers(mxd, "Rivers", df)[0]
sourceLayer = arcpy.mapping.Layer(r"C:\Project\Data\Rivers.lyr")
arcpy.mapping.UpdateLayer(df,update_layer,source_layer, symbology_only = True)
Method 2 Using Apply Symbology From Layer (Data Management):
import arcpy
mxd = arcpy.mapping.MapDocument(r'C:\temp\sample.mxd')
df = arcpy.mapping.ListDataFrames(mxd, "Counties")[0]
in_layer = arcpy.mapping.ListLayers(mxd, "Rivers", df)[0]
in_symbology_layer = arcpy.mapping.Layer(r"C:\Project\Data\Rivers.lyr")
arcpy.ApplySymbologyFromLayer_management(in_layer,in_symbology_layer)
【其它相关参考】
【创建及修改时间】
Created: 11/13/2014
Last Modified: 11/17/2014
【原文链接】
http://support.esri.com/en/kno ... 43409
要回复问题请先登录或注册