Mosaic to New Raster (too simple, but yet wont work)

1287
2
02-14-2013 02:58 AM
DustinEdge
Occasional Contributor
Greetings All

I've been stuck on this for most of this evening and would really like to know why its not working.

I'm doing a MosaicToNewRaster with a bunch of rasters that need to be mosaiced with a particular raster.

All I need is a simple ListRasters to get each raster from the bunch, keep the particular raster in a separate variable, feed the two to the Mosaic tool and it should be sweet.

But no.

At first, the loop script ran without errors, but the results were empty.

So I decided to go back to basics and try to get that to work with two fixed variables
Here's the code:

bathtub = "C:/Temp/dustin.gdb/Coastal_WD_2040"
inRas = "C:/Temp/dustin.gdb/depth_2040"

arcpy.MosaicToNewRaster_management("bathub;inRas","C:/Temp/dustin.gdb", "new_test", "#","32_BIT_FLOAT","#", "1", "MAXIMUM", "REJECT")


But it keeps returning a generic "ERROR 000582: Error occurred during execution"

If I put in the full paths then of course it works...but I need it to loop.

I thought I'd be smart about and get ModelBuilder to show me where I was going wrong.
I built the same two variables and feed it to the tool and it ran with full success.

So I exported the model to python script and guess what? it creates the necessary variables but then does not use them in the tool. Instead it uses the full path #ESRIFAIL

In past readings on this forum, I came across arcpy.Raster() which creates a Raster object from the raster.
I tried that too...and that didn't work.

I subsituted the # for just "" for the optional values and that didn't work either.

I tried every combination of r"", \ and even // for the file paths but still nothing.

Any suggestions?
Tags (2)
0 Kudos
2 Replies
DustinEdge
Occasional Contributor
**UPDATE**

I finally found something that worked.....and it really should be more prominent in all the help documentation involving multiple inputs.

Anyhoo...the arcpy.ValueTable() finally got the script to run.

But surely there is a more straight forward answer to this issue.


Regards
0 Kudos
curtvprice
MVP Esteemed Contributor
A fix I saw: you have your variables in quotes, so they won't be interpreted.
bathtub = "C:/Temp/dustin.gdb/Coastal_WD_2040"
inRas = "C:/Temp/dustin.gdb/depth_2040"

# using a python list
arcpy.MosaicToNewRaster_management([bathub,inRas],
    "C:/Temp/dustin.gdb", "new_test", "#","32_BIT_FLOAT","#", "1", "MAXIMUM", "REJECT")
# this is the "old way" - packing up a ";" delimited string - which will work as well:
arcpy.MosaicToNewRaster_management(bathub + ";" + inRas,
    "C:/Temp/dustin.gdb", "new_test", "#","32_BIT_FLOAT","#", "1", "MAXIMUM", "REJECT")
0 Kudos