Select to view content in your preferred language

"ERROR 160331: The table name is invalid" ModelBuilder When using several CREATE RANDOM RASTER simultaneously

215
2
a week ago
Labels (1)
MicaelBerg
New Contributor

Hi I'm a student and need to use the model builder so please don't answer for me to use Arcpy instead.

I'm trying to do a Monte Carlo simulation for NDVI change between 2 dates. The short is that when i use Create Random Raster, I need 4 of them because I have red, NIR bands for date 1 and date 2. BUT when I try to use the scratch.gdb or my model geodatabase as my output location, it adds on (1), (2), (3) at the end every time i write scratch.gdb in a new create random raster tool. I've tried ai to answer this issue and it says its a common iteration bug using create random raster. 

Is there a way to fix this in model builder? Or am i overthinking it and should just use 1 create random raster to bypass this whole issue?

0 Kudos
2 Replies
MErikReedAugusta
MVP Regular Contributor

I'm not familiar with Create Random Raster personally, but pulling up its entry in the online documentation (you don't specify your Pro version, so I just pulled the latest, 3.7), I can see that the second input variable is the name of the raster.

If you're getting results that have numbers in parentheses after the name, that's not actually a bug.  It means each run of the tool is trying to use the same name, finding that name is already taken by another file, and adding numbers to avoid overwriting the existing file.

  • Input Name: "RasterResult.tif"
  • Iteration 1:
    • Create "RasterResult.tif"
  • Iteration 2:
    • ERROR: "RasterResult.tif" exists.
    • Create "RasterResult (1).tif"
  • Iteration 3:
    • ERROR: "RasterResult.tif" exists.
    • ERROR: "RasterResult (1).tif" exists.
    • Create "RasterResult (2).tif"
  • Iteration 4:
    • ERROR: "RasterResult.tif" exists.
    • ERROR: "RasterResult (1).tif" exists.
    • ERROR: "RasterResult (2).tif" exists.
    • Create "RasterResult (3).tif"
  • Final Results (4 files):
    • "RasterResult.tif"
    • "RasterResult (1).tif"
    • "RasterResult (2).tif"
    • "RasterResult (3).tif"

In Iterations 2–4, there already existed a file called "RasterResult.tif", so it helpfully added a number so you knew that the file that iteration created was different.

Model Builder should be able to use inline variables to change those names, if you'd like the names to indicate what iteration they're in, and/or so you know what name to expect downstream in the model.  But if that's not necessary for what you're doing, you can just leave these names with the numbers; that's why ArcGIS does that automatically.

Whenever you're iterating a given tool multiple times (whether in Model Builder, Python, or as a Batch Tool), always be careful of any inputs that include a filename.  Some tools are able to automatically rename results so they don't collide, but that means you might get names you're not expecting.  Other tools will simply fail because the name is already claimed.

------------------------------
M Reed
"The pessimist may be right oftener than the optimist, but the optimist has more fun, and neither can stop the march of events anyhow." — Lazarus Long, in Time Enough for Love, by Robert A. Heinlein
0 Kudos
MicaelBerg
New Contributor

Thank you for such a structured response. 
The particular issue is that the files aren't the issue. I have a %Value% for changing the names of the files. The problem is that it's putting (1) in my geodatabase basically creating new databases for each entry instead of just saving to the database that I'm using. I tried creating a new variable as Workplace, and tried using my scratch.gdb but even those arcpro just doesn't want to save onto them, creating a separate database each time the tool runs, which gives me errors and doesn't complete the pathway.

0 Kudos