<?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: Exporting points from S123 feature service with arcpy in ArcGIS Survey123 Questions</title>
    <link>https://community.esri.com/t5/arcgis-survey123-questions/exporting-points-from-s123-feature-service-with/m-p/1391534#M55283</link>
    <description>&lt;P&gt;I see you're using the arcpy module to call CopyFeatures, but my experience is that you can't access hosted layers with the arcpy module.&amp;nbsp; It looks like you're using the arcgis module to set up you FeatureLayer, so I think you're well on the way to success.&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;There's a section in the ArcGIS for Python API that talks about how to call geoprocessing tools.&amp;nbsp; I think your answer may be there.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/python/guide/an-introduction-to-geoprocessing/" target="_blank"&gt;https://developers.arcgis.com/python/guide/an-introduction-to-geoprocessing/&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 05 Mar 2024 22:53:42 GMT</pubDate>
    <dc:creator>TylerGraham2</dc:creator>
    <dc:date>2024-03-05T22:53:42Z</dc:date>
    <item>
      <title>Exporting points from S123 feature service with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/exporting-points-from-s123-feature-service-with/m-p/1391124#M55273</link>
      <description>&lt;P&gt;I have a S123 set up with the web builder to collect points. By default, S123 creates an attachment layer to collect photos and files, but we do not need that functionality.&lt;/P&gt;&lt;P&gt;Here's my code snippet (note that I have already defined the max_date variable in a previous step not in this section):&lt;/P&gt;&lt;LI-CODE lang="python"&gt;feature_layer = FeatureLayer(feature_layer_url, gis=gis)
given_date = max_date
query = f"submission_date_and_time &amp;gt; timestamp '{given_date}'"
selected_features = feature_layer.query(where=query)

print(f"Number of features selected: {len(selected_features.features)}")

if len(selected_features.features)&amp;gt;0:
    output_feature_class = r'C:\path\to\Default.gdb\SelectedFeatures'
    copy_features = arcpy.management.CopyFeatures(selected_features, output_feature_class)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No matter what I try in line 10 - CopyFeatures, ExportFeatures, truncate an existing table and append the selected records - I cannot get those selected features out of the S123 feature layer.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I suspect that the attachments functionality is complicating the process, but I can't isolate a specific issue to troubleshoot. Does anyone have suggestions on how I can get these points exported to a FGDB?&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2024 15:07:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/exporting-points-from-s123-feature-service-with/m-p/1391124#M55273</guid>
      <dc:creator>AmyRoust</dc:creator>
      <dc:date>2024-03-05T15:07:30Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting points from S123 feature service with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/exporting-points-from-s123-feature-service-with/m-p/1391534#M55283</link>
      <description>&lt;P&gt;I see you're using the arcpy module to call CopyFeatures, but my experience is that you can't access hosted layers with the arcpy module.&amp;nbsp; It looks like you're using the arcgis module to set up you FeatureLayer, so I think you're well on the way to success.&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;There's a section in the ArcGIS for Python API that talks about how to call geoprocessing tools.&amp;nbsp; I think your answer may be there.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/python/guide/an-introduction-to-geoprocessing/" target="_blank"&gt;https://developers.arcgis.com/python/guide/an-introduction-to-geoprocessing/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2024 22:53:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/exporting-points-from-s123-feature-service-with/m-p/1391534#M55283</guid>
      <dc:creator>TylerGraham2</dc:creator>
      <dc:date>2024-03-05T22:53:42Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting points from S123 feature service with arcpy</title>
      <link>https://community.esri.com/t5/arcgis-survey123-questions/exporting-points-from-s123-feature-service-with/m-p/1391605#M55291</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/366404"&gt;@TylerGraham2&lt;/a&gt;, &lt;STRONG&gt;thank you&lt;/STRONG&gt; for your comment! It put me down the right path to find a solution.&lt;/P&gt;&lt;P&gt;From what I read in the Python API documentation, the only way to export features from a hosted feature layer is to export them into a new item in your ArcGIS Online account (or presumably Enterprise Portal, if that's your environment). I didn't want to manage the overhead of creating a new item, downloading it, and then deleting the web item, so I decided to rewrite the script to download the entire hosted feature layer using&amp;nbsp;arcpy.conversion.FeatureClassToFeatureClass() function. Thankfully, that arcpy function worked even though I was pulling hosted feature layer data into a file geodatabase on my desktop.&lt;/P&gt;&lt;P&gt;Once I had a copy of the entire point feature class, I used a SQL query in arcpy.management.MakeFeatureLayer() to select the records that I wanted to put into my master feature class.&lt;/P&gt;&lt;P&gt;For those who don't mind creating a new item in your portal, you can use &lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.features.manage_data.html#extract-data" target="_self"&gt;arcgis.features.manage.data.extract_data&lt;/A&gt; to export the results of a query into a separate file geodatabase (or shapefile, or csv, etc).&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2024 01:46:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-survey123-questions/exporting-points-from-s123-feature-service-with/m-p/1391605#M55291</guid>
      <dc:creator>AmyRoust</dc:creator>
      <dc:date>2024-03-06T01:46:09Z</dc:date>
    </item>
  </channel>
</rss>

