Select to view content in your preferred language

Median no longer available for Focal Statistics

1186
7
10-07-2011 08:07 AM
MichaelDenslow
Emerging Contributor
I am using ArcGIS 10 SP2

When I was using 9.x, I used to use Neighborhood Statistics to calculate the a focal median.

It looks like the tool is now called Focal Statistics. Once I choose my input file (a DEM) the median option is no longer available for Wedge type neighborhood (possibly other types as well). Am I missing something here?

Thanks in advance,
0 Kudos
7 Replies
Robert_LeClair
Esri Notable Contributor
Michael -

From the Focal Stats help - "If the input raster is of floating point type, only the Mean, Maximum, Minimum, Range, STD, and Sum statistics are available; the Majority, Minority, Median and Variety statistics are not permitted. If the input raster is of integer type, all the statistics types are available."

Question - is your DEM a floating point type raster?  If so, then you use the INT geoprocessing tool to change the cell format to integer and then run the Focal Stats tool for the median statistic type.

Hope this helps,

Robert LeClair
Esri-Denver
0 Kudos
MichaelDenslow
Emerging Contributor
Thanks you nailed it (my Raster is Float). Though I do think this is a change in behavior from 9.x.
I need to think about whether I would really want to convert to Integer.

I am not really sure why this should matter. The median is the median right?

Regardless, thanks for your help,
0 Kudos
Robert_LeClair
Esri Notable Contributor
Michael - glad it helped but it still made me curious why the change with regard to integer and floating point.  I pulled up the 9.3 Desktop Help and there's GP tools for FocalMedian as well as FocalStatistics - http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=FocalMedian that will work with integer or floating point rasters.

Not 100% sure why floating point rasters were removed from this statistic type but I did find a related forum article whereby Bill Huber explains a little about the logic - http://forums.arcgis.com/threads/14213-neighborhood-focal-statistics....-without-the-statistics  The "cliff" note version is that floating point rasters will support an attribute table and integer rasters do.
0 Kudos
DaveGalbraith
Emerging Contributor
Floating point base-10 data is fundamentally evil for machines to run if their operating system is based on binary code structure.

Don't forget to add 0.5 to your grids before applying the INT function, lest you wind up with a truncated rather than a rounded output.
0 Kudos
EricRice
Esri Regular Contributor
INT truncates no matter what you add.  4.2 and 4.9 would both become 4.  If you need to round, see Round Up or Round Down tools.

Regards,
Eric
0 Kudos
Luke_Pinner
MVP Regular Contributor
Eric, if you add 0.5 before truncating with INT, you will get values rounded to the nearest whole integer (ignoring any binary floating point issues and which way to round negative ties).

Using your example (4.2 and 4.9)... as 4.7+0.5 = 4.7 and 4.9 + 0.5 = 5.4, int(4.2 + 0.5) == 4 and int(4.9 + 0.5) == 5
0 Kudos
EricRice
Esri Regular Contributor
Thanks for pointing that out.  Obviously I didn't quite think that response through all the way. 😮

Eric
0 Kudos