Focal statistics problem

5222
5
04-18-2012 06:46 AM
NeilAyres
MVP Alum
I have some DEM (elevation raster) data in a file geoDB.
Its a bit noisy, so I wanted to fiddle with some filters to try and "improve" it a little.

The spatial ref is UTM metres. Its a 32bit float, with a perfectly normal range of values (from 250m up 560m).
It has LZ77 compression and stats and pyramids are done.

So I opened the Focal stats tool to do a bit of processing.
But when I enter the raster name at the top, the list of avalable statistics for the output automatically shortens and only leaves the Mean, Min, Max, Range, Std & Sum options.
The other options which dissappear are Majority, Minority, Median & Variety.

Of course I want to put a median filter through this data but can't.

Can anybody tell me why the tool will not let me run the focal process with the MEDIAN option selected?
Been scratching my head for 1hr already, and I am sure I have sucessfully used a median filter before, but can't now!!!

Thanks in anticipation,
Neil

Oh and I'm on Arc10 SP3, Win7 Pro 64bit
0 Kudos
5 Replies
SteveLynch
Esri Regular Contributor
Neil

Have you looked in the tool's help?

Steve
0 Kudos
NeilAyres
MVP Alum
Thanks Steve,
I have looked at the tool help.
Also did some searching here.
Found my answer. Stats like Majority, Minority & Median are not avaialble for float type data.
Well I can sort of understand why this is, but the help I have seen certainly does not make it obvious.
So, if you are a HELP documentor at ESRI, please add the large red letters -  These filters not available for float type data

So you have to convert to an INT type, then do the median filter, then convert back.
Something like this:

INT(DEM * 100 + 0.5) # lets try and keep detail down to the cm level. The + 0.5 ensures that the INT rounds rather than truncates.
Run the FocalStats (Median) filter (in my case a 7 X 7 cell window).
Then run raster calculator again to divide the ouput by 100 to get back to float.

Okay, got my answer.
Thanks to all who might have even pondered replying.
Cheers,
Neil
0 Kudos
NeilAyres
MVP Alum
Just had another look at the help for "How Focal Statistics Works":
Note that it says "if the input is integer ...., if the input is float...."


Statistics type
The available Focal Statistics statistics are majority, maximum, mean, median, minimum, minority, range, standard deviation, and sum. The default statistics type is mean.

Majority
If the input raster is integer, the values on the output raster will be integer; if the values on the input are floating point, the values on the output will be floating point.
When there is more than one majority value within a neighborhood, the processing cell location will receive NoData on the output.
Maximum
If the input raster is integer, the values on the output raster will be integer; if the values on the input are floating point, the values on the output will be floating point.
Mean
The output raster will always be floating point.
The mean statistic can be used with the weight neighborhood type.
Median
If the input raster is integer, the values on the output raster will be integer; if the values on the input are floating point, the values on the output will be floating point.
When the number of valid cell values in the neighborhood is odd, the median value is calculated by ranking the values and selecting the middle value. If the number of values in a neighborhood is even, the values will be ranked and the middle two values will be averaged.
Minimum
If the input raster is integer, the values on the output raster will be integer; if the values on the input are floating point, the values on the output will be floating point.
Minority
If the input raster is integer, the values on the output raster will be integer; if the values on the input are floating point, the values on the output will be floating point.
When there is more than one minority value within a neighborhood, the processing cell location will receive NoData on the output.
Range
If the input raster is integer, the values on the output raster will be integer; if the values on the input are floating point, the values on the output will be floating point.
The values for each cell location on the output grid are determined on a cell-by-cell basis by applying this simple formula: Focal Range = Focal Maximum �?? Focal Minimum
STD
The output raster will always be floating point.
The STD statistic can be used with the weight neighborhood type.
Sum
If the input raster is integer, the values on the output raster will be integer; if the values on the input are floating point, the values on the output will be floating point.
The STD statistic can be used with the weight neighborhood type.
Variety
The output raster will always be integer.
0 Kudos
DarrenWiens2
MVP Honored Contributor
From the FocalStatistics version 10 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.

Unfortunately, the version 9.3 help has no mention of float vs integer, at least on the Focal Statistics page. Honestly, the reply from Steve Lynch to read the help is below the standards I expect from an ESRI representative, especially when the answer is hidden so deeply in the help pages (for 9.3).
SteveLynch
Esri Regular Contributor
Neil

Thanks for pointing out the problem in the "How Focal Stats works", we'll get onto that ASAP.

Steve
0 Kudos