3 Replies Latest reply on Oct 19, 2010 1:52 PM by prokein

    ExtractByMask Error

    chewentao
      Hi,

      ExtractByMask does not work for the following Python:

      import arcpy
      arcpy.CheckOutExtension("spatial")
      tif = "H:\\Test-20100419\\t.tif"
      shp = "H:\\Test-20100419\\A27401_05.shp"
      out_raster = "H:\\Test-20100419\\ttt.tif"
      out = arcpy.sa.ExtractByMask(tif, shp)
      out.save(out_raster)

      Error message:

      Traceback (most recent call last):
        File "H:\Test-20100419\test.py", line 6, in <module>
          out = arcpy.sa.ExtractByMask(tif, shp)
        File "C:\ArcGIS\Desktop9.4\arcpy\arcpy\sa\Functions.py", line 1210, in ExtractByMask
          in_mask_data)
        File "C:\ArcGIS\Desktop9.4\arcpy\arcpy\sa\Utils.py", line 67, in swapper
          result = wrapper(*args, **kwargs)
        File "C:\ArcGIS\Desktop9.4\arcpy\arcpy\sa\Functions.py", line 1204, in wrapper
          out_raster)
        File "C:\ArcGIS\Desktop9.4\arcpy\arcpy\geoprocessing\_base.py", line 438, in <lambda>
          return lambda *args: val(*gp_fixargs(args))
      arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.
      ERROR 000879: Output raster: The length of the stack base name in H:\Test-20100419\Extract_t1 is longer than 9.
      Failed to execute (ExtractByMask).

      I set the output raster as a TIF not a Grid Stack, I can not understand the error message "The length of the stack base name is longer than 9." This is not the case.

      There is no any problem when I use ExtractByMask Tool in ArcToolbox.

      Best regards,

      Wentao

      KKC, Tokyo, Japan
        • ExtractByMask Error
          rdebruyn-esristaff
          HI Wentao

          There seems to be an issue with the name of the temporary raster that is created by the tool. By default you must have a file based scratch workspace set so the format is attempting to create a grid stack(limit 9 characters). 

          Try to set a file geodatabase as your scratch workspace there will not be a name restriction.

          arcpy.env.scratchWorkspace = "c:/data/myfilegdb.gdb"
          out = arcpy.sa.ExtractByMask(tif, shp)
          out.save("C:/output/final_ras")

          Thank you for your input, we will work to remedy the error.

          -Ryan
          ESRI Spatial Analyst Team
          • ExtractByMask Error
            chewentao
            Hi Ryan,

            Thank you for your reply.

            I tried to set scratch workspace and worksapce to :\Test-20100419\myfilegdb.gdb, both are failed.
            Herre is the error message:

              File "H:\Test-20100419\test2.py", line 19, in <module>
                out = arcpy.sa.ExtractByMask(tif, shp)
              File "C:\ArcGIS\Desktop9.4\arcpy\arcpy\sa\Functions.py", line 1210, in ExtractByMask
                in_mask_data)
              File "C:\ArcGIS\Desktop9.4\arcpy\arcpy\sa\Utils.py", line 67, in swapper
                result = wrapper(*args, **kwargs)
              File "C:\ArcGIS\Desktop9.4\arcpy\arcpy\sa\Functions.py", line 1204, in wrapper
                out_raster)
              File "C:\ArcGIS\Desktop9.4\arcpy\arcpy\geoprocessing\_base.py", line 438, in <lambda>
                return lambda *args: val(*gp_fixargs(args))
            arcgisscripting.ExecuteError: ERROR 000875: Output raster: H:\Test-20100419\myfilegdb.gdb\Extract_tif1's workspace is an invalid output workspace.
            ERROR 000581: Invalid parameters.
            Failed to execute (ExtractByMask).

            Wentao
            • Re: ExtractByMask Error
              prokein
              This problem persists in Arc10 Build2414.