Copying exact record in another feature class while creating the record in a feature class using ArcPy....

2799
12
10-15-2020 06:23 PM
ShahriarRahman
New Contributor III

Hi All,

I am trying to create a feature in a feature class, and want to automate the same record creation at the same time in another feature class using ArcPy scripting. Is there any way to do it? I can do it manually using "Paste Special", but it does not help when you have thousands of records. Great to have your expert suggestion. Please share any sample (Python or Arcade) script if you have faced this challenge, and solved it. Thank you in advance.

0 Kudos
12 Replies
DanPatterson
MVP Esteemed Contributor

Is this what you are currently doing?

Copy and paste features using the clipboard—ArcGIS Pro | Documentation 

Or are you trying to automate copying features from an existing featureclass?

Copy Features (Data Management)—ArcGIS Pro | Documentation 

In any event, how are you doing the selection, given you indicate you have lots to do?


... sort of retired...
0 Kudos
ShahriarRahman
New Contributor III

Hi, Dan. Thank you for your reply. Yes, I am doing both tasks together, and want to do it through ArcPy without opening the feature class that I want to add into. Like, If I am drawing something in "Water" layer, I want to copy the same record to "All_Water" feature class without opening the "All_Water" feature class, and it will populate description from one attribute (of "Water") to "All_Water" feature class. Is it possible to automate these tasks in an ArcPy script? Great if you please can share something similar.

Kind regards,

Shahriar

0 Kudos
DanPatterson
MVP Esteemed Contributor

I wouldn't recommend doing what I think you are doing, because it can rapidly propagate errors which you will want to undo, and doing this over many featureclasses will be ... shall we say .... less than an enjoyable experience.

Instead I would recommend finishing drawing your "Water" layer and making sure its records (geometry and attributes ) are to your satisfaction.  Then check again, because you are about to add "the stuff" to existing data, which presumably is good.

Once all is good, then you use either Append or Merge from the General toolset

An overview of the General toolset—ArcGIS Pro | Documentation 

My preference would be to merge since the original datasets are preserved and new ones are created... You can always go back, unlike Append which can add stuff that you find you want to correct later.

Merging to may featureclasses is possible by calling the script in arcpy.

Try it... the workflow can be exported to a script and it will serve as the basis for something that you want to automate.

Storage space is cheap.  Unraveling to a point in time where things were good, is definitely not, and it may never be attained.


... sort of retired...
ShahriarRahman
New Contributor III

Hi, @Dan Patterson. Thank you for your kind suggestion. I appreciate it, but at this moment, I need to do this at the same time to minimise the production time. As I want to link (from "Water" to "All_Water") based on a common identifier, it will not create any attribute error. Great if you please can share some similar scripts or references.

Thanking you,

Shahriar

0 Kudos
DanPatterson
MVP Esteemed Contributor

common identifiers are "joins", but they don't transfer geometry, only attributes


... sort of retired...
XanderBakker
Esri Esteemed Contributor

Hi Shahriar Rahman ,

If your data resides in an enterprise geodatabase, your best option is using a Calculation Attribute Rule. This could do this automatically on creating. Calculation attribute rules—ArcGIS Pro | Documentation 

Attribute Rules

ShahriarRahman
New Contributor III

I need to create the same record to both of the spatial layers. I am not sure we can do it through Arcade, but if you have any ArcPy example/sample it will be great! Xander Bakker @Dan Patterson 

Thank you both for your suggestions.

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi Shahriar Rahman ,

Before jumping into code examples it might be good to understand the "why" you have to do what you are trying to do. So if you can elaborate on that, it would be great. 

Then the "when" and how often something should happen is also important. If directly after creating a new feature or updating an exiting feature a trigger should propagate that change into the other featureclass, this will have a large influence on the right solution. Maybe replicas would be the way to achieve this Geodatabase replication fundamentals—ArcGIS Pro | Documentation  or otherwise Calculation Attribute Rules as I mentioned before: Calculation attribute rules—ArcGIS Pro | Documentation using the triggers Insert, Update and perhaps even Delete depending your requirements. 

Creating a script to reflect the changes into the other featureclass is an option, however, when should it run and how will it detect the changes to propagate into the other featureclass? You will want to avoid a full scan of the data and compare everything since this will become slow when the volume of data rises. Also, a script will not automatically trigger when you edit the data in one featureclass and will need to be started somehow. 

ShahriarRahman
New Contributor III

Hi Xander Bakker‌,

The story is two vector layers are related. One layer (Roads_All) is a summary of many road layers (e.g., Local Roads, Collector Roads, Distributor Roads, Sub-Arterial and Arterial Roads). It is very challenging to work on many individual road layers (and the data are intermittent) and then append it into the base layer (here, Roads_All). I want to simplify the task in a single step (so I don't need to append it after adding one or two records).

Is it possible to do it through ArcPy script, like while saving the edits, it will also append to the base layer? Sorry, but I am not sure is it doable or not.

0 Kudos