<?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: Saving a featureSet to a feature class in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/saving-a-featureset-to-a-feature-class/m-p/289150#M22417</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;What is the schema for your featureset input?&amp;nbsp; It sounds like something might be wonky with that since you are getting data out the other end, just missing fields.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1) Check schema of featureset input for tool.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2) If this is correct, you might want to do some error checking in your tool itself before you output to feature class.&amp;nbsp; Make sure all the fields are going into your featureclass-&amp;gt;featureclass&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
featureset = your featureset
fields = arcpy.ListFields(featureset)
for field in fields:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(field.name)
arcpy.CopyFeatures_management(featureset, outputFeatureclass)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 13:57:47 GMT</pubDate>
    <dc:creator>ChristopherFricke1</dc:creator>
    <dc:date>2021-12-11T13:57:47Z</dc:date>
    <item>
      <title>Saving a featureSet to a feature class</title>
      <link>https://community.esri.com/t5/python-questions/saving-a-featureset-to-a-feature-class/m-p/289147#M22414</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I create a gp service on ArcGIS server. Within this GP service there is a sub model which basically is Feature Class to Feature Class system tool except that Input Features parameter is a featureSet instead of featue class. The purpose of that is I want to save a featureSet from a query result to a feature class in %scratchworkspace%\scratch.gdb. It successfully save the featureset except for one thing: it only saved OBJECTID and Shape fields. all the other fields are lost in the process! Do someone have any ideas or Do i missing something? I have tried Copy Features, Table to Table and Copy Rows. They all have the same results. If i used the gp service on a mxd. It worked perfectly. That lead me to suspect it might have something to do with the FeatureSet. I wish someone can enlighten me on this.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Aug 2011 20:32:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/saving-a-featureset-to-a-feature-class/m-p/289147#M22414</guid>
      <dc:creator>HemingZhu</dc:creator>
      <dc:date>2011-08-04T20:32:35Z</dc:date>
    </item>
    <item>
      <title>Re: Saving a featureSet to a feature class</title>
      <link>https://community.esri.com/t5/python-questions/saving-a-featureset-to-a-feature-class/m-p/289148#M22415</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Heming,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a script that does something similar, but rather than creating a feature class in the scratch.gdb, my script creates a new file geodatabase in the the scratch folder and uses feature class to feature class to populate features while applying a query. The geodatabase is then zipped so it can be downloaded by a user. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You could try creating a new file GDB in the scratch folder and populate the feature class using Feature Class to Feature Class in the new GDB rather than using the sratch.gdb. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Alternately, rather than populating with Feature Class to Feature Class. You could create a new empty feature class in the sratch.gdb using Create Feature Class, setting your input or feature set as the template feature class (so the schemas match) . You could then use the Append to add the feature set (or a feature layer to which you apply your query) to the newly created feature class. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Not sure why what you are trying wouldn't work, but it my be worth trying a work around.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best of luck,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;BZ&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Aug 2011 21:14:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/saving-a-featureset-to-a-feature-class/m-p/289148#M22415</guid>
      <dc:creator>BenjaminZank1</dc:creator>
      <dc:date>2011-08-11T21:14:43Z</dc:date>
    </item>
    <item>
      <title>Re: Saving a featureSet to a feature class</title>
      <link>https://community.esri.com/t5/python-questions/saving-a-featureset-to-a-feature-class/m-p/289149#M22416</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Heming,&lt;BR /&gt;I have a script that does something similar, but rather than creating a feature class in the scratch.gdb, my script creates a new file geodatabase in the the scratch folder and uses feature class to feature class to populate features while applying a query. The geodatabase is then zipped so it can be downloaded by a user. &lt;BR /&gt;&lt;BR /&gt;You could try creating a new file GDB in the scratch folder and populate the feature class using Feature Class to Feature Class in the new GDB rather than using the sratch.gdb. &lt;BR /&gt;&lt;BR /&gt;Alternately, rather than populating with Feature Class to Feature Class. You could create a new empty feature class in the sratch.gdb using Create Feature Class, setting your input or feature set as the template feature class (so the schemas match) . You could then use the Append to add the feature set (or a feature layer to which you apply your query) to the newly created feature class. &lt;BR /&gt;&lt;BR /&gt;Not sure why what you are trying wouldn't work, but it my be worth trying a work around.&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;Best of luck,&lt;BR /&gt;BZ&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for reply. I have tried all the things you mentioned. I got the same results. I think the problem is not on those arcpy functions other than arcpy does not treat a featureset, which is a queryTask result from Web API, as a feature class or feature layer as ESRI doc claim. I do find a work around by changing the type from FeaturSet to FeatureLayer. Thanks for your suggestion anyway!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Aug 2011 12:08:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/saving-a-featureset-to-a-feature-class/m-p/289149#M22416</guid>
      <dc:creator>HemingZhu</dc:creator>
      <dc:date>2011-08-12T12:08:45Z</dc:date>
    </item>
    <item>
      <title>Re: Saving a featureSet to a feature class</title>
      <link>https://community.esri.com/t5/python-questions/saving-a-featureset-to-a-feature-class/m-p/289150#M22417</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;What is the schema for your featureset input?&amp;nbsp; It sounds like something might be wonky with that since you are getting data out the other end, just missing fields.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1) Check schema of featureset input for tool.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2) If this is correct, you might want to do some error checking in your tool itself before you output to feature class.&amp;nbsp; Make sure all the fields are going into your featureclass-&amp;gt;featureclass&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
featureset = your featureset
fields = arcpy.ListFields(featureset)
for field in fields:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(field.name)
arcpy.CopyFeatures_management(featureset, outputFeatureclass)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:57:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/saving-a-featureset-to-a-feature-class/m-p/289150#M22417</guid>
      <dc:creator>ChristopherFricke1</dc:creator>
      <dc:date>2021-12-11T13:57:47Z</dc:date>
    </item>
    <item>
      <title>Re: Saving a featureSet to a feature class</title>
      <link>https://community.esri.com/t5/python-questions/saving-a-featureset-to-a-feature-class/m-p/289151#M22418</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;What is the schema for your featureset input?&amp;nbsp; It sounds like something might be wonky with that since you are getting data out the other end, just missing fields.&lt;BR /&gt;&lt;BR /&gt;1) Check schema of featureset input for tool.&lt;BR /&gt;2) If this is correct, you might want to do some error checking in your tool itself before you output to feature class.&amp;nbsp; Make sure all the fields are going into your featureclass-&amp;gt;featureclass&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
featureset = your featureset
fields = arcpy.ListFields(featureset)
for field in fields:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(field.name)
arcpy.CopyFeatures_management(featureset, outputFeatureclass)
&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;First of all, I cann't use predefined schema because the featureset is based on user's choice of layer in .mxd, it is dynamic. Since featureset is the lightweight of featureclass, I thought the arcpy.ListFields(featureset) would give me a list of fields. Actually it is not the case. Featureset is a common result of interacting with map, unfortunately there is no easy ways to get its field names through arcpy.&amp;nbsp; Thanks for your suggestion.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:57:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/saving-a-featureset-to-a-feature-class/m-p/289151#M22418</guid>
      <dc:creator>HemingZhu</dc:creator>
      <dc:date>2021-12-11T13:57:50Z</dc:date>
    </item>
  </channel>
</rss>

