TransWikia.com

Adding feature class and applying symbology in ArcGIS Pro using ArcPy?

Geographic Information Systems Asked by smh on December 5, 2020

Using an ArcPy script run from a toolbox, I want to import a feature class from a geodatabase into an ArcGIS Pro 2.1.2 map and then symbolise that layer based on a lyrx file stored on disk.

Here is a simplified version:

import arcpy, os
aprx = arcpy.mp.ArcGISProject('CURRENT')
m = aprx.listMaps('*')[0]
outputWorkspace = r"C:PathToMyProject.gdb"
arcpy.env.workspace = outputWorkspace
out_fc = "fc_data"
out_fc_p = os.path.join(outputWorkspace, out_fc)
ref_lyrx = r"C:PathTosymbol_ref.lyrx"
m.addDataFromPath(out_fc_p)
out_fc_lyr = m.listLayers()[0]
arcpy.ApplySymbologyFromLayer_management(out_fc_lyr, ref_lyrx)

The script completes without error but no visible change is made to the symbology.

Is this a bug?

I’ve reviewed many similar questions but have been unable to resolve this.

I tried also first converting the fc to a layer using arcpy.MakeFeatureLayer_management().getOutput() before adding to the map with m.addLayer() and then using arcpy.ApplySymbologyFromLayer_management() but get exactly the same outcome.

One Answer

yes, that looks like a bug. Had the exact same issue https://support.esri.com/de/bugs/nimbus/QlVHLTAwMDEyMDkwNg==

Answered by Flousen on December 5, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP