How can i save raster data in arcpy

by stasha   Last Updated April 05, 2017 10:22 AM

I am new to arccpy 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)

arcpy.CreateFileGDB_management(output_folder,"output.gdb")
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)
elevation_min.Save(output_con_raster)

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

Tags : arcpy raster save


Answers 1


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?

Hornbydd
Hornbydd
April 05, 2017 11:03 AM

Related Questions



Map Algebra loop only creating one raster

Updated August 02, 2018 20:22 PM

Saving rasters in Arcpy loop

Updated August 07, 2018 00:22 AM


Change a script to run over subfolders

Updated May 11, 2017 13:22 PM