I created a model in ArcPro that will delete features (ex. drainage areas) that intersect with unfeasible landcover classes within a raster (ex. impervious). So I used the following model structure: Reclassify --> Raster to Polygon --> Select By Location (Intersect) --> Delete Features.
This model worked fine when I tested it on one geodatabase's data - but when I try to Iterate Workspace to apply the model to all 73 geodatabases, it cannot figure out where the input feature data is. Each geodatabase has the same data naming conventions within it but with different geodatabase id numbers at the end (ex. M3_drainage_huc_#). So the input features I use for Select by Location look like this ex: %Path%Name%M3_drainage_huc_%HUCNumber%
But as you can see in the screenshot below, it doesn't recognize where they are.
Any ideas as to why this might be happening? And/or ways to work around this issue?
P.S. Sorry if I didn't explain my question well enough--I tried not to make it confusing, but let me know if you need any clarifications.
Without more info, there are several things that might be the issue. I'd like to also say that the Report tool in the ModelBuilder toolbar will show you exactly how MB perceives all of the elements -- it's a great way to debug a complex model.
We'll start with the low hanging fruit: I can't tell exactly what the input parameters are for Select by Location, but there's a chance that it's a syntax issue. In your post you wrote:
...which should be something more like:
The Path output variable from the Parse Path tool does not include a final slash, nor does Name. Also the percent signs referencing your inline variables should encapsulate the "variable name", kind of like quotation marks. The way you have it in your post looks like this to ModelBuilder:
with just two variables: %Path% and %M3_drainage_huc_% (which isn't defined). "Name" is just a static string in between two variables, and I have no idea what it does with "HUCNumber%". Or maybe it sees nested variables, I'm not sure how it works exactly. But either way it's not seeing the correct path to the features. It should be more like:
where %Path% and %Name% reference the path and name of each GDB contained by the input directory, then %HUCNumber% is stripped from the GDB's name and appended to each of the standardized feature's "prefix" (M3_drainage_huc_, M3_bioreactor_huc_, etc.).
But that syntax is just the tip of the iceburg. I'll pretend the iterator input folder is called "C:\GIS\Folder" and that it contains a geodatabase named "HydroData_123.gdb" where 123 is the HUC# for the examples below. I don't know what's happening inside the Calculate Value tool, but here's what your variables are:
The Parse Path tool doesn't shave off the extension for GDBs for some reason even though it does put the extension in the Extension variable. The variables %Name% and %Workspace Name% are identical strings, which is the name of your geodatabase without its extension. If the Calculate Value tool doing takes %Name 2% and performs string manipulation to identify the HUC#, it should account for those extra four characters at the end of the string. What is the expression you're using there?
Note that the input for Select by Location that I think you meant to use
which is missing .gdb extension and looks like a regular folder.
Also, tools are picky about which types of data they accept as inputs. Select Layer by Location requires a Feature Layer, Raster Layer, or Mosaic Dataset. One trick to force picky tools to accept my input is to use the Calculate Value tool to set up each input (using the inline variables) and make sure the Data Type is set to "Feature Class" or "Raster Dataset" depending on what it is.
The expressions should be:
Since the Calculate Value tool uses Python to evaluate the expression, using quotes is helpful here and adding the r to the beginning ensures that the slashes in the filepath don't cause problems.
Though I made WAY too many assumptions, I built a model using your overall structure but with the above fixes and everything worked. The red box indicates the Calculate Value tools I added that make sure the input for the select tool is correct.
ModelBuilder is freakin weird sometimes, which is why I usually just write my own scripts. Let me know if I made an incorrect assumption here and I'll help you troubleshoot further if you can provide more info. Probably the easiest way to ensure all possible useful information is included would be to export the model report and post the XML file.