I have an online feature class "A" with a field "OBJECT ID". I am using Feature Class to Feature Class conversion to create a copy in my local Geodatabase.

While doing so I realized that the OBJECT ID gets changed somehow; so I tried to do this in ArcGIS Pro 2.8 by creating an additional field "OBJ1" while using Feature Class to Feature Class conversion and selecting "OBJECTID" field as Source with Merge Rule as "First".

This runs successfully and gives me the desired result in the form of "OBJ1" Output field with original "OBJECTID" value from A to B (local GDB Feature Class).

enter image description here

I tried to get the Python command since I need to do this in a script, but it seems everything got hard coded as a string especially the field mapping part, and I am unable to understand how to make it dynamic. I tried to place the place holders but it becomes confusing.

if not arcpy.Exists(self.Output_Layer):
    arcpy.conversion.FeatureClassToFeatureClass(splice_closure, p1, self.Output_Layer, '', r'GlobalID "GlobalID" false false true 38 GlobalID 0 0,First,#,xxxxxxxxxxx\xxxxxxxxxxxxx,GlobalID,-1,-1;label "Label" true true false 8 Text 0 0,First,#,xxxxxxxxxxx\xxxxxxxxxxxxx,label,0,8;enc_type "Enclosure Type" true true false 0 Long 0 0,First,#,xxxxxxxxxxx\xxxxxxxxxxxxx,enc_type,-1,-1;enc_size "Enclosure Size " true true false 0 Long 0 0,First,#,xxxxxxxxxxx\xxxxxxxxxxxxx,enc_size,-1,-1;stru_label "Structure Label" true true false 15 Text 0 0,First,#,xxxxxxxxxxx\xxxxxxxxxxxxxe,stru_label,0,15;placement "Placement" true true false 0 Long 0 0,First,#,xxxxxxxxxxx\xxxxxxxxxxxxx,placement,-1,-1;sp1_type "SP1 Type" true true false 0 Long 0 0,First,#,xxxxxxxxxxx\xxxxxxxxxxxxx,sp1_type,-1,-1;sp1_label "SP1 Label" true true false 16 Text 0 0,First,#,xxxxxxxxxxx\xxxxxxxxxxxxx,sp1_label,0,16;sp2_type "SP2 Type" true true false 0 Long 0 0,First,#,xxxxxxxxxxx\xxxxxxxxxxxxx,sp2_type,-1,-1;status "Status" true true false 0 Long 0 0,First,#,xxxxxxxxxxx\xxxxxxxxxxxxx,status,-1,-1;reel_end "Reel End?" true true false 0 Long 0 0,First,#,xxxxxxxxxxx\xxxxxxxxxxxxx,reel_end,-1,-1;sp2_label "SP2 Label" true true false 16 Text 0 0,First,#,xxxxxxxxxx\xxxxxxxx,sp2_label,0,16;CreationDate "CreationDate" true true false 8 Date 0 0,First,#,xxxxxxxxxxxxxxx\xxxxxxxxxxxxxxxxxxx,CreationDate,-1,-1;Creator "Creator" true true false 128 Text 0 0,First,#,xxxxxxxxxxxxxxxxxxx\xxxxxxxxxxxxxxxxx,Creator,0,128;EditDate "EditDate" true true false 8 Date 0 0,First,#,xxxxxxxxxxxxxxxxxxxx\xxxxxxxxxxxxxxxxxxxx,EditDate,-1,-1;Editor "Editor" true true false 128 Text 0 0,First,#,xxxxxxxxxxxxxxxxxx\xxxxxxxxxxxxxx,Editor,0,128;OBJ1 "OBJ1" true true false 255 Text 0 0,First,#,xxxxxxxxxxxxxxxxx\xxxxxxxxxxxxx,OBJECTID,-1,-1', '')

I am using ArcPy 3.0 and ArcGIS Pro 2.8 version

  • If you want to include all fields, just skip the field map parameter. It's unnecessary, if you want to include all fields. Sep 14 at 0:58
  • 1
    @BERA That seems to be working. Thanks Sep 14 at 5:41

I have had problems loosing the objectid field (which I needed for joins) when copying data from a server. What solved my problem was using featuresets and recordsets:

import arcpy, os

connection_file = r"D:\folder\connectiontoserver.sde"
local_fgdb = r'D:\download\data.gdb'

list_of_tables = ['table1','table2']

for t in list_of_tables:
    fullname = os.path.join(connection_file, t)
    feats.save(os.path.join(local_fgdb, t))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.