Hi, I'm looking for a way of copy paste points from one layer to another, just by using python commands in Arcgis pro.
Something like below but It might just be easier to use the Use append tool to append your selected features including all attributes.
<SPAN class="keyword token">import</SPAN> arcpy <SPAN class="keyword token">from</SPAN> arcpy <SPAN class="keyword token">import</SPAN> env fc1 <SPAN class="operator token">=</SPAN> <SPAN class="string token">""</SPAN> <SPAN class="comment token">#Feature class to copy from</SPAN> fc2 <SPAN class="operator token">=</SPAN> <SPAN class="string token">""</SPAN> <SPAN class="comment token">#feature class to copy to</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>workspace <SPAN class="operator token">=</SPAN> <SPAN class="string token">""</SPAN> <SPAN class="comment token">#Workspace "C:/Temp"</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>overwriteOutput <SPAN class="operator token">=</SPAN> <SPAN class="token boolean">True</SPAN> <SPAN class="comment token"># Start an edit session. Must provide the worksapce.</SPAN> edit <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>Editor<SPAN class="punctuation token">(</SPAN>arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>workspace<SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># Edit session is started without an undo/redo stack for versioned data</SPAN> <SPAN class="comment token"># (for second argument, use False for unversioned data)</SPAN> edit<SPAN class="punctuation token">.</SPAN>startEditing<SPAN class="punctuation token">(</SPAN><SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># Start an edit operation</SPAN> edit<SPAN class="punctuation token">.</SPAN>startOperation<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Append_management<SPAN class="punctuation token">(</SPAN>fc1<SPAN class="punctuation token">,</SPAN> fc2<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"NO_TEST"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># Stop the edit operation.</SPAN> edit<SPAN class="punctuation token">.</SPAN>stopOperation<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># Stop the edit session and save the changes</SPAN> edit<SPAN class="punctuation token">.</SPAN>stopEditing<SPAN class="punctuation token">(</SPAN><SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">)</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>RefreshActiveView<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
In fact, you indicated that the attributes are the same, which suggests that the fields are the same, so the code sample is much easier
<SPAN class="keyword token">import</SPAN> arcpy arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>workspace <SPAN class="operator token">=</SPAN> <SPAN class="string token">"C:/path_to_your/data.gdb"</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Append_management<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">"featureclass1"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"featureclass2"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"TEST"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Append—Data Management toolbox | Documentation to an existing file
Merge—Data Management toolbox | Documentation to a new file
I want to copy all the points from one feature layer to another base feature layer. Both feature layers have the same attributes.
Can you elaborate a little more on what you are trying to accomplish, are you trying to copy all the points from one feature class to another or just copy the selected ones or ones with a certain attribute?
Reading geometries—ArcPy Get Started | Documentation
Writing geometries—ArcPy Get Started | Documentation
or you can use tools in arctoolbox, eg.
Copy tool and Append tool
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.