Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I want to divide every cell of a raster by the raster's maximum cell value using ArcPy. Here is what I have done so far.

densityRaster = LineDensity(shapefileName, None, "", "", "")
maxVal = arcpy.GetRasterProperties_management(densityRaster ,"MAXIMUM")
normalRaster = densityRaster/maxVal #maxValue i get is 5.66

This gives me an error described below. Anybody has clues to where I get it wrong?

Runtime error : ERROR 000732: Input Raster: Dataset 5.666 does not exist or is not supported

If I enter normalRaster = densityRaster/5.666, I get the correct result.

share|improve this question
1  
On a side note, you should be able to get the maximum value by accessing the maximum property from your densityRaster since it's a raster object. –  dmahr Jun 27 '13 at 13:41
    
@dmahr - nice tip! i would try that..i have just put my feet into arcpy :) –  vinayan Jun 28 '13 at 11:43

1 Answer 1

up vote 2 down vote accepted

If you look at type(maxVal), you'll notice that it's neither a number or string. As a matter of fact, it is a ArcPy result object.

In order to extract that information use .getOutput(0). You can cast it to whatever type (int,float,etc) if you want as well.

share|improve this answer
1  
you are damn right! i didn't check the type..i can get it to work with float(maxVal[0]) now.. –  vinayan Jun 26 '13 at 18:29
    
+1 I didn't know it could be accessed like that actually. I thought you had to use .getOutput(0). Honestly, I don't know why some tools return a result object and not just the actual result. –  Paul Jun 26 '13 at 18:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.