The Below script is designed to take all raster (.txt ascii rasters) in a specified folder, add them to a list with the file paths, use the file paths stored in the list in the cell statistics tool to get the mean. The script then iterates on to the next folder until the while function is satisfied. There is a folder for every year from 1969 - 2014.

This script has previously ran successfully, and i am sure i haven't changed anything since i last ran it but today when i ran it i got the error:

"ERROR 000864: Input raster's or constant values: The input is not within the defined domain."

This error usually is regarding to complications with floating bit and integer but i thought that Cell Statistics could handle both types - i have also completed cell statistics on these raster's manually so i know they can be used.

Arcpy indicates the error is on line 23 which is the cell statistics part of the code.

import arcpy
import numpy
import os

file = 1969 #Set the starting year as a variable 

while file <=2014:  # set the loop to run up to the year 2014

    endPath = str(file)#get the starting eyar as a string

    #get the contents of the folderstructure in a list
    dirListing = os.listdir('C:\\Users\\Desktop\\MetOffice\\MetOffice Data\\'+ endPath)

    file_Path = 'C:\\Users\\Desktop\\MetOffice\\MetOffice Data\\'+ endPath + '\\'
    file_Path_ext = [file_Path + x for x in dirListing] 
    #get the full file path for each of the files and join it to the files. 

    #Output Location for the processed shapefiles
    output = "C:\\Users\\Desktop\\MetOffice\\ProcessedData\\"+endPath+".tif" 

   # Process: Cell Statistics
   arcpy.gp.CellStatistics_sa(dirListing, output, "MEAN", "DATA")
   file = file + 1 #add one to the year to start the next loop and move 
   through the folders
   print(endPath + " Completed" + ", " + str(2015 - file) +" Remaining")#print a update

print("All Years Completed")#tell the user when the task is completed

Your Answer

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

Browse other questions tagged or ask your own question.