<?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: Is &amp;quot;Optimize Layer Drawing&amp;quot; Supported in API? in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/is-quot-optimize-layer-drawing-quot-supported-in/m-p/1545066#M10729</link>
    <description>&lt;P&gt;Thank you, got brought here by Google exactly for this. I am having success setting it up through&amp;nbsp;FeatureLayerCollection and layer.manager.update_definition with no problems so far.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.features import FeatureLayerCollection

flc = FeatureLayerCollection.fromitem(fs_item)
flc.layers[0].manager.update_definition({"multiScaleGeometryInfo":{"levels":[]}})&lt;/LI-CODE&gt;&lt;P&gt;I am a bit worried about inconsistency you mentioned, might need to add scheduled monitoring of published layers later.&lt;/P&gt;</description>
    <pubDate>Thu, 03 Oct 2024 04:02:34 GMT</pubDate>
    <dc:creator>miro_aus</dc:creator>
    <dc:date>2024-10-03T04:02:34Z</dc:date>
    <item>
      <title>Is "Optimize Layer Drawing" Supported in API?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/is-quot-optimize-layer-drawing-quot-supported-in/m-p/1115034#M6799</link>
      <description>&lt;P&gt;If you have a polyline or polygon hosted feature service in ArcGIS Online, there is an option under the Settings tab to&amp;nbsp;&lt;STRONG&gt;Optimize Layer Drawing&lt;/STRONG&gt;, which "increases the drawing speed of line and polygon layers with detailed geometry (e.g., many vertices) but also uses additional storage space to do so."&lt;/P&gt;&lt;P&gt;Does anyone know if there is a Python API way to run this process on feature services?&amp;nbsp; It would be a very beneficial thing to do via scripting.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Nov 2021 20:39:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/is-quot-optimize-layer-drawing-quot-supported-in/m-p/1115034#M6799</guid>
      <dc:creator>PatrickMcKinney99</dc:creator>
      <dc:date>2021-11-08T20:39:29Z</dc:date>
    </item>
    <item>
      <title>Re: Is "Optimize Layer Drawing" Supported in API?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/is-quot-optimize-layer-drawing-quot-supported-in/m-p/1120149#M6851</link>
      <description>&lt;P&gt;See example eight on this page:&amp;nbsp;&lt;A href="https://developers.arcgis.com/rest/services-reference/online/update-definition-feature-layer-.htm" target="_blank"&gt;https://developers.arcgis.com/rest/services-reference/online/update-definition-feature-layer-.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Not a full answer, but maybe will get you on the right track.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 22:02:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/is-quot-optimize-layer-drawing-quot-supported-in/m-p/1120149#M6851</guid>
      <dc:creator>ArcProOne</dc:creator>
      <dc:date>2021-11-24T22:02:57Z</dc:date>
    </item>
    <item>
      <title>Re: Is "Optimize Layer Drawing" Supported in API?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/is-quot-optimize-layer-drawing-quot-supported-in/m-p/1314765#M8908</link>
      <description>&lt;P&gt;When I have Optimize Layer Drawing active I cannot use&amp;nbsp;&lt;SPAN&gt;featureLayer.layers&lt;/SPAN&gt;&lt;SPAN&gt;[&lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;FONT face="inherit"&gt;.edit_features().&amp;nbsp;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="inherit"&gt;Having a way to &lt;/FONT&gt;programmatically&lt;FONT face="inherit"&gt;&amp;nbsp;disable the optimization &lt;/FONT&gt;temporarily&lt;FONT face="inherit"&gt;, to perform the edit_features, would be appreciated.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2023 19:35:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/is-quot-optimize-layer-drawing-quot-supported-in/m-p/1314765#M8908</guid>
      <dc:creator>DiegoMeira</dc:creator>
      <dc:date>2023-08-02T19:35:18Z</dc:date>
    </item>
    <item>
      <title>Re: Is "Optimize Layer Drawing" Supported in API?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/is-quot-optimize-layer-drawing-quot-supported-in/m-p/1419942#M9985</link>
      <description>&lt;P&gt;Old thread but thought I'd post this here in case Google brings anyone here. There is an update_definition method in the&amp;nbsp;&lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.features.managers.html#featurelayercollectionmanager" target="_self"&gt;arcgis.features.managers module&lt;/A&gt;&amp;nbsp;of the Python API, but it's been inconsistent for me. So I just make the call through the REST API. The code below enables layer optimization for the specified feature service item and layer index:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS
import requests
import json

gis = (portal_url, username, password)
item_id = '' # item id of feature service wih layer to optimize

item = gis.content.get(item_id)
layer_index = 0 # layer index in feature service for layer to optimize
update_def_url = f"{item.layers[layer_index].url}/updateDefinition".replace(r'rest/services',r'rest/admin/services')

token = gis._con.token

data = {'token':token,
        'f': 'json',
        'async': 'true',
        'updateDefinition': r'{"multiScaleGeometryInfo":{"levels":[]}}'
        }

result = requests.post(update_def_url, data=data, timeout=10)
status_url = f"{result.json().get('statusURL')}?token={token}&amp;amp;f=json"

status = None

while not status == 'Completed' and not status == 'Failed':
    status = requests.get(status_url, timeout=10).json().get('status')
    print(f"Optimization status: {status}")
    time.sleep(10)
else:
    if status == 'Completed':
        logging.info(f"Layer drawing optimized successfully for {item.title} ({item.id})")
    if status == 'Failed':
        status = requests.get(status_url, timeout=10).json()
            logging.error(f"Layer optimization failed for {item.title} ({item.id}). Status: {status.json()}")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2024 15:37:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/is-quot-optimize-layer-drawing-quot-supported-in/m-p/1419942#M9985</guid>
      <dc:creator>JRhodes</dc:creator>
      <dc:date>2024-05-07T15:37:11Z</dc:date>
    </item>
    <item>
      <title>Re: Is "Optimize Layer Drawing" Supported in API?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/is-quot-optimize-layer-drawing-quot-supported-in/m-p/1545066#M10729</link>
      <description>&lt;P&gt;Thank you, got brought here by Google exactly for this. I am having success setting it up through&amp;nbsp;FeatureLayerCollection and layer.manager.update_definition with no problems so far.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.features import FeatureLayerCollection

flc = FeatureLayerCollection.fromitem(fs_item)
flc.layers[0].manager.update_definition({"multiScaleGeometryInfo":{"levels":[]}})&lt;/LI-CODE&gt;&lt;P&gt;I am a bit worried about inconsistency you mentioned, might need to add scheduled monitoring of published layers later.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2024 04:02:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/is-quot-optimize-layer-drawing-quot-supported-in/m-p/1545066#M10729</guid>
      <dc:creator>miro_aus</dc:creator>
      <dc:date>2024-10-03T04:02:34Z</dc:date>
    </item>
  </channel>
</rss>

