matoretta

ExtractByMask doesn´t work (AG 10 SP5)

Discussion created by matoretta on Oct 24, 2012
Hi i have one problem which drive me crazy. i used ExtractByMask which worked fine (SP4) but now i dont know why it doesn´t. any idea? thanks a lot  (see code please  line: pThiessen = ExtractByMask(pThiessenTemp, pMask)   err: 000582 Error occured during execution)

import arcpy
from arcpy.sa import *

def main():
    try:
        arcpy.CheckOutExtension("Spatial")
        arcpy.env.overwriteOutput = True

        inPoints = arcpy.GetParameterAsText(0)
        inField = arcpy.GetParameterAsText(1)
        inType = arcpy.GetParameterAsText(2)
        inMask = arcpy.GetParameterAsText(3)
        inWorkSpace = arcpy.GetParameterAsText(4)

        pMask = Raster(inMask)
        arcpy.env.snapRaster = inMask

        #Nastavenie union extentu body a povodie
        desc = arcpy.Describe(inPoints)
        xmin = min(desc.extent.XMin,pMask.extent.XMin)
        ymin = min(desc.extent.YMin,pMask.extent.YMin)
        xmax = max(desc.extent.XMax,pMask.extent.XMax)
        ymax = max(desc.extent.YMax,pMask.extent.YMax)
        arcpy.env.extent = arcpy.Extent(xmin, ymin, xmax, ymax)
        #Koniec nastavenia extentu
        arcpy.env.mask = inMask
        arcpy.env.cellSize = inMask
        pCellsize = (pMask.meanCellHeight + pMask.meanCellWidth) / 2

        arcpy.env.workspace = inWorkSpace

        if (inWorkSpace.find(".gdb") == -1) | (inWorkSpace.find(".gdb") == -1):
            db = ".shp"
        else:
            db = ""
            if inField == "FID":
                inField = "OBJECTID"

        arcpy.CreateThiessenPolygons_analysis(inPoints, "ThTemp1", "ALL")
        arcpy.FeatureToRaster_conversion("ThTemp1" + db, inField, "thtemp2", pCellsize)
        arcpy.Delete_management("ThTemp1"+ db)
        pThiessenTemp = Raster(inWorkSpace + "\\thtemp2")

        arcpy.ClearEnvironment("extent")
        arcpy.env.extent = pMask.extent 
        pThiessen = ExtractByMask(pThiessenTemp, pMask)
        arcpy.Delete_management(inWorkSpace +"\\thtemp2")

        if inType == "precipitation":
           pThiessen.save(inWorkSpace + "\\thiessen_p")
           Name = "thiessen_p"
        elif inType == "evapotranspiration":
            pThiessen.save(inWorkSpace + "\\thiessen_e")
            Name = "thiessen_e"
        else:
            pThiessen.save(inWorkSpace + "\\thiessen_t")
            Name = "thiessen_t"

        del pMask
        del pThiessenTemp
        del pThiessen
        arcpy.env.snapRaster = None
        arcpy.env.extent = None
        arcpy.env.mask = None
        arcpy.env.cellSize = None

        AddRasterLayerToMap(inWorkSpace, Name)
        arcpy.AddMessage("Script Run Succesfully")
    except Exception as e:
        arcpy.AddError(e.message) 

Outcomes