<?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: Copying point location into new feature class in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/copying-point-location-into-new-feature-class/m-p/16044#M367</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;From what you're describing make sure you destination featureclass has the same spatial domain and coordinate system is the same as your source featureclass.&amp;nbsp; I don't know if you need the spatialreference line.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 05 Dec 2012 23:29:00 GMT</pubDate>
    <dc:creator>SteveFang</dc:creator>
    <dc:date>2012-12-05T23:29:00Z</dc:date>
    <item>
      <title>Copying point location into new feature class</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/copying-point-location-into-new-feature-class/m-p/16042#M365</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to grab point features from an existing point layer (feature class), and add a new point feature into a different feature class at &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;that&lt;/SPAN&gt;&lt;SPAN&gt; location (based on irrelevant criterion).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I have creates new features, however, It puts all the features on top of each other at a single location, far away from the actual points I got the geometry from.&amp;nbsp; My code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
IFeature newConflict = fc.CreateFeature(); //feature class to create feature

newConflict.Shape = mFeat.Shape;&amp;nbsp; //mFeat is where I am pulling data from into newConflict

newConflict.Shape.SpatialReference = mFeat.Shape.SpatialReference;

//check for field, then add values
if (newConflict.Fields.FindField(FieldName) != -1)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (Value != null) Feature.set_Value(newConflict.Fields.FindField(FieldName), Value);
&amp;nbsp;&amp;nbsp;&amp;nbsp; else Feature.set_Value(newConflict.Fields.FindField(FieldName), DBNull.Value);
}
newConflict.Store();
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does feature.Shape not have contain location?&amp;nbsp; I thought it was complete geometry.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Do I need to manually store the Shape into the Shape field?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Dec 2012 11:30:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/copying-point-location-into-new-feature-class/m-p/16042#M365</guid>
      <dc:creator>KevinYanuk</dc:creator>
      <dc:date>2012-12-04T11:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: Copying point location into new feature class</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/copying-point-location-into-new-feature-class/m-p/16043#M366</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;As I understand this you just set the value for an empty feature in newConflict , you don't copy the feature.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Can't you just use Append? I really depends in what conditions you want to copy the feature(is it selected? etc). &lt;/SPAN&gt;&lt;BR /&gt;&lt;STRONG&gt;Does feature.Shape not have contain location? I thought it was complete geometry.&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;(lest assume we have declared IFeature feature and it is point feature, I will skip few things just to show you example) &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

IPoint point = (IPoint)feature.Shape;
//now you can get the x,y and z values from it

double x = point.X;
double y = point.Y;
double z = point.Z;
&lt;/PRE&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Use Append Class form DataManagementTools to append feature into new featurelayer(the attributes will be copied as well).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;tip - &amp;gt; it's easier to read the code this way:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
if (newConflict.Fields.FindField(FieldName) != -1)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (Value != null)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Feature.set_Value(newConflict.Fields.FindField(FieldName), Value);
&amp;nbsp;&amp;nbsp;&amp;nbsp; else 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Feature.set_Value(newConflict.Fields.FindField(FieldName), DBNull.Value);
}


&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 15:55:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/copying-point-location-into-new-feature-class/m-p/16043#M366</guid>
      <dc:creator>MarcinDruzgala</dc:creator>
      <dc:date>2021-12-12T15:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: Copying point location into new feature class</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/copying-point-location-into-new-feature-class/m-p/16044#M367</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;From what you're describing make sure you destination featureclass has the same spatial domain and coordinate system is the same as your source featureclass.&amp;nbsp; I don't know if you need the spatialreference line.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Dec 2012 23:29:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/copying-point-location-into-new-feature-class/m-p/16044#M367</guid>
      <dc:creator>SteveFang</dc:creator>
      <dc:date>2012-12-05T23:29:00Z</dc:date>
    </item>
  </channel>
</rss>

