Is it possible in Model Builder to use a String Variable and Get Field Value Variable to reference an input file for a tool?

6507
11
05-31-2016 04:28 AM
RichardG
New Contributor II

ModelImage.png

I have a model which is set up to first iterate (using Feature Selection) through all points in a feature class using a unique value from field X (string).

The model then takes this feature and runs it through the Get Field Value tool in order to identify the attribute for any given feature from field Y (string).

This point is then fed into the Batch Watershed Delineation tool from the ArcHydro Toolset. Each of the input files for this tool are located in the same raster folder. Input files all begin with the same text. E.g. for Input Flow Direction Grid I have several files in my folder that start with "fdr" and end with the attributes gathered from the Get Field Value.

I created a string variable which points to the folder containing the raster files. I named this variablerasterLocation. I have tried to reference each of the relevant input files in the Batch Watershed Delineation Tool, e.g. %rasterLocation%fdr%Y%

However, I get the error message - "Input dataset does not exist or is not supported."

0 Kudos
11 Replies
FC_Basson
MVP Regular Contributor

Looks like you are missing a slash after the folder path.  Try %rasterLocation%/fdr%Y%

0 Kudos
RichardG
New Contributor II

I have this included in the string variable (rasterLocation). The string variable appears with my personal computer information then \CatchmentDelineation\Layers\

0 Kudos
FC_Basson
MVP Regular Contributor

Do the tool messages give you an indication of the dataset path?

0 Kudos
RichardG
New Contributor II

The Batch Watershed Delineation tool messages says the following;

ERROR 000732 - Dataset %rasterLocation%fdr%HA% does not exist or is not supported.

This is repeated for each input file.

The messages for the individual input files are "The value does not exist"

0 Kudos
FC_Basson
MVP Regular Contributor

Have you tried replacing the rasterLocation variable in your inputs with the actual path to test if it exists and works?

0 Kudos
RichardG
New Contributor II

Thanks for your responses. Yes when I have specified particular files,  the model runs fine and I get the desired output.

0 Kudos
FC_Basson
MVP Regular Contributor

Does the rasterLocation variable need to be of type String?  I would also try using it as a Workspace type variable, then you might need to add an additional forward slash in the dataset path.

0 Kudos
RichardG
New Contributor II

I removed the rasterLocation string variable and added it as a Workspace type variable as you suggested. I named it rasterLocation again and added the forward slash.

The error messages remain.

0 Kudos
RichardG
New Contributor II

I've solved the problem. The Get Value string variable refers to attributes which begin with '0'. I put some text before these attributes and edited the input file names and the model works perfectly now.