Select to view content in your preferred language

Extract by Attributes error with extract.save

2721
6
04-11-2012 12:04 PM
AnneRiddle
Emerging Contributor
On the following code block (specifically, the last line), IDLE throws this error:

ERROR 010093: Output raster format UNKNOWN is unsupported.

for raster in arcpy.ListRasters(): 
    outpoint = workspace + raster + "af"
    extract = arcpy.sa.ExtractByAttributes (raster, " VALUE = 6 OR VALUE = 8")
    extract.save (outpoint)


I feel like it shouldn't be necessary to specify a format since the output is saving into a geodatabase. Also, is there better documentation on extract.save somewhere? I've found very little on it and am just imitating the syntax example used on the Extract by Attributes tool page.
Tags (2)
0 Kudos
6 Replies
MarcinGasior
Frequent Contributor
Based on your script I created this one:
import arcpy
arcpy.CheckOutExtension("Spatial")

workspace = "C:/tmp/Testing.gdb"
arcpy.env.workspace = workspace

try:
    for raster in arcpy.ListRasters():
        outpoint = workspace + "/" + raster + "af"
        extract = arcpy.sa.ExtractByAttributes(raster, "VALUE = 6 OR VALUE = 8")
        extract.save(outpoint)
except:
    arcpy.GetMessages()

Works.
0 Kudos
AnneRiddle
Emerging Contributor
This was basically the same as the script I had, with the addition of the backslash. Mine looks like this:


arcpy.env.workspace = r"S:\FIRE\86to92.gdb"
workspace = arcpy.env.workspace

outtable = r"S:\FIRE\73to80.gdb\y86to92"

for raster in arcpy.ListRasters(): 
    outpoint = workspace + "/" + raster + "af"
    extract = arcpy.sa.ExtractByAttributes (raster, " VALUE = 6 OR VALUE = 8")
    extract.save (outpoint)


However, now I am getting this error message:

Traceback (most recent call last):
  File "S:\FIRE\gdb.py", line 33, in <module>
    extract = arcpy.sa.ExtractByAttributes (raster, " VALUE = 6 OR VALUE = 8")
  File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\sa\Functions.py", line 1117, in ExtractByAttributes
    where_clause)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\sa\Utils.py", line 47, in swapper
    result = wrapper(*args, **kwargs)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\sa\Functions.py", line 1113, in wrapper
    out_raster)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 474, in <lambda>
    return lambda *args: val(*gp_fixargs(args))
ExecuteError: ERROR 999999: Error executing function.
Access denied
Access denied [GDB_Items]
No spatial reference exists.
ERROR 010302: Unable to create the output raster: S:\FIRE\86to92.gdb\Extract_u8001
ERROR 010067: Error in executing grid expression.
Failed to execute (ExtractByAttributes).


ERROR 010302 suggests that I don't have write permission or don't have enough space available. I checked and both of these are OK.
0 Kudos
toddsams
Deactivated User
I am getting the same error as the original post on this thread (ERROR 010093). I tried changing my os.sep to "/" but still get the error. My code is below, the error occurs on the FdrOut.save line:

for HUC in HUCs:
    print HUC
    try:
        FDRpath = Main + os.sep + "fdr"
        FACpath = Main + os.sep + "fac"
        print FDRpath
        print FACpath
        # Execute ExtractByMask
        FdrOut = ExtractByMask(MainFdr, HUC)
        # Save the output 
        FdrOut.save(FDRpath + "/" + "fdr_" + HUC)
        print "fdr finished"
    except:
        print "error_" + HUC
        continue
0 Kudos
MarcinGasior
Frequent Contributor
I believe you shold use "\" instead of "/" in this line.

BTW, os module prowides very convenient method for constructing pathes - join. In your case it will be:
outRaster = os.path.join(FDRpath, "fdr_" + "HUC")
FdrOut.save(outRaster)

The same way you can construct FDRpath and FACpath variables.
0 Kudos
curtvprice
MVP Esteemed Contributor
A few things to keep in mind:


  • Although Spatial Analyst tools now do direct read/write of many formats, grid (folder workspace) is usually still the best choice.

  • The workspace and scratchWorkspace should be set to the same folder for best performance.

  • Grid format is limited to 13-characters, alphanumeric + "_", starting with a letter.

  • Workspace, feature class, table, and field names should never begin with a number.

0 Kudos
ThomasLaxson
Occasional Contributor
This error (010093) often occurs when trying to create an improperly named raster file. For GRIDs, the naming restrictions include:

...a grid should not be named with spaces or any other special characters in its name. A multiple-band grid cannot have more than 9 characters in its file name, and a single-band raster dataset cannot have more than 13 characters.


Todd, this probably applies in your case, if you're using HUC 12s; the appending of your four characters ('fdr_') puts you over the 13 character limit.

See ESRI's help page on GRIDs for more info.
0 Kudos