for raster in arcpy.ListRasters(): outpoint = workspace + raster + "af" extract = arcpy.sa.ExtractByAttributes (raster, " VALUE = 6 OR VALUE = 8") extract.save (outpoint)
...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.
outRaster = os.path.join(FDRpath, "fdr_" + "HUC") FdrOut.save(outRaster)
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
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)
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).
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()
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.