Passing variable value into MosaicToNewRaster (python)

1881
0
10-23-2014 10:23 AM
MikeKnowles
New Contributor

I have the following for loop which subsets 420 DEM's into 20 DEM's.:

 

for i in range(0,420,21):

    low = i

    high = i + 21

    interval = high / 21

    AK_in = 'str_dems_AK' + str(interval)

    AK_out = 'NED_AK' + str(interval)

    subset_AK = AK_in + ' = str_dems_AK[' + str(low) + ':' + str(high) + ']'

    exec subset_AK

   

    arcpy.MosaicToNewRaster_management(AK_in, r"H:\dmf\pds\ned\grid\raster_mosaics", AK_out, "", "", "", "1", "", "")

    arcpy.BuildPyramids_management(AK_out, "", "", "", "", "", "SKIP_EXISTING")

 

which results in the following error:

 

Traceback (most recent call last):

  File "H:\NED_BuildPyramids_Mosaic_test.py", line 85, in <module>

arcpy.MosaicToNewRaster_management(AK_in, r"H:\dmf\pds\ned\grid\raster_mosaics", AK_out, "", "", "", "1", "", "")

  File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\management.py", line 11619, in MosaicToNewRaster

    raise e

ExecuteError: ERROR 000582: Error occurred during execution.

 

If I manually run the following command it works so I assume the problem is passing the value of “AK_out” into the mosaic command:

arcpy.MosaicToNewRaster_management(AK_in, r"H:\dmf\pds\ned\grid\raster_mosaics",”NED_AK1”, "", "", "", "1", "", "")

 

If have tried a variety of alternatives but I always get an error so I'm hoping that someone can tell me how to (a) pass the value of AK_out into the mosiac command or (b) if that's not the problem, identify what is causing the eror.

 

Thanks,
Mike.

0 Kudos
0 Replies