Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Raster Functions, update specific rasters. (Loop)

$
0
0
Hey all!

I'm trying a script that updates Raster Functions on specific rasters in the mosaic dataset.

The problem is that this code doesn't work when its in a loop.
I need the loop to make different querys depending on the raster that needs to be updated.

The first loop works great. OBJECTID=1 gets updated with correct settings.

Code:

Executing: EditRasterFunction Templayer EDIT_MOSAIC_DATASET_ITEM REPLACE W:\XMLTEMPLATE\4250_50_ii12.xml #
Start Time: Wed Apr 24 17:08:09 2013
Working on AMD_image_CAT\Raster.OBJECTID = 1
Succeeded at Wed Apr 24 17:08:11 2013 (Elapsed Time: 2,00 seconds)

On the second loop (OBJECTID=2) it crashes on arcpy.MakeMosaicLayer_management().

Code:

ERROR 000622: Failed to execute (Make Mosaic Layer). Parameters are not valid.
ERROR 000628: Cannot set input into parameter in_mosaic_dataset.

Do i need to clear the Templayer somehow? Or what im i doing wrong?

Code:

# variables for test..
TEMPLATE = "URLToTemplate.xml"
env.workspace = "C:\awsomeimages.gdb"
MOSAIC_DATASET = "image"

try:
        QUERY = "OBJECTID="+str(OBJECTID)
        TEMPLAYER = "Templayer"
        arcpy.MakeMosaicLayer_management( MOSAIC_DATASET,TEMPLAYER,QUERY )
        arcpy.EditRasterFunction_management( TEMPLAYER,"EDIT_MOSAIC_DATASET_ITEM","REPLACE",TEMPLATE )
except:
        print arcpy.GetMessages()

Best regards,

Viewing all articles
Browse latest Browse all 2485

Trending Articles