How to input more than 1 shapefile in model builder

3912
8
11-18-2017 12:42 AM
AkhilChhibber1
New Contributor II

I am new to GIS modelbuilder. I have 3 shapefiles and for 3 of them:

1.) I want to make a buffer
2.) Project the coordinate system
3.) Multipart to single

What I want to do is apple these tools in my model to more than 1 shapefile(suppose 3) and output the same(i.e. 3) shapefiles with applied tools(as per the 3 mentioned tools above)

0 Kudos
8 Replies
AbdullahAnter
Occasional Contributor III

Frist put the three shape files alone inside one folder.

Then design your model as the following picture:

Insert : Iterate Feature Classes (and define the folder path) , then connect  shapefile with  the first tool (buffer) then the second tool ..etc

Make the Workspace of iteration tool as a parameter (shape files folder in the picture) , and make the final output as parameter to define the path of the result of model.

AkhilChhibber1
New Contributor II

The result you told is helpful but this is the case in which we know which shapefiles we need to run the process on.

Suppose I have random shapefiles may be 2 or 4 or 7 and I want to run this model i.e. all the processed included in the model, how would I do.

Please help me out. i would be thankful to you for this.

0 Kudos
AkhilChhibber1
New Contributor II

ITERATOR

I tried using the method as per your reply. But the issue which I am facing is that in Iterator only one shapefile is selected i.e. bld2plot. I have 4 shapefiles in the folder which I selected from Iterate Feature but still only I shapefile is coming as per the screenshot above specifically marked in red circle.

0 Kudos
AbdullahAnter
Occasional Contributor III

Frist , connect the output of Iteration with the first input process.

 in your case connect the output of iteration with input of project and remove the parameter (Define shape file). And make the workspace of iteration as parameter.

Second when you run the model and finish all processes , the model will start again with next shapefile, and will keep reply until finish the last shapefile in the folder. 

0 Kudos
DuncanHornby
MVP Notable Contributor

With so few inputs an alternative method, if you do not wish to use an iterator is to make the input of the buffer tool a list of values. Simply right click on the input, go to properties and choose list of values.

When you open the input you can add as many inputs as you like, you would also need to set the equivalent "row" in the output of the project and multi-to-single part tools. 

Not saying this is a better approach than Abdullah's method, just a different way of achieving the same outcome.

Model

AkhilChhibber1
New Contributor II

As per the description in the comment

The result was helpful but the image above is the result which would happen using the approached being told by you in the comment. Can you please help me out with a way with which I can get an interface like in the image below.

The above image is what I need and I am not able to figure out how to get this in my model such that if suppose I have 2 or 6 or any number of shapefiles, the same processes run for every shapefile.

0 Kudos
DuncanHornby
MVP Notable Contributor

If you are wanting a similar interface as above you need to be exposing your inputs and outputs as Parameters, simply right click on them in model builder and select model parameter, then run the model outside modelbuilder. But you need to think about what you are asking:

Input data > Buffer > Project > Single part

The issue here is that you are passing a single dataset through the model. The interface above is proving a LIST of input datasets. If you read the help file, syntax section, buffer tool takes as input a SINGLE featurelayer. So what you are asking is impossible. Abdullah's idea of passing in a folder of shapefiles in more sensible, the user selects a workspace with datasets and then the iterator feeds out a dataset at a time into the rest of your model.

AkhilChhibber1
New Contributor II

I understand the fact that in case of "Buffer" tool, only 1 shapefile can be used at a time and input of more than 1 shapefile in not possible.

MODEL

INTERFACE

The image above shows the model which I am using because I want to use the same process for 4 shapefiles. Also the interface have been shown in the image above.

This model is working fine and also solving my problem. The problem which I am facing is that I want a model in which there should be no restriction for the number of input files. Suppose I want to run the same process for suppose 2 or 4 or 10 shapefiles and this model is only restricted to 4 shapefiles. What should I do do fix this issue???????

Please help me out with this issue. I would be thankful to you for this.

0 Kudos