How to get a model to continue when 'all the inputs are not current'

10503
7
02-25-2016 06:41 AM
MTGIS
by
New Contributor

Hello,

I am trying to write a model in ModelBuilder. I have attempted to create six shapefile, however two of these contained no data. I am trying to get the model to merge the shapefiles. However because two have no data, it won't do the merge. But I still want it to run, merging the other 4 shapefiles that have data in them. Is there a way I can get this to run the merge?

Thanks,

Michael

Tags (1)
0 Kudos
7 Replies
ScottMoyer
Occasional Contributor

Michael,

I created a test model with two empty shapefiles and one shapefile with data. The Merge of all three ran all the way through without error. All fields were also merged. Is there something else that may be stopping your model?

Scott

MTGIS
by
New Contributor

Thanks Scott. You are correct, but I worded my question incorrectly. The issue is that the shapefiles aren't actually created, not that they are created empty. So I have six model output - 4 shapefiles and 2 nothings. Another time I run the model on a different area it may be any combination of shapefiles and nothings. However I always want it to merge anything that has been created. It gets stuck when I have inputs into the merge that don't exist.

0 Kudos
DanPatterson_Retired
MVP Emeritus

do you have a precondition set to gather only those files for merging if they exist? or are they all required parameters?  in otherwords an " if exists then proceed" syntax. 

0 Kudos
MTGIS
by
New Contributor

Hi Dan,

The problem when I try to do that is that because some of the shapefiles do not exist, the model stops. But I want it to carry on with the merge despite some of the shapefiles not existing. Perhaps I am using IF incorrectly?

0 Kudos
XanderBakker
Esri Esteemed Contributor

Most geoprocessing tool will generate empty outputs (featureclasses with no features) so this shouldn't produce the problems you are encountering. Also if you use the Lists: Iterate Feature Classes—Help | ArcGIS for Desktop it will only take into account the existing featureclasses. So how are you generating the list of 6 featureclasses?

0 Kudos
MTGIS
by
New Contributor

Thanks for the replies.

Specifically my model was selecting features with certain attributes (select by attribute tool), then making these selections into new features (copy features tool), then calculating the area of the new feature (calculate geometry/area tool). The outputs from the calculate geometry/area tool are then used as inputs into the merge tool. However, for areas where there have been no features selected the calculate geometry/area tool does not produce any output. So when the merge then tries to run it can't.  I have adjusted the model now so that the calculate areas occurs after the merge and it runs fine now. But I'd still be interested to hear if there is a way to get the merge to run as I originally intended.

Thanks,

Michael

0 Kudos
XanderBakker
Esri Esteemed Contributor

If you create the intermediate featureclasses in a specific workspace, you can list those that exist and use those in the merge tool. I would probably have switched to Python already.