<?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: Truncated and appended data to existing feature layer and features disappeared?! in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/truncated-and-appended-data-to-existing-feature/m-p/1480705#M10084</link>
    <description>&lt;P&gt;Hm, that's so odd that they are missing but you're right. Is there a reason the shape values wouldn't be saved in the geojson? I exported it from the feature layer's page (before I messed it up and there still were shape values) Is there anything I need to do or can do to add them back?&lt;/P&gt;</description>
    <pubDate>Thu, 30 May 2024 03:38:03 GMT</pubDate>
    <dc:creator>maya_fromstein</dc:creator>
    <dc:date>2024-05-30T03:38:03Z</dc:date>
    <item>
      <title>Truncated and appended data to existing feature layer and features disappeared?!</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/truncated-and-appended-data-to-existing-feature/m-p/1480491#M10080</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a single feature layer that I've symbolized in a few different webmaps that all feed into an experience builder. In order to not lose the symbolization when updating the data, I understood (?) that I would need to truncate and append new data to the original feature layer. I tried this many times with this code and this data (but a backup) and it has repeatedly worked.&lt;/P&gt;&lt;P&gt;However!! I just tried to update the original feature layer now (the one that comprises my whole experience builder) after several test runs on backup layers, &lt;STRONG&gt;and all the data has transferred&amp;nbsp;except all the features are invisible.&lt;/STRONG&gt; It doesn't seem to help if I change the field being symbolized (which sometimes has 'refreshed' things i guess and made it work). I am really hoping I didn't just throw out a ton of time down the drain by losing all these products! Is anyone able to help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code (after I have pulled the original and new feature layer items from my portal):&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;## flc = the original layer in feature layer collection format&lt;/P&gt;&lt;P&gt;## fLyr is the original layer in feature layer (item.layers[0])&lt;/P&gt;&lt;P&gt;print("Truncating Feature Service")&lt;BR /&gt;fLyr.manager.truncate()&lt;BR /&gt;print("target layer has " + str(len(fLyr.query()))+ " clients")&lt;/P&gt;&lt;P&gt;################################&lt;BR /&gt;##### UPDATING THE SCHEMA #####&lt;BR /&gt;################################&lt;/P&gt;&lt;P&gt;# these fields are in the original data layer I want to update&lt;/P&gt;&lt;P&gt;featureServiceFields = {}&lt;BR /&gt;for field in fLyr.manager.properties.fields:&lt;BR /&gt;if field.type != "esriFieldTypeOID" and "Shape_" not in field.name and 'GlobalID' not in field.name:&lt;BR /&gt;featureServiceFields[field.name] = field.type&lt;/P&gt;&lt;P&gt;# these are the fields in the new/updated data layer&lt;/P&gt;&lt;P&gt;featureClassFields = {}&lt;BR /&gt;for field in newFC.manager.properties.fields:&lt;BR /&gt;if field.type != "esriFieldTypeOID" and "Shape_" not in field.name and 'GlobalID' not in field.name:&lt;BR /&gt;featureClassFields[field.name] = field.type&lt;/P&gt;&lt;P&gt;## identifying which fields are missing from which layers and need updating in the original layer&lt;/P&gt;&lt;P&gt;minusSchemaDiff = set(featureServiceFields) - set(featureClassFields)&lt;BR /&gt;addSchemaDiff = set(featureClassFields) - set(featureServiceFields)&lt;/P&gt;&lt;P&gt;## deleting fields&lt;BR /&gt;update_dict={}&lt;BR /&gt;if len(minusSchemaDiff) &amp;gt; 0:&lt;BR /&gt;print("Deleting removed fields")&lt;BR /&gt;for key in minusSchemaDiff:&lt;BR /&gt;print(f"\tDeleting field {key}")&lt;BR /&gt;remove_field = {&lt;BR /&gt;"name": key,&lt;BR /&gt;"type": featureServiceFields[key]&lt;BR /&gt;}&lt;BR /&gt;update_dict = {'fields': [remove_field]}&lt;BR /&gt;print(update_dict)&lt;BR /&gt;fLyr.manager.delete_from_definition(update_dict)&lt;BR /&gt;print("Finished removing fields")&lt;BR /&gt;## adding new fields&lt;BR /&gt;if len(addSchemaDiff) &amp;gt; 0:&lt;BR /&gt;print("Adding additional fields")&lt;BR /&gt;for key in addSchemaDiff:&lt;BR /&gt;print(f"\tAdding field {key}")&lt;BR /&gt;new_field = {&lt;BR /&gt;"name": key,&lt;BR /&gt;"type": featureClassFields[key]&lt;BR /&gt;}&lt;BR /&gt;update_dict = {'fields': [new_field]}&lt;BR /&gt;print(update_dict)&lt;BR /&gt;fLyr.manager.add_to_definition(update_dict)&lt;BR /&gt;print("Finished adding additional fields")&lt;/P&gt;&lt;P&gt;#####&lt;/P&gt;&lt;P&gt;####################################&lt;BR /&gt;&lt;SPAN&gt;##### APPENDING THE NEW DATA #####&lt;BR /&gt;&lt;/SPAN&gt;####################################&lt;/P&gt;&lt;P&gt;print("Adding data to the target layer now")&lt;BR /&gt;# shp_item is the shapefile format of the new data layer&lt;BR /&gt;fLyr.append(item_id=shp_item.id, upload_format="shapefile", upsert=False, field_mappings=[])&lt;BR /&gt;print("target layer now has " + str(len(fLyr.query()))+ " clients")&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;Here is what the feature layer in one of the webmaps looks now:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="maya_fromstein_0-1717010813955.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/105690iCE6CE2F0F8B6C5DB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="maya_fromstein_0-1717010813955.png" alt="maya_fromstein_0-1717010813955.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;And here is the data table in the original feature layer, showing that the data did infact change and so did the necessary field names:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="maya_fromstein_1-1717010864981.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/105691i7766C6BA2D37F399/image-size/medium?v=v2&amp;amp;px=400" role="button" title="maya_fromstein_1-1717010864981.png" alt="maya_fromstein_1-1717010864981.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help!! Much appreciated!!&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2024 19:30:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/truncated-and-appended-data-to-existing-feature/m-p/1480491#M10080</guid>
      <dc:creator>maya_fromstein</dc:creator>
      <dc:date>2024-05-29T19:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: Truncated and appended data to existing feature layer and features disappeared?!</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/truncated-and-appended-data-to-existing-feature/m-p/1480498#M10081</link>
      <description>&lt;P&gt;Did you view the layer's data? It sounds like the Shape values may be missing.&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2024 19:47:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/truncated-and-appended-data-to-existing-feature/m-p/1480498#M10081</guid>
      <dc:creator>EarlMedina</dc:creator>
      <dc:date>2024-05-29T19:47:49Z</dc:date>
    </item>
    <item>
      <title>Re: Truncated and appended data to existing feature layer and features disappeared?!</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/truncated-and-appended-data-to-existing-feature/m-p/1480705#M10084</link>
      <description>&lt;P&gt;Hm, that's so odd that they are missing but you're right. Is there a reason the shape values wouldn't be saved in the geojson? I exported it from the feature layer's page (before I messed it up and there still were shape values) Is there anything I need to do or can do to add them back?&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2024 03:38:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/truncated-and-appended-data-to-existing-feature/m-p/1480705#M10084</guid>
      <dc:creator>maya_fromstein</dc:creator>
      <dc:date>2024-05-30T03:38:03Z</dc:date>
    </item>
    <item>
      <title>Re: Truncated and appended data to existing feature layer and features disappeared?!</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/truncated-and-appended-data-to-existing-feature/m-p/1481062#M10085</link>
      <description>&lt;P&gt;Ah, so you are appending from a geojson file then? My guess is there may be an issue parsing the geometry data. Is the source data only available in geojson?&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2024 13:23:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/truncated-and-appended-data-to-existing-feature/m-p/1481062#M10085</guid>
      <dc:creator>EarlMedina</dc:creator>
      <dc:date>2024-05-30T13:23:14Z</dc:date>
    </item>
    <item>
      <title>Re: Truncated and appended data to existing feature layer and features disappeared?!</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/truncated-and-appended-data-to-existing-feature/m-p/1483680#M10104</link>
      <description>&lt;P&gt;Sorry, I was really struggling with this and worked my way in circles.&lt;/P&gt;&lt;P&gt;I wasn't updating from a geojson, I had just tried to make a copy of my target data layer with one and forgot how it was involved. Sorry about that. I was updating it from another hosted feature layer using the code I listed in the question. For whatever reason, it works perfectly for point layers but the shape columns get dropped when the data is polygons. I hacked a workaround by just adding a new visible layer on top, but I feel like the more hacks there are the more room for error as well. For now it is working at least.&lt;/P&gt;&lt;P&gt;I would really love to understand how to append polygon features and not just point features.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2024 21:22:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/truncated-and-appended-data-to-existing-feature/m-p/1483680#M10104</guid>
      <dc:creator>maya_fromstein</dc:creator>
      <dc:date>2024-06-04T21:22:46Z</dc:date>
    </item>
    <item>
      <title>Re: Truncated and appended data to existing feature layer and features disappeared?!</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/truncated-and-appended-data-to-existing-feature/m-p/1484974#M10114</link>
      <description>&lt;P&gt;I think I've understood that I can't update the geometry after truncating the whole feature layer because the polygons are so huge, my server times out before it can update each feature's geometry again.&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is also the issue if I convert to feature set and use the .edit_features() route.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Selectively truncate/clear data, without removing the geometry properties or the join fields&lt;/LI&gt;&lt;LI&gt;Update the cleared fields with new data&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Every time I think I've figured out a way of playing with the feature.attribute dictionaries, I still have to update the features, including their geometries, and time out again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jun 2024 02:28:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/truncated-and-appended-data-to-existing-feature/m-p/1484974#M10114</guid>
      <dc:creator>maya_fromstein</dc:creator>
      <dc:date>2024-06-05T02:28:18Z</dc:date>
    </item>
  </channel>
</rss>

