Select to view content in your preferred language

Mosaic a list of grids fails arcpy - Solved

2301
4
10-20-2014 08:00 AM
RafaelAnleu
Emerging Contributor

Hi, I am trying to mosaic a list of grids with arcpy.MosaicToNewRaster_management but keep getting a series of errors, no matter what I try. My problem seems to lie on the input rasters. Since I need to mosaic a series of grids, then the input becomes a multi value input, thus I have tried the three ways suggested by ArcGIS Desktop . Yes I am working with ArcGis 10.0

So, first thing with Python List:

ERROR 000157: Input and target dataset should have the same number of bands

Whith following code:

dem_list = ["path1\\grid1;path2\\grid2"]

arcpy.MosaicToNewRaster_management(dem_list, target_gdb, "mos_wat", varGeo_SpatRef, "32_BIT_FLOAT", "", "1", "MEAN", "REJECT")

Now, with Value Table

ERROR 000732: Input Rasters: Dataset F:\FLOODS_USA\A_FLOODS\DEM_SRTM\ADEM_10mUSA_Neue\n25w081\grdn25w081_13;F:\FLOODS_USA\A_FLOODS\DEM_SRTM\ADEM_10mUSA_Neue\n25w081\grdn25w082_13 does not exist or is not supported

Whith following code:

dem1 = "path1\\grid1"

dem2 = "path2\\grid2"

vt = arcpy.ValueTable(1)

vt.addRow(dem1)

vt.addRow(dem2)

arcpy.MosaicToNewRaster_management(vt, a_gdb, "mos_wat", varGeo_SpatRef, "32_BIT_FLOAT", "", "1", "MEAN", "REJECT")

Finally with String

ERROR 000157: Input and target dataset should have the same number of bands

Whith following code:

dem_list = "path1\\grid1;path2\\grid2"

arcpy.MosaicToNewRaster_management(dem_list, target_gdb, "mos_wat", varGeo_SpatRef, "32_BIT_FLOAT", "", "1", "MEAN", "REJECT")

For all three cases, if I print the input variable it seems to be in the correct format as bellow

path1\grid1;path2\grid2

I have also tried wraping it in quotes as to have

"path1\grid1;path2\grid2"

and I get the same problem. I have of course searched for answers here and somewhere else, and I find no definitive answer to it, since everything points to what I have already tried without success. I would appreciate any help here. By the way: paths, bands, type and projection are all OK.

0 Kudos
4 Replies
DanPatterson_Retired
MVP Emeritus

And you are emulating the script in the help topic exactly?n  I would recommend doing it manually, then get to the Results window and check the syntax there which you can use as part of your python script as a code snippet

0 Kudos
RafaelAnleu
Emerging Contributor

I actually started with a Model on Model Builder (as I usually do), after it worked I exported to Python and begann to edit it. It came out as follows:

arcpy.MosaicToNewRaster_management("full_path1\\grid1;full_path2\\grid2", target_dir.... )

when I make a print out of any of my three options, it comes out as the input above, unless there is some hidden character which I doubt, and that is what is most mind boggling.

0 Kudos
DanPatterson_Retired
MVP Emeritus

do it in ArcToolbox setting your Environments within the option at the bottom of the tool itself, then go to the Results window.  If it works in Arctoolbox, then there may be Environment options that aren't getting carried over in the translation to a script

RafaelAnleu
Emerging Contributor

So, I managed to solve the issue. My problem was the "separator". I was using " ; " instead of " , " thus the input was being interpreted as one single file. Thanks Dan by the way.

0 Kudos