I am new to arcpy and I'm trying to write a script to get the raster and check for the minimum cell size value using Get Raster Properties method.

After I run my code I get a message of the minimum value but the raster is not saved. Below are my line of codes:

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

input_raster= arcpy.GetParameterAsText(0)
output_folder = arcpy.GetParameterAsText(1)

outputgdb = output_folder +"\\output.gdb"+ os.sep

output_con_raster = outputgdb + "cond_raster"

inRas1 = arcpy.Raster(input_raster)
rasterValue = arcpy.GetRasterProperties_management(inRas1,'MINIMUM')
elevation_min= rasterValue.getOutput(0)

Is there anything wrong with my code as the save method is not working?


You are confusing yourself with the naming convention you are using.

rasterValue is a result object.

Your next line returns the output of the result object which will be a number, the minimum value in your raster.

Knowing this then the final line elevation_min.Save(output_con_raster) make absolutely no sense as your syntax is suggesting you are trying to save a raster when in fact you have nothing more than a number (float or integer).

You could write this value to a table?

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.