Statistics
| Revision:

root / org.gvsig.toolbox / trunk / org.gvsig.toolbox / org.gvsig.toolbox.algorithm / src / main / java / es / unex / sextante / gridStatistics / neighborhoodMeanValue / NeighborhoodMeanValueAlgorithm.java @ 59

History | View | Annotate | Download (1002 Bytes)

1
package es.unex.sextante.gridStatistics.neighborhoodMeanValue;
2

    
3
import es.unex.sextante.core.Sextante;
4
import es.unex.sextante.gridStatistics.base.NeighborhoodStatsBaseAlgorithm;
5

    
6
public class NeighborhoodMeanValueAlgorithm
7
         extends
8
            NeighborhoodStatsBaseAlgorithm {
9

    
10
   @Override
11
   public void defineCharacteristics() {
12

    
13
      setName(Sextante.getText("Mean__neighbourhood"));
14
      setGroup(Sextante.getText("Focal_statistics"));
15
      super.defineCharacteristics();
16

    
17
   }
18

    
19

    
20
   @Override
21
   protected double processValues() {
22

    
23
      int i;
24
      double dValue;
25
      int iValidCells = 0;
26

    
27
      double dMean = 0;
28

    
29
      for (i = 0; i < m_dValues.length; i++) {
30
         dValue = m_dValues[i];
31
         if (dValue != NO_DATA) {
32
            dMean += dValue;
33
            iValidCells++;
34
         }
35
      }
36

    
37
      if (iValidCells > 0) {
38
         return (dMean / iValidCells);
39
      }
40
      else {
41
         return NO_DATA;
42
      }
43

    
44
   }
45

    
46
}