Select to view content in your preferred language

ESRI model builder iterations and clipping

4371
5
Jump to solution
11-10-2014 10:38 AM
RyanRobinson1
Deactivated User

I am trying to build an ESRI model which makes a copy of a file in "folder A"  everytime it iterates over an individual file in "folder B". Then it clips the copied file  with the iterated file in "folder b".

 

I can get it do iterate over a set of files but am having trouble with making a copy and clipping that copy over each iteration. Can anyone give me some direction as to go about this? I have tried using sub models but not sure that is the way to go. Is this something better accomplished through Python scripting?

 

Thanks

 

Ryan

0 Kudos
1 Solution

Accepted Solutions
ChrisDonohue__GISP
MVP Alum

I think you have the your model mostly set up correctly as you depicted it above.  Most of the advice I posted is irrelevant if this is the case, since the model will not need to be as complex.

One suggested change - assuming you don't need multiple copies of the Original.shp, you can skip the Copy Features part and instead use the Original.shp as a direct input to the Clip, since it is constant.

If it doesn't work, post what the error is (if any) and/or how far it got before it stopped.

Another issue to check would be the presence of other types of files in the Iterated folder besides shapefiles, as they may trigger an error as the model tries to Clip them.  These can often filtered out (without having to remove them) by setting the  the Iterate Feature Classes "Feature Type" to "Polygon."

View solution in original post

0 Kudos
5 Replies
ChrisDonohue__GISP
MVP Alum

A few questions to help clarify what you are trying to do/troubleshoot/brainstorm.  I haven't seen your model/code, so these are stabs in the dark, but may offer some insight:

1.  Is an "in-line variable substitution" being used to point to the appropriate file to be copied in folder A?  This is a potential way to extract the file name from the iterated file for use in the Copy process, assuming that is how your iteration is set up (i.e. the file names are an attribute in the file you are iterating).  http://resources.arcgis.com/en/help/main/10.2/index.html#/Examples_of_inline_model_variable_substitu...

2.  Is the intent to only get a clipped result - i.e. do you need to retain the copy made before it was clipped?  I ask as there can sometimes be issues where the data used in the process - the "intermediate data" - is not being created as expected and thus unavailable for the following processes (Clip).

http://resources.arcgis.com/en/help/main/10.2/index.html#/Making_intermediate_data_managed_data/002w...

One can also make the intermediate data Parameters to force the saving:

http://resources.arcgis.com/en/help/main/10.2/index.html#/Preserving_intermediate_data/002w0000003m0...

Chris Donohue, GISP

0 Kudos
ChrisDonohue__GISP
MVP Alum

Some more ideas.  I put together a quick model of what I think you are trying to do (but without knowing the particulars):

(please see attached jpg)

Iterate_CopyFC_Clip__TEST.jpg

1.  You may need a Precondition set for the Feature Class to Feature Class to activate correctly.  Set the Precondition for "Name".  A dotted line will show up connecting Name to the FC to FC.

2.  If it runs the Feature Class to Feature Class but does not save the results, consider making the Output Feature Classes Parameters (as in jpg) to ensure it saves

3.  Major potential issue - you may end up with an "infinite loop" as the process copies a file from Folder A to Folder B, but then continues Iterating Folder B based on the files that are there (which the process continues to add).  If this occurs, a workaround would be to make 2 submodels:

- Submodel for Copy.  The initial Iterate Features and Feature Class to Feature Class, but modified to copy the files to another location besides Folders A or B (let's call it Folder C),

- Submodel for the Clip part, where an iteration occurs (Iterate Feature Classes) on Folder C to clip the files, with the results going back to the final location desired.

-Then a model to connect the two submodels, with a Precondition set to have the Clip submodel activate after the Copy submodel is done.

Anyway, hope that helps.

Chris Donohue, GISP

0 Kudos
RyanRobinson1
Deactivated User

Thanks Chris,

Im going to take a look at what you suggested. The attached image is what I have as a rough draft of what im trying to do.

I basically need to make a copy of the "Original" file for the first file in "Folder A", clip that copy with the first file and then move to the next file in "Folder A", make another copy of "Original" and repeat the process until it iterates over all files in "Folder A".

Inputs would be:

Folder A

file1.shp

file2.shp

file3.shp

Folder B

"Original.shp" (File to be copied and clipped)

Output would be:

(Folder B)

Copy of Original_file1_clipped

Copy of Original_file2_clipped

Copy of Original_file3_clipped

model.JPG

0 Kudos
ChrisDonohue__GISP
MVP Alum

I think you have the your model mostly set up correctly as you depicted it above.  Most of the advice I posted is irrelevant if this is the case, since the model will not need to be as complex.

One suggested change - assuming you don't need multiple copies of the Original.shp, you can skip the Copy Features part and instead use the Original.shp as a direct input to the Clip, since it is constant.

If it doesn't work, post what the error is (if any) and/or how far it got before it stopped.

Another issue to check would be the presence of other types of files in the Iterated folder besides shapefiles, as they may trigger an error as the model tries to Clip them.  These can often filtered out (without having to remove them) by setting the  the Iterate Feature Classes "Feature Type" to "Polygon."

0 Kudos
RyanRobinson1
Deactivated User

Thanks Chris. For some reason, I was stuck on the idea that I need to make a copy since that is how I did it in another GIS program. I appreciate the help.

ryan

0 Kudos