<?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 Force style to use layer renderer after changing style in ArcGIS Online in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/force-style-to-use-layer-renderer-after-changing/m-p/1257486#M66832</link>
    <description>&lt;P&gt;Hi Developers,&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Background&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I am developing a script to set up a Feature Layer Collection (point, polyline, polygon) including fields and styles. To set the styles, I add a renderer to the lines layer, which works fine (attached image, right side).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;# Lines
unique_value_renderer = {
    "renderer": {
        "type": "uniqueValue",
        "field1": "CATEGORY",
        "defaultSymbol": {
                "color": [0, 0, 255, 255],
                "width": 5,
                "type": "esriSLS",
            },
        "uniqueValueInfos": [
        {
            "value": "Good_Route",
            "symbol": {
                "color": [0, 255, 0, 255],
                "width": 5,
                "type": "esriSLS",
            },
        },
        {
            "value": "Blocked_Route",
            "symbol": {
                "color": [255, 0, 0, 255],
                "width": 5,
                "type": "esriSLS",
            },
        }
        ]
    }
}
# Set the renderer for the feature layer
fl = FeatureLayer(url=url_lines)
fl.manager.update_definition({"drawingInfo": unique_value_renderer})&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;&lt;STRONG&gt;My Question&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Using ArcGIS Online, I visualize the line feature layer in new Map Viewer, change the styles and save the layer (not a map,&amp;nbsp; but the layer). &lt;STRONG&gt;After doing so, how can I revert back to have my renderer as default style for adding the layer to maps or visualizing the data?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;What I tried&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Run above code again, no change&lt;/LI&gt;&lt;LI&gt;Tried to understand WebStyle and set it to none&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;fl.manager.update_definition({"web_style_id": None})&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Compared &lt;EM&gt;fl.properties&lt;/EM&gt; of both layers in screenshot attached (left: changed style online; right: API only), but did not find a difference, except the name.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Setup&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;ArcGIS Online&lt;/LI&gt;&lt;LI&gt;Visual Studio Code + Jupyter Notebook&lt;/LI&gt;&lt;LI&gt;ArcGIS Python API Version&amp;nbsp;2.1.0.2&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;Edit&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;See attached my Notebook that shows the different behavior. Dev4 section is a Feature Layer Collection to which I made changes in symbology online. My goal is to get Dev4 Variant A running the same way as Dev5.&lt;/P&gt;</description>
    <pubDate>Mon, 13 Feb 2023 16:43:47 GMT</pubDate>
    <dc:creator>Nico44263</dc:creator>
    <dc:date>2023-02-13T16:43:47Z</dc:date>
    <item>
      <title>Force style to use layer renderer after changing style in ArcGIS Online</title>
      <link>https://community.esri.com/t5/python-questions/force-style-to-use-layer-renderer-after-changing/m-p/1257486#M66832</link>
      <description>&lt;P&gt;Hi Developers,&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Background&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I am developing a script to set up a Feature Layer Collection (point, polyline, polygon) including fields and styles. To set the styles, I add a renderer to the lines layer, which works fine (attached image, right side).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;# Lines
unique_value_renderer = {
    "renderer": {
        "type": "uniqueValue",
        "field1": "CATEGORY",
        "defaultSymbol": {
                "color": [0, 0, 255, 255],
                "width": 5,
                "type": "esriSLS",
            },
        "uniqueValueInfos": [
        {
            "value": "Good_Route",
            "symbol": {
                "color": [0, 255, 0, 255],
                "width": 5,
                "type": "esriSLS",
            },
        },
        {
            "value": "Blocked_Route",
            "symbol": {
                "color": [255, 0, 0, 255],
                "width": 5,
                "type": "esriSLS",
            },
        }
        ]
    }
}
# Set the renderer for the feature layer
fl = FeatureLayer(url=url_lines)
fl.manager.update_definition({"drawingInfo": unique_value_renderer})&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;&lt;STRONG&gt;My Question&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Using ArcGIS Online, I visualize the line feature layer in new Map Viewer, change the styles and save the layer (not a map,&amp;nbsp; but the layer). &lt;STRONG&gt;After doing so, how can I revert back to have my renderer as default style for adding the layer to maps or visualizing the data?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;What I tried&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Run above code again, no change&lt;/LI&gt;&lt;LI&gt;Tried to understand WebStyle and set it to none&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;fl.manager.update_definition({"web_style_id": None})&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Compared &lt;EM&gt;fl.properties&lt;/EM&gt; of both layers in screenshot attached (left: changed style online; right: API only), but did not find a difference, except the name.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Setup&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;ArcGIS Online&lt;/LI&gt;&lt;LI&gt;Visual Studio Code + Jupyter Notebook&lt;/LI&gt;&lt;LI&gt;ArcGIS Python API Version&amp;nbsp;2.1.0.2&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;Edit&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;See attached my Notebook that shows the different behavior. Dev4 section is a Feature Layer Collection to which I made changes in symbology online. My goal is to get Dev4 Variant A running the same way as Dev5.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2023 16:43:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/force-style-to-use-layer-renderer-after-changing/m-p/1257486#M66832</guid>
      <dc:creator>Nico44263</dc:creator>
      <dc:date>2023-02-13T16:43:47Z</dc:date>
    </item>
    <item>
      <title>Re: Force style to use layer renderer after changing style in ArcGIS Online</title>
      <link>https://community.esri.com/t5/python-questions/force-style-to-use-layer-renderer-after-changing/m-p/1257623#M66836</link>
      <description>&lt;P&gt;I found out that manual changes of the symbology get stored in the item data behind the feature layer collection instead of into the collection or the layer. When the item data contains drawing info, the layer's drawing info will be ignored. So, I delete all item drawing info like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Delete item renderers
def delete_items_renderer(url):
    
    # delete all keys in a json object
    def delete_key(obj, key):
        if isinstance(obj, dict):
            if key in obj:
                del obj[key]
            for k in obj:
                delete_key(obj[k], key)
        elif isinstance(obj, list):
            for item in obj:
                delete_key(item, key)
        return obj
    
    flc = FeatureLayerCollection(url, gis)
    itemid = flc.properties['serviceItemId']
    item = Item(gis=gis, itemid=itemid)

    data = item.get_data()
    data = delete_key(data, "renderer")

    # Update the item properties
    item.update(data=data)

delete_items_renderer(url_feature_layer_collection)&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 13 Feb 2023 17:54:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/force-style-to-use-layer-renderer-after-changing/m-p/1257623#M66836</guid>
      <dc:creator>Nico44263</dc:creator>
      <dc:date>2023-02-13T17:54:45Z</dc:date>
    </item>
  </channel>
</rss>

