2
# Process: Get Raster Properties
Max_Aggl = arcpy.GetRasterProperties_management(EucDist_Aggl, "MAXIMUM", "")
print (Max_Aggl)
print float(Max_Aggl.getOutput(0))
b = int(Max_Aggl.getOutput(0))
c = b/2
print c
delta = int(Max_Aggl.getOutput(0))
print delta
a = delta/1000
print a

This is a part of the code, and the value of Max_Aggl=44250.27734375 (more than 10 digits) and I have error :

44250.27734375 44250.2773438

Traceback (most recent call last): File "D:\NEO\bbbb.py", line 22, in b = int(Max_Aggl.getOutput(0)) ValueError: invalid literal for int() with base 10: '44250.27734375'

you help me first time to convert the result to value

2

It seems that you are returning a string and not a number, and there is no direct conversion from float stored string to int in Python. So you should use :

delta = int(float(Max_Aggl.getOutput(0)))
  • 1
    There can be a direct conversion from string to int in Python - try print int("6") - what you cannot do is use int on a "float stored as a string" i.e. print int("44250.27734375") will give the observed error message – PolyGeo Jan 21 '14 at 7:41

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.