I am trying to run various tools on a large number of rasters beginning with Project Raster but the last raster is always missed and so the output has one less raster in it. The model appears to run successfully with no errors given. All rasters were previously defined successfully using the raster iterator.
Below is my model I am using to project my rasters and also convert them from ASCII to Esri Grid in the process. Because I want to maintain the names of the rasters I am using in-line substitution. Normally I would use the %name% in-line substitution but this also includes the .asc file extension which prevents converting to Esri Grid as this output format is specified by a lack of an extension. So instead I am using Parse Path with name chosen as the Parse Type so that %value% can be used as in-line substitution for the original file name without the extension.
All seems well at this point, but when I run the model all but the last raster are output by the model (all rasters are named with four numbers, e.g. 1457). I was able to successfully project the missing rasters individually but then I discovered that all the rasters outputted by the model had been given the wrong names. It seems that the name is applied to raster that's next on the list instead of the actual raster it belongs to.
Biggest clue I've found so far is that it only occurs when using Parse Path. But as I mentioned above, if I just use %name% without Parse Path I won't be able to convert to Esri Grid, and if I choose another format such as TIFF my file names will be exampleraster.asc.tif which causes more problems down the line because of the double file extension.
I have been able to reproduce this problem with multiple folders of rasters and when I remove the 'problem raster' that was skipped and run the model again it then repeats the problem again and skips the next last raster. The same issue occurs with other tools I need to use such as Raster to Polygon. I have had the exact same problem using ArcMap 10.6.1 and 10.4.1.
Not sure if this is useful or not but the problem doesn't occur if the folder only contains one raster, but does occur when it contains two.
Summary:
Does anyone know what might be going on or any workarounds? I am a relative beginner to GIS so I have no experience with Python at present but I suspect I may have to teach myself soon.
Solved! Go to Solution.
Try making the output of parse path a precondition to your project raster tool. This means you want parse path tool to run before the project raster tool.
Try making the output of parse path a precondition to your project raster tool. This means you want parse path tool to run before the project raster tool.
I am sure this is right on, especially because of MY candidate for the biggest clue:
It seems that the name is applied to raster that's next on the list instead of the actual raster it belongs to.