0

I'm trying to run 'Mosaic to New Raster' iteratively across 500 raster pairs in ArcGIS ModelBuilder. Either this tool or my model is not working. Intuitively, the model is correctly specified, but in reality it is not fully specified according to ModelBuilder, so it won't run!

DETAILS OF THE GOAL AND ISSUE: I have two sets of geotif rasters - 500 rasters in Folder1 and another 500 in Folder2. The rasters in Folder1 and in Folder2 have the same file names and differ only with respect to spatial location. For a given pair of rasters having a given file name (e.g., raster1.tif), I want to run the Mosiac to New Raster tool in ModelBuilder to create a output geotif with the same file name as its input rasters. Schematically, this would look like this:

Mosaic to New Raster (1st iteration)

  • Input1: Folder1 > Raster1.tif
  • Input2: Folder2 > Raster1.tif
  • Output: OutputFolder > Raster1.tif

...and so on...

Mosaic to New Raster (500th iteration)

  • Input1: Folder1 > Raster500.tif
  • Input2: Folder2 > Raster500.tif
  • Output: OutputFolder > Raster500.tif

I have tried creating a model in ModelBuilder to this end. See the picture of the same. As you can see, I used the 'Iterate Raster' tool to iterate over each of the 500 rasters in Folder1 by raster file name. The iterator directly specifies the first raster of a given raster pair in the Mosaic to New Raster tool. The raster name variable of Iterate Rasters tool, %Name%, serves to specify the second input raster of the pair as C:...Folder2\%Name% in the Mosaic to New Raster tool. The latter input is not recognised by the Mosaic to New Raster tool, however, so the tool remains unspecified and cannot run.

I don't know anything about Python scripts so hope for a solution that can run in ModelBuilder.

View of the Model in ModelBuilder, Described in this Post

2 Answers 2

1

Hold your cursor over Name bubble, and note whether you see Raster1 or Raster1.tif. I suspect you need to complete the input name by adding .tif after %Name%. Also from your screen shot you have not completed all mandatory parameters, that's what the red stars are indicating.

1

Thanks for your comments Hornbydd and PolyGeo.

I solved this issue and post and explain the correctly specified and functional model here. The problem in the original model was indeed due to file extensions mis-specified in the model, despite my best efforts and intuitive assumptions of what 'should be' workable in ModelBuilder. It seems that the tools were adding their own sauce to my soup and spoiling my efforts.

Specifically, given that the 'Name' inline variable of the Iterate Rasters tool would correctly read 'raster1.tif' when the mouse hovers over it in ModelBuilder, and so on this basis upon inputting Folder2\Raster1.tif into the Mosaic to New Raster tool as 'C:\...\Folder2\%Name%', the Mosaic to New Raster tool would appear specified in ModelBuilder and run, but ultimately would call upon a non-existent raster 'C:\...\Folder2\%Name%.tif.tif' when run. Crazy! As no raster by this name exist, the corresponding output mosaicked raster would be comprised of only C:\...\Folder1\Raster1.tif - there was no Folder2\Raster1.tif involved in the mosaic.

The solution was to link the Iterate Rasters tool with the 'Parse Path' tool, specify this latter tool as a precondition to the Mosaic to New Raster tool, and use the the Parse Path variable 'raster file name without extension' (renamed and shown as 'Name_NoExtension') as an inline variable in the Mosaic to New Raster tool. Specifically, in the Mosaic to New Raster tool, I had to specify Folder2\Raster1.tif as 'C:\...\Folder2\%Name_NoExtension%.tif'. I similarly specified the output mosaic raster as 'C:\...\OutputFolder\Output_%Name_NoExtension%.tif' to avoid the output file name reading '...tif.tif', as would have been the case if the output where specified instead as '\Output_%Name%.tif' - a necessity if %Name% were specified since the Mosaic to New Raster tool demanded that a file extension be typed directly within the tool.

In sum, it was a very easy fix to a very tedious and non-intuitive issue!

Final Specified and Functional Model

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.