I am trying to compute a moving window maximum on a raster, such that the output is the max within a 5 mile radius. This should result in an output grid where the maximum is equal to the maximum of the input grid. I am using the FocalStatistics function in spatial analyst,

Here is the code:

import arcpy
from arcpy import env
from arcpy.sa import *
env.extent = "MAXOF"

localMax = FocalStatistics(InRaster, NbrCircle(5, "MAP"), "MAXIMUM")

Pretty straight forward. But if I check that stats: arcpy.GetRasterProperties(localMax, “MAXIMUM”) The value returned is 3.4e+38 (out to lunch), whereas:

arcpy.GetRasterProperties_management(inRaster, “MAXIMUM”)

returns 5.73

I have used this function without problems before – I am out of ideas. Anyone?

edit: inRaster is projected, and the linear unit is Miles (US)

  • Ignore NoData can play tricks
    – FelixIP
    Feb 18, 2016 at 0:47
  • Felix - Good point, I tried with the ignore NoData parameter set to True, and then False. I got the same result! Am I applying this correctly? localMax = FocalStatistics(InRaster, NbrCircle(5, "MAP"), "MAXIMUM", True)
    – Sarobinson
    Feb 18, 2016 at 1:07
  • Further testing, tried both "DATA" and "NODATA" in the ignore NoData parameter. Same result
    – Sarobinson
    Feb 18, 2016 at 1:15
  • If this is standalone script, "MAP" parameter might not work, try CELL
    – FelixIP
    Feb 18, 2016 at 1:32
  • No luck with "CELL" either. I tried both "DATA" and "NODATA" with it as well. Fixed my GetRasterProperies_management in the question. Thanks Felix
    – Sarobinson
    Feb 18, 2016 at 1:47

2 Answers 2


This works perfectly fine

import arcpy
from arcpy.sa import *
localMax = FocalStatistics(inRaster, NbrCircle(5, "MAP"), "MAXIMUM")
result=arcpy.GetRasterProperties_management(localMax, "MAXIMUM")

The only other thing I can think of is environment extent. Does baaad things very often.

UPDATE: tested with wrong extent, get the same "answer" 3.40282e+038

  • Felix - What do you mean "wrong extent?" I set env.extent() before running the script, and the projection is the same for inRaster as the extent raster. Is there something else?
    – Sarobinson
    Feb 18, 2016 at 3:17
  • Set it inside the script env.extent=raster.extent or union of inputs
    – FelixIP
    Feb 18, 2016 at 4:57
  • It sounds like this is the problem, but I am not able to correct. I have tried setting arcpy.env.extent = "MAXOF", and not setting the extent explicitly, like you show in your script above.
    – Sarobinson
    Feb 18, 2016 at 16:37

UPDATE This issue seems to be related to floats. If the input raster is multiplied by 1.0 before running the focal statistics, it yields the expected results.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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