Description
The output raster dataset could not be created in the specified format. There may already exist an output raster with the same name and format. Certain raster formats have limitations on the range of values that are supported. For example, the GIF format only supports a value range of 0 to 255, which would be a problem if the output raster would have a range of -10 to 365.
Solution
Check that a raster with the same name and format does not already exist in the output location. Also, check the Help for the technical specifications of raster dataset formats to make sure that the expected range of values in the output is compatible with the specified format.
Hi,
I am having the same problem when writing GeoTiff files. The files can be saved when I am running in debug mode, but not when running the code outside of debug. I can also save the intermediate file by displaying first in ArcDesktop 10.5 and then exporting to a file. I am calculating the difference between two input (geotiff) Rasters, the results are in type "Double." I have checked to make sure there is not a file of the same name already in existence. I have also tested whether or not using a different geodatabase path makes a difference, it does not. I have check to see if I could just save it to a folder, I cannot. The code is as follows (current_datestr example: 201909101900):
output_file = "T2min_{}".format(current_datestr)
output_file = os.path.join(output_workspace, output_file)
output_file = "{}.tif".format(os.path.splitext(output_file)[0])
if arcpy.Exists(output_file):
arcpy.Delete_management(output_file)
current_raster = Raster(current_raster)
previous_raster = Raster(previous_raster)
# set noData appropriately before subtraction:
arcpy.SetRasterProperties_management(current_raster, nodata="1 -3")
accum = current_raster - previous_raster
output_con = arcpy.sa.Con(accum > 0, accum)
output_con.save(output_file)
Thanks for your help.
Joleen
I think the problem was that I set the nodata value for the current_raster, but forgot to set it for the previous_raster. In addition, I should have calculated accumulation amounts by setting Null values to zero before subtracting.
from arcpy.sa import *
current_raster = Raster(current_raster_name)
previous_raster = Raster(previous_raster_name)
current = SetNull(current_raster, current_raster, "VALUE < 0")
previous = SetNull(previous_raster, previous_raster, "VALUE < 0")
current_raster = Con(IsNull(current), 0, current)
previous_raster = Con(IsNull(previous), 0, previous)
accum = current_raster - previous_raster
out_con = Con(accum > 0, accum)
out_con.save(output_file)