Trying to get implement an ArcMap (arcpy.mapping) to ArcGIS Pro 2.7
Here's what I have in ArcMap:
fringe_shades = os.path.join(os.path.dirname(__file__),
"lyr", "Fringe{}.lyr".format(cycles))
outlyr = arcpy.mapping.Layer(fringe_shades)
pth = os.path.dirname(rast.catalogPath)
outlyr.replaceDataSource(pth, "NONE", os.path.basename(rast.catalogPath))
outlyr.symbology.excludedValues = ex_str
outlyr.symbology.reclassify()
outlyr.name = results
# add to map
mxd = arcpy.mapping.MapDocument("CURRENT")
arcpy.mapping.AddLayer(mxd.activeDataFrame, outlyr)
arcpy.RefreshActiveView()
I can't see a way to apply an exclusion and reclassify in arcpy.mp. Here's what I have so far. I don't seem to be able to add my layer to map like I did in ArcMap as I m.addLayer doesn't seem to let me add a geoprocessing layer object to my map. So I'm adding it using the GP environment.
outlyr = arcpy.MakeRasterLayer_management(rast.catalogPath, results)
fringe_shades = os.path.join(os.path.dirname(__file__),
"lyrx", "Fringe{}.lyrx".format(cycles))
outlyr = arcpy.ApplySymbologyFromLayer_management(outlyr, fringe_shades, None, "UPDATE")
parameters[5].value = outlyr
arcpy.SetParameterAsText(5, outlyr)
It seems like I should be able to use the arcpy.mp.Layerfile() class to access a Layer object, but I don't seem to have anything like the .reclassify() method.
The ApplySymbologyFromLayer tool works with a geoprocessing layer object, applying new data ranges, but then I can't exclusions and reclassify. I had to write a separate tool to apply exclusions after I added the raster layer tot he map using CIM access -- but I can't reclassify, just turn the pixels off by setting the exclusion values:
# use CIM to set exclusion ranges
p = arcpy.mp.ArcGISProject("CURRENT")
m = p.activeMap
ly = m.listLayers(parameters[0].valueAsText)[0]
lyc = ly.getDefinition('V2')
lyc.colorizer.exclusionRanges = [-.0001, .0001]
ly.setDefinition(lyc)
This works for me, but wish I could figure out how to do it in the main tool.
Solved! Go to Solution.
Good Great news, the ArcGIS Pro dev team is working on this. Thank you @JeffBarrette
Esri Case #02746274 - arcpy.mapping symbology.excludedValues issue
Good Great news, the ArcGIS Pro dev team is working on this. Thank you @JeffBarrette
Esri Case #02746274 - arcpy.mapping symbology.excludedValues issue