**import arcpy
from arcpy import env
from arcpy.sa import *
import math
  # Check out any necessary licenses
   # OverwriteOutput
arcpy.env.overwriteOutput = True
   # Set Geoprocessing environments
arcpy.env.autoCommit = "1000"
arcpy.env.scratchWorkspace = "D:\\NEO\\GISMODELLING\\BestLocationsModel.mdb"
# arcpy.env.extent = "214386.1775 3837166.9542 256099.9616 3907138.0305"
arcpy.env.extent = "D:\\NEO\\GISMODELLING\\BestLocationsModel.mdb\WasteWaterPlant\\Tart_UTM"
arcpy.env.cellSize = "10"
arcpy.env.mask = "D:\\NEO\\GISMODELLING\\BestLocationsModel.mdb\\WasteWaterPlant\\Tart_UTM"
arcpy.env.workspace = "D:\\NEO\\GISMODELLING\\BestLocationsModel.mdb\\WasteWaterPlant"
EucDist_Aggl = "D:/NEO/GISMODELLING/BestLocationsModel.mdb/EucDist_Aggl"
# Process: Get Raster Properties
Max_Aggl = arcpy.GetRasterProperties_management(EucDist_Aggl, "MAXIMUM", "")
print Max_Aggl
delta = int (Max_Aggl)
print delta
a = delta/1000
print a**

when I running this code I have this errore


Traceback (most recent call last): File "D:\NEO\test.py", line 28, in delta = int (Max_Aggl) TypeError: int() argument must be a string or a number, not 'Result'

I need to use the value of Max_Aggl in loops

I try to learn Python as I go


As from the ArcGIS help, getRasterProperties() ...

... returns the output values of a tool when it is executed as a Result object. The advantage of a result object is that you can maintain information about the execution of tools, including messages, parameters, and output. These results can be maintained even after several other tools have been run.

you need to get the value of the result using .getOutput(index), which will return your value of interest as an unicode string at index 0. This string can in turn be converted into a numeric variable using float() and int().

print int(float(Max_aggl.getOutput(0)))
  • Thank it's work ,but i have another errore this is the new part of the last code : # Process: Get Raster Properties Max_Aggl = arcpy.GetRasterProperties_management(EucDist_Aggl, "MAXIMUM", "") print (Max_Aggl) print float(Max_Aggl.getOutput(0)) b = float(Max_Aggl.getOutput(0)) c = b/2 print c delta = int(Max_Aggl.getOutput(0)) print delta a = delta/1000 print a the errore is : Traceback (most recent call last): File "D:\NEO\bbbb.py", line 25, in <module> delta = int(Max_Aggl.getOutput(0)) ValueError: invalid literal for int() with base 10: '44250.27734375' – zeanaabed Jan 20 '14 at 12:29
  • and i need all var : delta ,a ,b,c and int() thanks – zeanaabed Jan 20 '14 at 12:33
  • As looking for result object related posts, I came across this. To just completely close this post, you need to cast your string to float first then to int, such as int(float(Max_Aggl.getOutput(0))). – fatih_dur Feb 17 '16 at 1:14
  • @fatih_dur thanks, if the raster is not of integer type, you indeed need float() first. Your suggestion is thus more generic therefore I updated my answer. – radouxju Feb 17 '16 at 8:00
  • thanks @radouxju, in fact the last issue was not about GIS and it would be fair to leave OP to investigate more, but could not help myself, as I said. – fatih_dur Feb 18 '16 at 2:33

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.