Select to view content in your preferred language

ModelBuilder Iteration

514
6
Jump to solution
12-13-2023 04:59 AM
AJ24
by
New Contributor II

Hello Team,

 

I am trying to run a simple model which iterating the feature classes within a geodatabase and copying them into another geodatabase.

Model_sim.png

The model run and copied the feature classes into the target geodatabase. But the issue is the fields of the output feature classes does not match the fields in the input geodatabase (Somehow it take the fields of the first feature class as a template and copy it to the other feature classes in the output). I found that in Esri document:

When this tool is used in a model, the first feature class is used as a template for the output. This allows for selection of fields in subsequent tools.

 

Is there a way that I can preserve the fields of output feature classes?

0 Kudos
1 Solution

Accepted Solutions
Robert_LeClair
Esri Notable Contributor

Thank you for the additional information as I found a BUG that likely explains this behavior. 

BUG-000161459 - A model created in ArcGIS Pro 3.1.3, including an iterator and the Spatial Join tool with the merge rule set to 'Sum' for one of the attributes, executes unexpectedly. The output from the first iteration is correct, but for the following target feature classes, the tool reverts to the 'First' merge rule (the default rule option). 

The BUG is currently under review and is not reproducible in ArcGIS Pro 2.9.x

View solution in original post

6 Replies
Robert_LeClair
Esri Notable Contributor

So I built an ArcGIS Pro 3.2 model in modelbuilder that I use in Instructor Led classes to copy all the data from a folder of shapefiles to an Enterprise Geodatabase (as referenced below) and each feature class in the eGDB has their own unique attribute values vs. the first one being used as the template.  I do not do any field mapping in the Fields parameter of the FC to FC GP tool in the model.  

ModelBuilder.JPG

0 Kudos
AJ24
by
New Contributor II

Hi @Robert_LeClair ,

I tried to mimic your ModelBuilder and converted the data to a shapefile but I am getting the same result again. Here is  what I get when running the tool:

Input

 

po1in.png

Output: (this one copied without any issue since this the first feature class in iteration)

po1out.png

Input:

po2in.png

Output: (The schema of the feature class changed after copying it to match the first feature class)

po2out.png

The same happen to all feature classes/ Shapefiles.( It took the schema of the first feature class in the iteration)

The only difference between my test and yours is that I am using ArcGIS Pro 3.0

0 Kudos
Robert_LeClair
Esri Notable Contributor

Interesting!  I guess I never noticed this before but YES my model is doing the same thing.  The first feature class is fine but all subsequent feature classes inherit the schema of the first.  That's got to be a bug.  So I started digging deeper and learned the Feature Class to Feature Class GP tool is deprecated (or soon will be) and that the Export Features GP tool is recommended.  So I created a new model as seen below with the following settings.  It worked!  Each feature class has it's "own" schema as it were.

Also, no need to convert to a shapefile as the input workspace can be a folder of shapefiles, a file geodatabase or an enterprise geodatabase.

ModelBuilder2.JPG

0 Kudos
AJ24
by
New Contributor II

My model will also have the spatial join tool and it gives the same result (Copying the schema of the first feature class) the issue is reproducible with any tool that has the field map option

I belive it might be a bug specialy with the spatial join tool and FC2FC, but I would appricte your feedback if you can confirm that so I can look for any workaround

0 Kudos
Robert_LeClair
Esri Notable Contributor

Thank you for the additional information as I found a BUG that likely explains this behavior. 

BUG-000161459 - A model created in ArcGIS Pro 3.1.3, including an iterator and the Spatial Join tool with the merge rule set to 'Sum' for one of the attributes, executes unexpectedly. The output from the first iteration is correct, but for the following target feature classes, the tool reverts to the 'First' merge rule (the default rule option). 

The BUG is currently under review and is not reproducible in ArcGIS Pro 2.9.x

AJ24
by
New Contributor II

Another update, I tested it by using Pro3.2 and got the same result

0 Kudos