<?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: Python update filter on layer in map in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/python-update-filter-on-layer-in-map/m-p/1299598#M52827</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/650811"&gt;@Scoth&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can update the filter in a layer directly in a WebMap with the following...&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS
from arcgis.mapping import WebMap

## access AGOL
agol = GIS("home")

## access the WebMap Item
wm_item = agol.content.get("WebMap_Item_ID")

## create a WebMap object
webmap = WebMap(wm_item)

## get the layer of interest
lyr = webmap.get_layer(title="Name of layer as it appears in the WebMap")
## set the filter
lyr.layerDefinition.definitionExpression = "FIELDNAME = 'attribute'" # for text field

## update the webmap
webmap.update()&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 15 Jun 2023 10:56:06 GMT</pubDate>
    <dc:creator>Clubdebambos</dc:creator>
    <dc:date>2023-06-15T10:56:06Z</dc:date>
    <item>
      <title>Python update filter on layer in map</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/python-update-filter-on-layer-in-map/m-p/1299483#M52820</link>
      <description>&lt;P&gt;I'm trying to use the arcgis api for Python to update the filter on a layer in a WebMap.&amp;nbsp; The api reference says there should be a function called "update_layer", but I don't see it on the WebMap object or the layer. Is it out of date or am I missing something?&lt;/P&gt;&lt;P&gt;Either way, I have the layer properties saved in a dictionary, I just need to know how to update the layer now. I know how I would update the Feature Layer itself. But I need to update the layer in the map only.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also the example given in the reference for how to use this nonexistent function doesn't make sense to me. Seems like there are some typos in this section maybe.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Scoth_0-1686783042420.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/73285i5E254283BE37D369/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Scoth_0-1686783042420.png" alt="Scoth_0-1686783042420.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2023 22:50:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/python-update-filter-on-layer-in-map/m-p/1299483#M52820</guid>
      <dc:creator>Scoth</dc:creator>
      <dc:date>2023-06-14T22:50:46Z</dc:date>
    </item>
    <item>
      <title>Re: Python update filter on layer in map</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/python-update-filter-on-layer-in-map/m-p/1299495#M52821</link>
      <description>&lt;P&gt;Nevermind, I realized I need to use get_data() on the map Item object, not the WebMap object. Then adjust the JSON for the layer&amp;nbsp;&lt;EM&gt;within the whole map definition.&amp;nbsp;&lt;/EM&gt;Then I can update the map. Still confused about the "update_layer" function, but whatever.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2023 23:04:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/python-update-filter-on-layer-in-map/m-p/1299495#M52821</guid>
      <dc:creator>Scoth</dc:creator>
      <dc:date>2023-06-14T23:04:08Z</dc:date>
    </item>
    <item>
      <title>Re: Python update filter on layer in map</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/python-update-filter-on-layer-in-map/m-p/1299598#M52827</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/650811"&gt;@Scoth&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can update the filter in a layer directly in a WebMap with the following...&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS
from arcgis.mapping import WebMap

## access AGOL
agol = GIS("home")

## access the WebMap Item
wm_item = agol.content.get("WebMap_Item_ID")

## create a WebMap object
webmap = WebMap(wm_item)

## get the layer of interest
lyr = webmap.get_layer(title="Name of layer as it appears in the WebMap")
## set the filter
lyr.layerDefinition.definitionExpression = "FIELDNAME = 'attribute'" # for text field

## update the webmap
webmap.update()&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 15 Jun 2023 10:56:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/python-update-filter-on-layer-in-map/m-p/1299598#M52827</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2023-06-15T10:56:06Z</dc:date>
    </item>
    <item>
      <title>Re: Python update filter on layer in map</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/python-update-filter-on-layer-in-map/m-p/1299602#M52828</link>
      <description>&lt;P&gt;It is more than likely that your version of the arcgis python module is an older version that does not have the update_layer function. When I check for it in version 2.0 it is not there, but it is available in version 2.1.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 11:12:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/python-update-filter-on-layer-in-map/m-p/1299602#M52828</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2023-06-15T11:12:58Z</dc:date>
    </item>
    <item>
      <title>Re: Python update filter on layer in map</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/python-update-filter-on-layer-in-map/m-p/1299763#M52852</link>
      <description>&lt;P&gt;Ahh cool. I guess I was kinda looking for a way to update all of the layer properties to match the layer in another map. But your answer works best for my specific question.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 15:26:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/python-update-filter-on-layer-in-map/m-p/1299763#M52852</guid>
      <dc:creator>Scoth</dc:creator>
      <dc:date>2023-06-15T15:26:08Z</dc:date>
    </item>
  </channel>
</rss>

