Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a code that calculates the sum of water recharge for a pixel for a 9 year period (This piece of code works fine, just thought I would show how it is made just in case. The values range from 0 to 207379mm per 1km cell):

for variable in variables:
    env.workspace = "G:\\Faculty\\Mann\\GFDLA2_BCM\\Aggregated1080"             #   "G:/CA_270m_GFDLA2/Aggregated1080/"    
    scenario = "_A2"    # "" for historical
    # limit to current variable 
    relevant_tifnames = filter(lambda x: str(variable) in x,tifnames)
    print('FOR VARIABLE:'+str(variable))

    for year in base_year[0:1]:        
        print('limiting to '+str(year)+' to '+ str((year+years_to_end)))  # limit to time period of interest 
        relevant_tifnames_year = [v for v in relevant_tifnames if int(re.sub('[^0-9]','',v) or 0) >= year and int(re.sub('[^0-9]','',v) or 0) <= year+years_to_end ]
        period_sum = CellStatistics(relevant_tifnames_year, "SUM", "DATA")
        period_sum2 = Con(period_sum<0,0,period_sum) 

I then want to summarize this data by water shed unit (hydo units range in size from 4108 cells to 25, with 190 units in all):

hydro_units  = Raster("G:\\Faculty\\Mann\\Share\\Environemental Factors\\Watersheds FRAP\\HydroUnit.tif")
# calc sum of recharge for each hydro uni
waterzone = ZonalStatistics(hydro_units  , "Value", period_sum2 , "SUM", "NODATA")

Sends back this error:

Failed to copy raster dataset ERROR 010240: Could not save raster dataset to G:\Faculty\Mann\GFDLA2_BCM\WaterAggregated1080\g_g5214 with output format GRID. Failed to execute (ZonalStatistics).

The same happens with "AVERAGE" or "MINIMUM" etc.

Any thoughts on why this is happening? At first I thought the "SUM" values where too large, but MINIMUM shouldn't have the same issue. Any thoughts?

share|improve this question

1 Answer 1

You get this error if you are trying to write to a location already containing a dataset of the specified name or if the raster format can't take the range of values. Also, the filename 'g_g5214' is the sort of name that ESRI gives temporary geoprocessing rasters.

So it is probably something about the conversion of your hydro-units data from a polygon vector to a temporary raster (on the fly) it doesn't like. You have quoted the size of the hydro_units but what about the total range of their values? If you have a very large number of hydro_units whose values are auto-generated ids, you could be over-running the range allowed by the GRID format (though you would need a very large number of zones to do this as the GRID format can be either 16 or 32 bits - that said, I have done it on occasion, so it's quite possible).

share|improve this answer
    
There are only 190 units. The odd thing is this works when run straight through arcmap, and model builder. But even the python code export from model builder complains. This is arc 10.1. –  mmann1123 Feb 19 '13 at 15:25
    
have you checked to see if there is a 'g-g5214' file sitting in your destination folder (perhaps after a crash). I would expect Arc you create a new name for the temporary file but if it isn't, an old file could be blocking the process. If that's the case, you could try adding "arcpy.OverwriteOutput = True" at the start of the code. –  MappaGnosis Feb 19 '13 at 16:01
    
Anyone else running into this problem in 10.1? I have already tried OverwriteOutput = T and creating an empty scratch folder. Still getting the same error! Even when trying to raster.save in other scripts!!!!!!!!!! This is killing me –  mmann1123 Apr 22 '13 at 18:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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