Skip to main content
edited tags
Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345
added more detail
Source Link
mmann1123
  • 591
  • 7
  • 16

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?

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):

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?

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?

Source Link
mmann1123
  • 591
  • 7
  • 16

Error 010240 with ZonalStatistics

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):

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?