<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: auto-generate a class breaks renderer for a layer in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/auto-generate-a-class-breaks-renderer-for-a-layer/m-p/1144158#M7123</link>
    <description>&lt;P&gt;I'm still flailing on this. Anyone at Esri on these forums? We have a bug.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyhow, my hack work-around starts with my previous reply, where I talk about generating a renderer for Portal/AGOL using&amp;nbsp;&lt;FONT face="courier new,courier" color="#993300"&gt;arcgis.mapping.renderer.generate_renderer()&lt;/FONT&gt;. Go read that first. That renderer is messed up, but it serves as a shell for what you want.&lt;/P&gt;&lt;P&gt;You will want to run this in a Pro or Jupyter Notebook to see the color ramp options for Portal/AGOL.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.mapping import symbol, display_colormaps
display_colormaps(symbol.ALLOWED_CMAPS)&lt;/LI-CODE&gt;&lt;P&gt;Next, I have an identical feature class in an FGDB locally and have that as a layer in an APRX. I then use ArcPy to read my APRX, find the layer (variable &lt;FONT face="courier new,courier" color="#993300"&gt;lyr&lt;/FONT&gt;) and classify it like this:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;sym = lyr.symbology
sym.renderer.classificationField = field
sym.updateRenderer('GraduatedColorsRenderer')
sym.renderer.classificationMethod = 'Quantile'
sym.renderer.breakCount = 6
sym.renderer.colorRamp = aprx.listColorRamps('Cyan to Purple')[0]
lyr.symbology = sym  # re-run with any change&lt;/LI-CODE&gt;&lt;P&gt;Then, within that&amp;nbsp;&lt;FONT face="courier new,courier" color="#993300"&gt;lyr&lt;/FONT&gt; object, look for&amp;nbsp; &lt;FONT face="courier new,courier" color="#993300"&gt;lyr.symbology.renderer.classBreaks.upperBound&lt;/FONT&gt; for the class breaks. You can also retrieve the class break labels, too. Once I have the class break from my APRX's symbology, I copy those into my broken renderer dict from &lt;FONT face="courier new,courier" color="#993300"&gt;generate_renderer()&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;As I mentioned above, I just use the color schemes from AGOL/Portal in the &lt;FONT face="courier new,courier" color="#993300"&gt;arcgis &lt;/FONT&gt;API. If you want to use the colors from Pro, here is how I get the color ramp names for the&amp;nbsp;&lt;FONT face="courier new,courier" color="#993300"&gt;colorRamp&lt;/FONT&gt;&amp;nbsp;property. I'm sure there's a better way, but this works.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dcafdg_0-1644943527332.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/33957i0AA225D32EF68AB9/image-size/large?v=v2&amp;amp;px=999" role="button" title="dcafdg_0-1644943527332.png" alt="dcafdg_0-1644943527332.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 15 Feb 2022 16:53:12 GMT</pubDate>
    <dc:creator>davedoesgis</dc:creator>
    <dc:date>2022-02-15T16:53:12Z</dc:date>
    <item>
      <title>auto-generate a class breaks renderer for a layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/auto-generate-a-class-breaks-renderer-for-a-layer/m-p/1139700#M7070</link>
      <description>&lt;P&gt;I have a hosted feature layer with a LOT of numeric fields in it. I started an AGOL webmap with the hosted feature layer. It is drawn using its default symbol - shaded by total population. What I'd like to do is clone that layer a bunch of times for the various fields.&lt;/P&gt;&lt;P&gt;I won't have time to go through and determine the best classification method and color ramp for each field's layer, but I just want to quickly stub something in to at least have a quick and dirty starting point. I'm thinking something like what I can do in AGOL by clicking on the highlighted parts of this screenshot:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dcafdg_0-1643768270623.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/32908i196D79FBA03C9753/image-size/large?v=v2&amp;amp;px=999" role="button" title="dcafdg_0-1643768270623.png" alt="dcafdg_0-1643768270623.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found the &lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.mapping.toc.html#generate-renderer" target="_self"&gt;doc for arcgis.mapping.renderer.generate_renderer()&lt;/A&gt;, which looks like what I want, but I still have some missing pieces and &lt;EM&gt;&lt;U&gt;OF COURSE&lt;/U&gt;&lt;/EM&gt; there are no samples in the documentation!!! Are there any samples available for this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, what can I use for the 'sdf_or_series' argument? I create a FeatureLayer object that works with WebMap.add_layer(). Will that work?&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.features import FeatureLayer
county_hfl_url = 'https://services.arcgis.com/[truncated]/FeatureServer/0'
county_fl = FeatureLayer(county_hfl_url)&lt;/LI-CODE&gt;&lt;P&gt;I can write some code to figure out the min/max values in each field I guess, but again, I just want to throw the data at a default renderer and run with that, so anything to keep this simple is appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Feb 2022 02:44:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/auto-generate-a-class-breaks-renderer-for-a-layer/m-p/1139700#M7070</guid>
      <dc:creator>davedoesgis</dc:creator>
      <dc:date>2022-02-02T02:44:38Z</dc:date>
    </item>
    <item>
      <title>Re: auto-generate a class breaks renderer for a layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/auto-generate-a-class-breaks-renderer-for-a-layer/m-p/1140124#M7074</link>
      <description>&lt;P&gt;I made some progress.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;I create a FeatureLayer from the hosted feature layer on AGOL&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;I create a spatially enabled data frame from a local FGDB copy of my data&lt;/LI&gt;&lt;LI&gt;I use that SDF to create a renderers for equal interval, natural breaks, quantiles, and std dev.&lt;/LI&gt;&lt;LI&gt;I published that same FeatureLayer four times, once for each different renderer.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;This code below runs just fine, assuming you already have an &lt;FONT face="courier new,courier" color="#800000"&gt;arcgis.gis.GIS&lt;/FONT&gt; object created, but the results are not what I expected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import arcgis
from arcgis.features import FeatureLayer
from arcgis.mapping import WebMap
import pandas as pd
county_hfl_url = 'https://services.arcgis.com/&amp;lt;redacted&amp;gt;/FeatureServer/0'
county_fl = FeatureLayer(county_hfl_url)
out_item = gis.content.get('&amp;lt;item_id&amp;gt;') # webmap to update 
out_wm = WebMap(out_item)
fc_path = r"D:\Path\to\fgdb.gdb\County"
sdf = pd.DataFrame.spatial.from_featureclass(fc_path, 
            where_clause="State_FIPS = '53'")
ren_q = arcgis.mapping.renderer.generate_renderer(geometry_type="polygon", 
            sdf_or_series=sdf, label="Poverty", render_type="c", 
            method="esriClassifyQuantile", field="Poverty", 
            min_value=0, class_count=6, colors="Blues")
out_wm.add_layer(county_fl, {'title': 'Quantiles 6', 'opacity': 0.5, 
            'visibility': False, 'renderer': ren_q})

ren_nb = arcgis.mapping.renderer.generate_renderer(geometry_type="polygon", 
            sdf_or_series=sdf, label="Poverty", render_type="c", 
            method="esriClassifyNaturalBreaks", field="Poverty", 
            min_value=0, class_count=6, colors="Blues")
out_wm.add_layer(county_fl, {'title': 'test natural breaks 6', 
            'opacity': 0.5, 'visibility': False, 'renderer': ren_nb})

ren_ei = arcgis.mapping.renderer.generate_renderer(geometry_type="polygon", 
            sdf_or_series=sdf, label="Poverty", render_type="c", 
            method="esriClassifyEqualInterval", field="Poverty", 
            min_value=0, class_count=6, colors="Blues")
out_wm.add_layer(county_fl, {'title': 'test equal interval 6', 
            'opacity': 0.5, 'visibility': False, 'renderer': ren_ei})

ren_sd = arcgis.mapping.renderer.generate_renderer(geometry_type="polygon", 
            sdf_or_series=sdf, label="Poverty", render_type="c", 
            method="esriClassifyStandardDeviation", 
            field="Poverty", min_value=0, class_count=6, colors="Blues")
out_wm.add_layer(county_fl, {'title': 'test standard deviation 6', 
            'opacity': 0.5, 'visibility': False, 'renderer': ren_sd})

out_wm.update()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First, let me show you the legend from the layer created via the equal interval renderer. The interval is about 33,700. Everything looks kosher till I get to the top category, which has the same min/max values, that also match the max value of the category below that. I probably could fix this with code, but the values in this data set are really skewed by a few really large counties, so equal interval is really not my preference.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dcafdg_0-1643843348876.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/32991iDD87F41776052B88/image-size/large?v=v2&amp;amp;px=999" role="button" title="dcafdg_0-1643843348876.png" alt="dcafdg_0-1643843348876.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Next, I noticed that I get the &lt;EM&gt;&lt;U&gt;exact same result&lt;/U&gt;&lt;/EM&gt;&amp;nbsp;(a broken equal interval classification) from the renderers that used other classification methods. Here are the legends for the natural breaks and quantile class breaks layers. The result is the same as the equal interval! Same for the standard deviation (not shown, but you get the idea).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dcafdg_1-1643843510648.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/32992i06FAEA841A03F7BF/image-size/large?v=v2&amp;amp;px=999" role="button" title="dcafdg_1-1643843510648.png" alt="dcafdg_1-1643843510648.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I've gotten it to where I'm successfully going through all the steps and the code runs ok, but the result is definitely not right. Any ideas?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyone from Esri on these forums? (Random attempt to tag humans:&amp;nbsp;@Anonymous User&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/518194"&gt;@myesri&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/450269"&gt;@esrirk&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/422069"&gt;@EsriTG&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/406521"&gt;@EsriSF&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/248310"&gt;@KPEsri&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/127549"&gt;@EsriEsri4&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/507304"&gt;@esriasg&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/506532"&gt;@sgresri&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/503462"&gt;@esrigrk&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/437396"&gt;@cc_esri&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/274167"&gt;@ESRI___&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/152470"&gt;@ESRIGIS&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/484385"&gt;@ELP_Esri&lt;/a&gt;&amp;nbsp;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Feb 2022 23:27:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/auto-generate-a-class-breaks-renderer-for-a-layer/m-p/1140124#M7074</guid>
      <dc:creator>davedoesgis</dc:creator>
      <dc:date>2022-02-02T23:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: auto-generate a class breaks renderer for a layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/auto-generate-a-class-breaks-renderer-for-a-layer/m-p/1144158#M7123</link>
      <description>&lt;P&gt;I'm still flailing on this. Anyone at Esri on these forums? We have a bug.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyhow, my hack work-around starts with my previous reply, where I talk about generating a renderer for Portal/AGOL using&amp;nbsp;&lt;FONT face="courier new,courier" color="#993300"&gt;arcgis.mapping.renderer.generate_renderer()&lt;/FONT&gt;. Go read that first. That renderer is messed up, but it serves as a shell for what you want.&lt;/P&gt;&lt;P&gt;You will want to run this in a Pro or Jupyter Notebook to see the color ramp options for Portal/AGOL.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.mapping import symbol, display_colormaps
display_colormaps(symbol.ALLOWED_CMAPS)&lt;/LI-CODE&gt;&lt;P&gt;Next, I have an identical feature class in an FGDB locally and have that as a layer in an APRX. I then use ArcPy to read my APRX, find the layer (variable &lt;FONT face="courier new,courier" color="#993300"&gt;lyr&lt;/FONT&gt;) and classify it like this:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;sym = lyr.symbology
sym.renderer.classificationField = field
sym.updateRenderer('GraduatedColorsRenderer')
sym.renderer.classificationMethod = 'Quantile'
sym.renderer.breakCount = 6
sym.renderer.colorRamp = aprx.listColorRamps('Cyan to Purple')[0]
lyr.symbology = sym  # re-run with any change&lt;/LI-CODE&gt;&lt;P&gt;Then, within that&amp;nbsp;&lt;FONT face="courier new,courier" color="#993300"&gt;lyr&lt;/FONT&gt; object, look for&amp;nbsp; &lt;FONT face="courier new,courier" color="#993300"&gt;lyr.symbology.renderer.classBreaks.upperBound&lt;/FONT&gt; for the class breaks. You can also retrieve the class break labels, too. Once I have the class break from my APRX's symbology, I copy those into my broken renderer dict from &lt;FONT face="courier new,courier" color="#993300"&gt;generate_renderer()&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;As I mentioned above, I just use the color schemes from AGOL/Portal in the &lt;FONT face="courier new,courier" color="#993300"&gt;arcgis &lt;/FONT&gt;API. If you want to use the colors from Pro, here is how I get the color ramp names for the&amp;nbsp;&lt;FONT face="courier new,courier" color="#993300"&gt;colorRamp&lt;/FONT&gt;&amp;nbsp;property. I'm sure there's a better way, but this works.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dcafdg_0-1644943527332.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/33957i0AA225D32EF68AB9/image-size/large?v=v2&amp;amp;px=999" role="button" title="dcafdg_0-1644943527332.png" alt="dcafdg_0-1644943527332.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Feb 2022 16:53:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/auto-generate-a-class-breaks-renderer-for-a-layer/m-p/1144158#M7123</guid>
      <dc:creator>davedoesgis</dc:creator>
      <dc:date>2022-02-15T16:53:12Z</dc:date>
    </item>
    <item>
      <title>Re: auto-generate a class breaks renderer for a layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/auto-generate-a-class-breaks-renderer-for-a-layer/m-p/1166351#M7323</link>
      <description>&lt;P&gt;&lt;FONT color="#993366"&gt;[EDIT: After marking this as the accepted solution, GeoNet creates a copy of it at the top, but I recommend reading this odyssey, in order, below. I reference several things in previous replies that won't make sense if you read it out of order.]&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This hack is basically where I landed. It's super frustrating that the ArcGIS API is broken and you need to bring in desktop software as a work-around, but that's what I resorted to.&lt;/P&gt;&lt;P&gt;I don't have time to create a working sample, but I tried to extract all the important pieces out of the project I was working on. &lt;STRONG&gt;Please understand that any code below is just bread crumbs pseudo-code and you will need to fiddle with it.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;In an ArcGIS Pro Notebook, you can get a display of all the valid colormaps and their names from AGOL/Portal:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.mapping import symbol, display_colormaps
display_colormaps(symbol.ALLOWED_CMAPS)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have an offline copy of your data in an APRX map. Use ArcPy to create a variable &lt;FONT face="courier new,courier" color="#993300"&gt;lyr&lt;/FONT&gt;&amp;nbsp;for your layer (this is ArcPy 101, lots of samples online if you don't know how to find a map layer). Then, follow the steps above with the &lt;FONT face="courier new,courier" color="#993300"&gt;sym &lt;/FONT&gt;variable to create a renderer with ArcPy and assign it back to your layer. Modify as desired if you want equal interval or more/fewer class breaks, etc. ArcPy docs on the topic &lt;A href="https://pro.arcgis.com/en/pro-app/2.8/arcpy/mapping/graduatedcolorsrenderer-class.htm" target="_self"&gt;here&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once you have the ArcPy renderer assigned to your layer, you can create a list of the upper boundaries like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy_breaks = [x.upperBound for x in lyr.symbology.renderer.classBreaks]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(Or probably just get them directly from the&amp;nbsp;&lt;FONT face="courier new,courier" color="#993300"&gt;sym &lt;/FONT&gt;variable, but that wasn't my workflow.)&lt;/P&gt;&lt;P&gt;Then, I generate a renderer with the arcgis API. It is borked, as described in the original question, but we'll fix it with the ArcPy legend. Another dependency between the local copy in Pro and the ArcGIS API is the &lt;FONT face="courier new,courier" color="#993300"&gt;sdf &lt;/FONT&gt;variable, which I set in my code sample above using ArcPy and a definition query. Since we're just creating an interim renderer, I wouldn't get too hung up on perfecting the definition query, but I think you need something for this argument.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;renderer = arcgis.mapping.renderer.generate_renderer(
    geometry_type="polygon", 
    sdf_or_series=sdf,
    label=&amp;lt;your_label&amp;gt;, 
    render_type="c", 
    method="esriClassifyNaturalBreaks", 
    field=&amp;lt;your_field&amp;gt;, 
    min_value=0, 
    class_count=6, # must match what you used in ArcPy
    colors=&amp;lt;color_scheme&amp;gt;)

# At this stage, I recommend you implement some checks that both the
# arcpy and arcgis renderers have the same number of classes. Data sets
# with small sample sizes broke my ability to create a renderer with 6
# classes, for example.

for i in range(len(renderer['classBreakInfos'])):
    cb = renderer['classBreakInfos'][i]
    cb['classMaxValue'] = arcpy_breaks[i]
    cb['label'] = arcpy_breaks[i]
    cb['description'] = arcpy_breaks[i]
    
    # Fix the default symbol, which ends up fat and light gray
    cb['symbol']['outline']['width'] = 0.75
    cb['symbol']['outline']['color'][0] = 50 # red
    cb['symbol']['outline']['color'][1] = 50 # green
    cb['symbol']['outline']['color'][2] = 50 # blue&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once you I have my renderer, here is my workflow to create a new layer in my webmap:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Get the webmap
webmap_item = gis.content.get(webmap_item_id)
webmap = WebMap(webmap_item)

# This is the layer I want to symbolize and add to the webmap
template_item = gis.content.get(&amp;lt;layer_item_id&amp;gt;)
feature_layer = [x for x in template_item.layers 
                 if x.properties.name == &amp;lt;title&amp;gt;][0]

options_dict = {'title': title_out, 'visibility':False}
options_dict['opacity'] = opacity # decimal from 0-1?
options_dict['renderer'] = renderer
webmap.add_layer(feature_layer, options_dict)
webmap.update()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lastly, while it's not exactly pertinent to this topic of legends, but fits in the theme of &lt;EM&gt;stuff broken in the ArcGIS API for Python&lt;/EM&gt;, I should mention the following:&amp;nbsp;There are several properties that could go in the &lt;FONT face="courier new,courier" color="#993300"&gt;options_dict &lt;/FONT&gt;above, but they don't seem to do anything. I have to find the webmap layer after it's created (via &lt;FONT face="courier new,courier" color="#993300"&gt;webmap.update()&lt;/FONT&gt;) and set them.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;for wm_layer in webmap.layers:
    if wm_layer.title != title_out: continue
    wm_layer['layerDefinition']['definitionExpression'
                  ] = &amp;lt;def_query&amp;gt;
    # also set wm_layer['layerDefinition']['minScale'] and such
webmap.update()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please expect that this pseudo-code won't execute without some tinkering, but it should be close. I'm trying to extract it from a giant workflow custom to my org and share back to the community, but don't have more time to test it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2022 19:22:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/auto-generate-a-class-breaks-renderer-for-a-layer/m-p/1166351#M7323</guid>
      <dc:creator>davedoesgis</dc:creator>
      <dc:date>2022-04-20T19:22:44Z</dc:date>
    </item>
  </channel>
</rss>

