arcpy.management.ApplySymbologyFromLayer(in_layer, in_symbology_layer, {symbology_fields}, {update_symbology})
|
名前
|
説明
|
データ タイプ
|
|
in_layer
|
シンボル情報を適用するレイヤー。
|
Feature Layer; Raster Layer; Layer
|
|
in_symbology_layer
|
入力レイヤーに適用されるシンボルを含むレイヤー。 .lyrx ファイルと .lyr ファイルの両方をサポートしています。
|
Layer
|
|
symbology_fields
[[field_type, source_field, target_field],...]
(オプション)
|
シンボル レイヤーで使用されているシンボル フィールドと一致する入力レイヤーのフィールド。
値テーブル列:
Type—Specifies whether the field is the symbology value field, normalization field, or other type.
VALUE_FIELD—The field will be used as the primary field to symbolize values.
NORMALIZATION_FIELD—The field will be used to normalize quantitative values.
EXCLUSION_CLAUSE_FIELD—The field will be used for the symbology exclusion clause.
CHART_RENDERER_PIE_SIZE_FIELD—The field will be used to set the size of pie chart symbols.
ROTATION_XEXPRESSION_FIELD—The field will be used to set the rotation of symbols on the x-axis.
ROTATION_YEXPRESSION_FIELD—The field will be used to set the rotation of symbols on the y-axis.
ROTATION_ZEXPRESSION_FIELD—The field will be used to set the rotation of symbols on the z-axis.
TRANSPARENCY_EXPRESSION_FIELD—The field will be used to set the transparency of symbols
TRANSPARENCY_NORMALIZATION_FIELD—The field will be used to normalize transparency values.
SIZE_EXPRESSION_FIELD—The field will be used to set the size or width of symbols.
COLOR_EXPRESSION_FIELD—The field will be used to set the color of symbols.
PRIMITIVE_OVERRIDE_EXPRESSION_FIELD—The field will be used to set various properties on individual symbol layers.
Source Field—The symbology field used in the symbology layer. Use "#" if you do not know the source field and want the system default to be used.
Target Field—The field from the input layer to use when applying the symbology.
|
Value Table
|
|
update_symbology
(オプション)
|
シンボル範囲を更新するかどうかを指定します。
|
String
|
派生した出力
|
名前
|
説明
|
データ タイプ
|
|
out_layer
|
更新された入力レイヤー。
|
Layer
|
コードのサンプル
ApplySymbologyFromLayer の例 1 (Python ウィンドウ)
次の Python ウィンドウ スクリプトは、イミディエイト モードで ApplySymbologyFromLayer 関数を使用する方法を示しています。
import arcpy
arcpy.env.workspace = "C:/data.gdb"
arcpy.management.ApplySymbologyFromLayer("sf_points", "sf_points_water.lyrx")
ApplySymbologyFromLayer の例 2 (スタンドアロン スクリプト)
次のスクリプトは、スタンドアロン スクリプトで ApplySymbologyFromLayer 関数を使用する方法を示しています。
# 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 の例 3 (スタンドアロン スクリプト)
次のスクリプトは、スタンドアロン スクリプトで ApplySymbologyFromLayer 関数を使用する方法を示しています。
# 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 の例 3 (スクリプト ツール)
スクリプト ツールでは、派生された複数の出力フィーチャ レイヤーにシンボルを適用します。 ツール例には、以下のパラメーターがあります。
入力レイヤー
シンボル表示
データ タイプ: フィーチャ レイヤー
タイプ: 必須
方向: 入力
派生した出力
# 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 feature class.
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)