<?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: How do I overwrite an automated buffer feature layer in AGOL using jupyter? in Esri Tutorials Questions</title>
    <link>https://community.esri.com/t5/esri-tutorials-questions/how-do-i-overwrite-an-automated-buffer-feature/m-p/1020395#M384</link>
    <description>&lt;P&gt;Hi. I can't see how this directly overwrites the existing feature layer. I need it to simply update the buffer based on a field (as this field is constantly updated) without creating a new item (which is part of a map). Is this possible?&lt;/P&gt;&lt;P&gt;Sorry this is all a bit new for me but I couldn't get the code above to do this.&lt;/P&gt;&lt;P&gt;So far I generate the buffer like this:&lt;BR /&gt;from arcgis.gis import GIS&lt;BR /&gt;gis = GIS("home")&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;points_item = gis.content.get("pointsID")&lt;BR /&gt;points_item&lt;/P&gt;&lt;P&gt;from arcgis.features import use_proximity&lt;BR /&gt;#access the first layer in points_item&lt;BR /&gt;points_layer1 = points_item.layers[0]&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;points_buffer = use_proximity.create_buffers(points_layer1,&lt;BR /&gt;field='buffer',&lt;BR /&gt;units='meters',&lt;BR /&gt;output_name="Buffer_m")&lt;/P&gt;&lt;P&gt;I need this output to overwrite an existing layer buffer_m&lt;/P&gt;</description>
    <pubDate>Wed, 27 Jan 2021 06:58:46 GMT</pubDate>
    <dc:creator>CassiePorter</dc:creator>
    <dc:date>2021-01-27T06:58:46Z</dc:date>
    <item>
      <title>How do I overwrite an automated buffer feature layer in AGOL using jupyter?</title>
      <link>https://community.esri.com/t5/esri-tutorials-questions/how-do-i-overwrite-an-automated-buffer-feature/m-p/1017844#M372</link>
      <description>&lt;P&gt;I have a feature layer in AGOL that contains points, and have scripted in jupyter for buffers to be generated based on one of the fields (proximity analysis) and then output a polygon feature layer with these buffers. My problem is that I need to automate the buffers throughout the day (as data is changed for the field that the buffers are generated from). How do I get the output to overwite the existing feature layer each time the buffers are calculated?&lt;BR /&gt;&lt;BR /&gt;This is the script I have to generate the buffers. Just need it to overwrite the output name.&amp;nbsp;&lt;BR /&gt;buffer= use_proximity.create_buffers(itembuffersgeneratedfrom_layer1,&lt;BR /&gt;field='buffer_field',&lt;BR /&gt;units='meters',&lt;BR /&gt;output_name="Buffered_Points")&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jan 2021 04:47:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/esri-tutorials-questions/how-do-i-overwrite-an-automated-buffer-feature/m-p/1017844#M372</guid>
      <dc:creator>CassiePorter</dc:creator>
      <dc:date>2021-01-19T04:47:01Z</dc:date>
    </item>
    <item>
      <title>Re: How do I overwrite an automated buffer feature layer in AGOL using jupyter?</title>
      <link>https://community.esri.com/t5/esri-tutorials-questions/how-do-i-overwrite-an-automated-buffer-feature/m-p/1017856#M373</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/221331"&gt;@CassiePorter&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following script overwrites a feature layer:&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.gis import GIS
from arcgis.features import use_proximity
from arcgis.features import FeatureLayerCollection
gis = GIS("url", "username", "password")

# get the buffered feature layer
existing_Buffered_Points_item = gis.content.get("existing_Buffered_Points_item_id")
fLyr = existing_Buffered_Points_item.layers[0]
fLyr.manager.truncate()

#access the first layer in points_item
points_layer1 = points_item.layers[0]

# get the newly buffered item
points_buffer = use_proximity.create_buffers(points_layer1,
                                             field='buffer',
                                             units='meters',
                                             output_name="Buffer_m")


points_buffer_itemID = gis.content.get(points_buffer.id)

feature_layer_collection = FeatureLayerCollection.fromitem(existing_Buffered_Points_item)
feature_layer_collection.manager.overwrite(points_buffer_itemID)&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;/P&gt;&lt;P&gt;&lt;EM&gt;Please give a like if helpful and Accept as Solution if it's answered your query.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 02:53:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/esri-tutorials-questions/how-do-i-overwrite-an-automated-buffer-feature/m-p/1017856#M373</guid>
      <dc:creator>MehdiPira1</dc:creator>
      <dc:date>2021-01-28T02:53:22Z</dc:date>
    </item>
    <item>
      <title>Re: How do I overwrite an automated buffer feature layer in AGOL using jupyter?</title>
      <link>https://community.esri.com/t5/esri-tutorials-questions/how-do-i-overwrite-an-automated-buffer-feature/m-p/1020367#M382</link>
      <description>&lt;P&gt;Thanks. Do you know why I can't take this layer offline to collector or field maps?&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jan 2021 04:25:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/esri-tutorials-questions/how-do-i-overwrite-an-automated-buffer-feature/m-p/1020367#M382</guid>
      <dc:creator>CassiePorter</dc:creator>
      <dc:date>2021-01-27T04:25:30Z</dc:date>
    </item>
    <item>
      <title>Re: How do I overwrite an automated buffer feature layer in AGOL using jupyter?</title>
      <link>https://community.esri.com/t5/esri-tutorials-questions/how-do-i-overwrite-an-automated-buffer-feature/m-p/1020394#M383</link>
      <description>&lt;P&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jan 2021 06:57:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/esri-tutorials-questions/how-do-i-overwrite-an-automated-buffer-feature/m-p/1020394#M383</guid>
      <dc:creator>CraigGadaloff1</dc:creator>
      <dc:date>2021-01-27T06:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: How do I overwrite an automated buffer feature layer in AGOL using jupyter?</title>
      <link>https://community.esri.com/t5/esri-tutorials-questions/how-do-i-overwrite-an-automated-buffer-feature/m-p/1020395#M384</link>
      <description>&lt;P&gt;Hi. I can't see how this directly overwrites the existing feature layer. I need it to simply update the buffer based on a field (as this field is constantly updated) without creating a new item (which is part of a map). Is this possible?&lt;/P&gt;&lt;P&gt;Sorry this is all a bit new for me but I couldn't get the code above to do this.&lt;/P&gt;&lt;P&gt;So far I generate the buffer like this:&lt;BR /&gt;from arcgis.gis import GIS&lt;BR /&gt;gis = GIS("home")&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;points_item = gis.content.get("pointsID")&lt;BR /&gt;points_item&lt;/P&gt;&lt;P&gt;from arcgis.features import use_proximity&lt;BR /&gt;#access the first layer in points_item&lt;BR /&gt;points_layer1 = points_item.layers[0]&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;points_buffer = use_proximity.create_buffers(points_layer1,&lt;BR /&gt;field='buffer',&lt;BR /&gt;units='meters',&lt;BR /&gt;output_name="Buffer_m")&lt;/P&gt;&lt;P&gt;I need this output to overwrite an existing layer buffer_m&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jan 2021 06:58:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/esri-tutorials-questions/how-do-i-overwrite-an-automated-buffer-feature/m-p/1020395#M384</guid>
      <dc:creator>CassiePorter</dc:creator>
      <dc:date>2021-01-27T06:58:46Z</dc:date>
    </item>
    <item>
      <title>Re: How do I overwrite an automated buffer feature layer in AGOL using jupyter?</title>
      <link>https://community.esri.com/t5/esri-tutorials-questions/how-do-i-overwrite-an-automated-buffer-feature/m-p/1020846#M386</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/221331"&gt;@CassiePorter&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To make the feature layer to work offline, here are the steps:&lt;/P&gt;&lt;P&gt;1. Go to settings of the feature layer and enable sync&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MehdiPira1_1-1611796207315.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/4745i362B4F892F01CCC3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MehdiPira1_1-1611796207315.png" alt="MehdiPira1_1-1611796207315.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Create a web map from this feature layer, you can include other feature services/layers as well&lt;/P&gt;&lt;P&gt;3. Go to settings of the web map once it's created and turn on the offline mode and save it.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MehdiPira1_0-1611796172622.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/4744i6D41950CD50E344E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MehdiPira1_0-1611796172622.png" alt="MehdiPira1_0-1611796172622.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 01:11:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/esri-tutorials-questions/how-do-i-overwrite-an-automated-buffer-feature/m-p/1020846#M386</guid>
      <dc:creator>MehdiPira1</dc:creator>
      <dc:date>2021-01-28T01:11:29Z</dc:date>
    </item>
    <item>
      <title>Re: How do I overwrite an automated buffer feature layer in AGOL using jupyter?</title>
      <link>https://community.esri.com/t5/esri-tutorials-questions/how-do-i-overwrite-an-automated-buffer-feature/m-p/1020861#M387</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/221331"&gt;@CassiePorter&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I edited the code I provided above.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2021 02:55:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/esri-tutorials-questions/how-do-i-overwrite-an-automated-buffer-feature/m-p/1020861#M387</guid>
      <dc:creator>MehdiPira1</dc:creator>
      <dc:date>2021-01-28T02:55:47Z</dc:date>
    </item>
    <item>
      <title>Re: How do I overwrite an automated buffer feature layer in AGOL using jupyter?</title>
      <link>https://community.esri.com/t5/esri-tutorials-questions/how-do-i-overwrite-an-automated-buffer-feature/m-p/1022879#M388</link>
      <description>&lt;P&gt;Almost working, but got an error on overwrite.&lt;/P&gt;&lt;P&gt;The code:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;pointsFeatureLayer = gis.content.get("[pointslayerguid]")
pointsLayer = pointsFeatureLayer.layers[0]

points_buffer = use_proximity.create_buffers(pointsLayer,
                                             field='CHANGE_TOL',
                                             units='meters',
                                             output_name="Buffer_m4")

points_buffer_itemID = gis.content.get(points_buffer.id)

existingBufferFeatureLayer = gis.content.get("[bufferlayerguid]")
existingBufferLayer = existingBufferFeatureLayer.layers[0]
existingBufferLayer.manager.truncate()

feature_layer_collection = FeatureLayerCollection.fromitem(existingBufferFeatureLayer)
feature_layer_collection.manager.overwrite(points_buffer_itemID)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;{'error': 'Cannot find related data item used to publish this feature layer'}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 03:57:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/esri-tutorials-questions/how-do-i-overwrite-an-automated-buffer-feature/m-p/1022879#M388</guid>
      <dc:creator>CassiePorter</dc:creator>
      <dc:date>2021-02-03T03:57:43Z</dc:date>
    </item>
    <item>
      <title>Re: How do I overwrite an automated buffer feature layer in AGOL using jupyter?</title>
      <link>https://community.esri.com/t5/esri-tutorials-questions/how-do-i-overwrite-an-automated-buffer-feature/m-p/1024772#M397</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/221331"&gt;@CassiePorter&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I reckon the error is due to the following limitation from &lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.features.managers.html?highlight=manager%20overwrite#arcgis.features.managers.FeatureLayerCollectionManager.overwrite" target="_self"&gt;manager.overwrite&lt;/A&gt;:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;"&lt;EM&gt;3. The data file used to&amp;nbsp;&lt;/EM&gt;&lt;/SPAN&gt;&lt;EM&gt;&lt;SPAN class="highlighted"&gt;overwrite&lt;/SPAN&gt;&lt;/EM&gt;&lt;SPAN&gt;&lt;EM&gt;&amp;nbsp;should be of the same format and filename as the original that was used to publish the layer 4.&lt;/EM&gt;"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Anyway, I've created another script and tested successfully. It first truncates the existing buffered feature layer then appends the newly buffered ones. You just need to add/remove and update the attribute fields according to your feature layer fields.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS
from arcgis.features import use_proximity
from copy import deepcopy
gis = GIS("url", "username", "password")

# get the buffered feature layer
existing_Buffered_Points_item = gis.content.get("existing_Buffered_Points_item_id")
existing_Buffered_Points_layers = existing_Buffered_Points_item.layers

fLyr = existing_Buffered_Points_item.layers[0]
fset = fLyr.query()
template_hostedFeature = deepcopy(fset.features[0])
fLyr.manager.truncate()
flayer_rows = fset.sdf

#access the first layer in points_item
points_layer1 = points_item.layers[0]

# get the newly buffered item
points_buffer = use_proximity.create_buffers(points_layer1,
                                             field='buffer',
                                             units='meters',
                                             output_name="Buffer_m")


new_buffered_points_item = gis.content.get(points_buffer.id)
new_fLyr = new_buffered_points_item.layers[0]
new_fset = new_fLyr.query()
new_fset_features = new_fLyr.query().features
new_flayer_rows = new_fset.sdf

features_to_be_added = []

for index, row in new_flayer_rows.iterrows():
    new_feature = deepcopy(template_hostedFeature)
    input_geometry = new_fset_features[index].geometry
    output_geometry = geometry.project(geometries = [input_geometry],
                                       in_sr = 3857, 
                                       out_sr = 3857,
                                       gis = gis)

    # assign the updated values
    # update these based on your dataset
    new_feature.geometry = output_geometry[0]
    new_feature.attributes['OBJECTID'] = row['OBJECTID']
    new_feature.attributes['Asset_ID'] = row['Asset_ID']
    new_feature.attributes['Latitude'] = row['Latitude']
    new_feature.attributes['Longitude'] = row['Longitude']
    new_feature.attributes['Speed'] = row['Speed']
    new_feature.attributes['Date'] = row['Date']
    new_feature.attributes['BUFF_DIST'] = row['BUFF_DIST'] 
    
    features_to_be_added.append(new_feature)

existing_Buffered_Points_layers[0].edit_features(adds = features_to_be_added) 
print("The existing buffer feature layer is updated with new buffered features!")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;Mehdi&lt;/P&gt;&lt;P&gt;======================================================================&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Please give a like if helpful and Accept as Solution if it's answered your query.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 05:33:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/esri-tutorials-questions/how-do-i-overwrite-an-automated-buffer-feature/m-p/1024772#M397</guid>
      <dc:creator>MehdiPira1</dc:creator>
      <dc:date>2021-02-09T05:33:36Z</dc:date>
    </item>
    <item>
      <title>Re: How do I overwrite an automated buffer feature layer in AGOL using jupyter?</title>
      <link>https://community.esri.com/t5/esri-tutorials-questions/how-do-i-overwrite-an-automated-buffer-feature/m-p/1485183#M847</link>
      <description>&lt;P&gt;Absurdly complicated&amp;nbsp; but good answer from&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/43250"&gt;@MehdiPira1&lt;/a&gt;&amp;nbsp;!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jun 2024 10:39:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/esri-tutorials-questions/how-do-i-overwrite-an-automated-buffer-feature/m-p/1485183#M847</guid>
      <dc:creator>KenBragg</dc:creator>
      <dc:date>2024-06-05T10:39:21Z</dc:date>
    </item>
  </channel>
</rss>

