1

I have multiple rasters saved in "Zonal.gdb". All the rasters in "Zonal.gdb" and "TownWilson_PrjUTM" have projected coordinates "WGS_1984_UTM_Zone_15N". I want to clip each raster to the extent in the shapefile (TownWilson_PrjUTM) and resample to 10 meter resolution and estimate zonal statistics as shown in the code below.

I am getting an error as shown below. Cannot understand why I am getting the error even though I have projected rasters and shapefile to the same projected coordinates.

Can somebody help me to figure this out?

import arcpy, os, arcinfo
from arcpy import env
from arcpy.sa import *


arcpy.env.overwriteOutput = True
arcpy.CheckOutExtension("Spatial")
env.workspace = "H:/Arkansas_Flood/Zonal.gdb"
watershedFeat = "H:/Arkansas_Flood/Zonal.gdb/TownWilson_PrjUTM"
outDir = "H:/Table/"

for raster in arcpy.ListRasters(): 
    raster_name = os.path.basename(raster).rstrip(os.path.splitext(raster)[1])
    ## Clip Raster Dataset by known extent - Left Bottom Right Top
    clip_raster = arcpy.Clip_management(raster, "231366.658400 4140371.653300 280675.622100 4180783.072200", "#", "#", "#", "NONE") # with TownWilson_Prj
    # Process: Project Raster
    finalras = arcpy.Resample_management(clip_raster, "#", "10", "BILINEAR")
    outTable = outDir + raster_name + "_TBL.dbf"
    arcpy.gp.ZonalStatisticsAsTable(watershedFeat,"T_R", finalras, outTable,"NODATA","MEAN") # DATA for precipitation, NODATA for RZSM


arcpy.CheckInExtension("Spatial")

> Error:
> 
> Executing: zonalMeanRev Start Time: Thu Jan 04 23:50:02 2018 Running
> script zonalMeanRev... Failed script zonalMeanRev...
> 
>     Traceback (most recent call last):   File "C:\Users\jayaskeradl\Desktop\Arkansas_
> Flood\My_Phyton_Scripts\zonal_mean_rev.py", line 46, in <module>
>     clip_raster = arcpy.Clip_management(raster, "231366.658400 4140371.653300 280675.622100 4180783.072200", "#", "#", "#", "NONE") # with TownWilson_Prj   File "c:\program files
> (x86)\arcgis\desktop10.4\arcpy\arcpy\management.py", line 13771, in
> Clip
>     raise e ExecuteError: ERROR 000622: Failed to execute (Clip). Parameters are not valid. ERROR 000628: Cannot set input into
> parameter in_raster.
> 
> 
> Failed to execute (zonalMeanRev).
> 
> 
> Traceback (most recent call last):   File
> "C:\Users\jayaskeradl\Desktop\Arkansas_
> Flood\My_Phyton_Scripts\zonal_mean_rev.py", line 46, in <module>
>     clip_raster = arcpy.Clip_management(raster, "231366.658400 4140371.653300 280675.622100 4180783.072200", "#", "#", "#", "NONE") # with TownWilson_Prj   File "c:\program files
> (x86)\arcgis\desktop10.4\arcpy\arcpy\management.py", line 13771, in
> Clip
>     raise e ExecuteError: ERROR 999999: Error executing function. The table already exists. No spatial reference exists. Failed to execute
> (Clip).
> 
> 
> Failed to execute (zonalMeanRev).


Traceback (most recent call last):
  File "C:\Users\jayaskeradl\Desktop\Arkansas_ Flood\My_Phyton_Scripts\zonal_mean_rev.py", line 53, in <module>
    finalras = arcpy.Resample_management("H:/Arkansas_Flood/Zonal.gdb/newRaster", "#", "10", "BILINEAR")
  File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\management.py", line 14243, in Resample
    raise e
ExecuteError: ERROR 999999: Error executing function.
The table already exists.
No spatial reference exists.
The table was not found. [VAT_newRaster]
Failed to execute (Resample).


Failed to execute (zonalMeanRev).
2

Looks like you are missing the out_raster parameter:

enter image description here

Try something like:

clip_raster = arcpy.Clip_management(raster, "231366.658400 4140371.653300 280675.622100 4180783.072200", "H:/Arkansas_Flood/Zonal.gdb/newRaster", "#", "#", "NONE")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.