<?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: API for python spatial.to_featureclass - maintain attachments? in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/api-for-python-spatial-to-featureclass-maintain/m-p/1538780#M10664</link>
    <description>&lt;P&gt;The arcgis python API is a rest interface, not a relational database. Everything is atomic and restful. This means you cannot edit a single attribute in a record. You have to retrieve the whole record, edit the attributes you want and post the whole record back into the online feature layer. Because the REST interface is Stateless. It does not remember anything you have done, which record you edited etc. Its like a whole new phone call to a new support caller without a log. You have to explain the issue all over again.&lt;/P&gt;&lt;P&gt;I liken it to having string puppets digging a hole with a shovel instead of you just doing it with a shovel yourself. The puppet is clumsy and very poor at digging holes.&lt;/P&gt;&lt;P&gt;You cannot use the arcpy package to edit online data. You have to use the arcgis package.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 16 Sep 2024 05:17:02 GMT</pubDate>
    <dc:creator>KimOllivier</dc:creator>
    <dc:date>2024-09-16T05:17:02Z</dc:date>
    <item>
      <title>API for python spatial.to_featureclass - maintain attachments?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/api-for-python-spatial-to-featureclass-maintain/m-p/1400017#M9803</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I recently just updated geoprocessing python script tools to use more of the API for python for processing AGOL hosted feature layers that are also in the scripts downloaded to local file geodatabases.&lt;/P&gt;&lt;P&gt;Previously I had used the arcpy tool below which maintains attachments.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;arcpy.FeatureClassToFeatureClass_conversion&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However in the following updated snippet I do not see the photo attachments in the downloaded feature class. Is there an additional setting I need to set to maintain attachments? Or maybe there just aren't attachments in a spatially enabled dataframe to even export?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;fn_df.spatial.to_featureclass(location=out_features, sanitize_columns=False)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using ArcGIS API for Python 2.0.1 with ArcGIS Pro 3.0.3&lt;/P&gt;&lt;P&gt;Thanks,&lt;BR /&gt;Kathy&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 24 Mar 2024 00:15:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/api-for-python-spatial-to-featureclass-maintain/m-p/1400017#M9803</guid>
      <dc:creator>kmsmikrud</dc:creator>
      <dc:date>2024-03-24T00:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: API for python spatial.to_featureclass - maintain attachments?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/api-for-python-spatial-to-featureclass-maintain/m-p/1400380#M9805</link>
      <description>&lt;P&gt;Hi Kathy,&lt;/P&gt;&lt;P&gt;sdf to feature class will not maintain attachments. You can use arcpy similar to below or try other avenues listed &lt;A href="https://learn.finaldraftmapping.com/extracting-from-an-arcgis-online-feature-service-to-a-file-geodatabase/" target="_blank" rel="noopener"&gt;here&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

arcpy.env.maintainAttachments = True

## output feature class name
out_fc = "exported_layer"

## url to the feature layer
## this could also be to a table
fl_url = "https://services-eu1.arcgis.com/*******/arcgis/rest/services/FS_Name/FeatureServer/0"

## file geodatabase path
## NOTE you can use arcpy to create a geodatabase rather than having an existing
gdb = r"C:\Path\to\Documents\fgdb.gdb"

## path for saving output feature class
out_fc_path = "{0}\\{1}".format(gdb, out_fc)

## create feature class from feature layer
## you can also use FeatureClassToFeatureClass in older versions of ArcGIS Pro
## if exporting a table use arcpy.conversion.ExportTable()
arcpy.conversion.ExportFeatures(fl_url, out_fc_path)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2024 15:23:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/api-for-python-spatial-to-featureclass-maintain/m-p/1400380#M9805</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2024-03-25T15:23:00Z</dc:date>
    </item>
    <item>
      <title>Re: API for python spatial.to_featureclass - maintain attachments?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/api-for-python-spatial-to-featureclass-maintain/m-p/1400398#M9806</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/417766"&gt;@Clubdebambos&lt;/a&gt;&amp;nbsp;for the clarification on the attachments.&lt;/P&gt;&lt;P&gt;Its been an interesting and frustrating learning experience in trying to make us of the ArcGIS API for python and move away from arcpy (as suggested by Esri solution engineers) only to find out objectives can't be met with the API.&lt;/P&gt;&lt;P&gt;For instance, earlier in the scripts I updated the code from using arcpy and the UpdateCursor to use the edit_features like shown below. This works great to update attributes in the AGOL hosted feature layers, but then if you use arcpy and either the arcpy.conversion.ExportFeatures or the arcpy.FeatureClassToFeatureClass conversion, any records updated with the API are exported with blank values. When I would view the data in AGOL the data is all updated, but for some reason exporting using arcpy did not recognize those record updates. So then I was able to use the spatial.to_featureclass only to find out this won't work either because we need the attachments to download.&amp;nbsp; So apparently you can't mix and match or do you know why the arcpy exports blank records updated with the API.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;updates_key_df.append(feature)

# Perform the update
result = lyr.edit_features(updates=updates_key_df)
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Thanks again for the response.&lt;/P&gt;&lt;P&gt;Kathy&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2024 15:58:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/api-for-python-spatial-to-featureclass-maintain/m-p/1400398#M9806</guid>
      <dc:creator>kmsmikrud</dc:creator>
      <dc:date>2024-03-25T15:58:02Z</dc:date>
    </item>
    <item>
      <title>Re: API for python spatial.to_featureclass - maintain attachments?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/api-for-python-spatial-to-featureclass-maintain/m-p/1400430#M9807</link>
      <description>&lt;P&gt;The ArcGIS API for Python is still quite in its infancy if you ask me. If you find something doesn't work or have an idea I suggest you file an issue or the idea on &lt;A href="https://github.com/Esri/arcgis-python-api" target="_blank" rel="noopener"&gt;github&lt;/A&gt;. Esri are really good for getting back to you on that platform. You might dig around and find similar for ArcPy. It is strange behaviour with the blanks and one that should be reported.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2024 17:06:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/api-for-python-spatial-to-featureclass-maintain/m-p/1400430#M9807</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2024-03-25T17:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: API for python spatial.to_featureclass - maintain attachments?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/api-for-python-spatial-to-featureclass-maintain/m-p/1538780#M10664</link>
      <description>&lt;P&gt;The arcgis python API is a rest interface, not a relational database. Everything is atomic and restful. This means you cannot edit a single attribute in a record. You have to retrieve the whole record, edit the attributes you want and post the whole record back into the online feature layer. Because the REST interface is Stateless. It does not remember anything you have done, which record you edited etc. Its like a whole new phone call to a new support caller without a log. You have to explain the issue all over again.&lt;/P&gt;&lt;P&gt;I liken it to having string puppets digging a hole with a shovel instead of you just doing it with a shovel yourself. The puppet is clumsy and very poor at digging holes.&lt;/P&gt;&lt;P&gt;You cannot use the arcpy package to edit online data. You have to use the arcgis package.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2024 05:17:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/api-for-python-spatial-to-featureclass-maintain/m-p/1538780#M10664</guid>
      <dc:creator>KimOllivier</dc:creator>
      <dc:date>2024-09-16T05:17:02Z</dc:date>
    </item>
  </channel>
</rss>

