Select to view content in your preferred language

Copy paste from one layer to another using python commands

2774
6
Jump to solution
04-06-2020 12:19 PM
EduardoC_
Occasional Contributor

Hi, I'm looking for a way of copy paste points from one layer to another, just by using python commands in Arcgis pro.

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
CCWeedcontrol
Frequent Contributor

Something like below but It might just be easier to use the Use append tool to append your selected features including all attributes.

import arcpy
from arcpy import env

fc1 = "" #Feature class to copy from
fc2 = "" #feature class to copy to
arcpy.env.workspace = "" #Workspace "C:/Temp"

arcpy.env.overwriteOutput = True
# Start an edit session. Must provide the worksapce.
edit = arcpy.da.Editor(arcpy.env.workspace)

# Edit session is started without an undo/redo stack for versioned data
#  (for second argument, use False for unversioned data)
edit.startEditing(True)

# Start an edit operation
edit.startOperation()

arcpy.Append_management(fc1, fc2, "NO_TEST")

# Stop the edit operation.
edit.stopOperation()

# Stop the edit session and save the changes
edit.stopEditing(True)

arcpy.RefreshActiveView()
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

View solution in original post

6 Replies
DanPatterson_Retired
MVP Emeritus

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 

CCWeedcontrol
Frequent Contributor

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?

0 Kudos
EduardoC_
Occasional Contributor

I want to copy all the points from one feature layer to another base feature layer. Both feature layers have the same attributes.

0 Kudos
DanPatterson_Retired
MVP Emeritus
0 Kudos
CCWeedcontrol
Frequent Contributor

Something like below but It might just be easier to use the Use append tool to append your selected features including all attributes.

import arcpy
from arcpy import env

fc1 = "" #Feature class to copy from
fc2 = "" #feature class to copy to
arcpy.env.workspace = "" #Workspace "C:/Temp"

arcpy.env.overwriteOutput = True
# Start an edit session. Must provide the worksapce.
edit = arcpy.da.Editor(arcpy.env.workspace)

# Edit session is started without an undo/redo stack for versioned data
#  (for second argument, use False for unversioned data)
edit.startEditing(True)

# Start an edit operation
edit.startOperation()

arcpy.Append_management(fc1, fc2, "NO_TEST")

# Stop the edit operation.
edit.stopOperation()

# Stop the edit session and save the changes
edit.stopEditing(True)

arcpy.RefreshActiveView()
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
DanPatterson_Retired
MVP Emeritus

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

import arcpy
arcpy.env.workspace = "C:/path_to_your/data.gdb"
arcpy.Append_management(["featureclass1", "featureclass2"], "TEST")