/// <summary>
 /// Will perform a focal raster operation on an input raster all bands
 /// </summary>
 /// <param name="inRaster">either IRaster, IRasterDataset, or a valid path pointing to a raster</param>
 /// <param name="radius">number of cells that make up the radius of a circle</param>
 /// <param name="statType">the type of opporation</param>
 /// <returns>a IRaster that can be used for further analysis</returns>
 public IFunctionRasterDataset calcFocalStatisticsFunction(object inRaster, int radius, focalType statType)
 {
     IFunctionRasterDataset iR1 = createIdentityRaster(inRaster);
     string tempAr = funcDir + "\\" + FuncCnt + ".afr";
     IFunctionRasterDataset frDset = new FunctionRasterDatasetClass();
     IFunctionRasterDatasetName frDsetName = new FunctionRasterDatasetNameClass();
     frDsetName.FullName = tempAr;
     frDset.FullName = (IName)frDsetName;
     IRasterFunction rsFunc = null;
     List<int[]> outLst = new List<int[]>();
     int[,] crl = null;
     double[] cArr = null;
     double sumCircle = 0;
     switch (statType)
     {
         case focalType.MIN:
             rsFunc = new FunctionRasters.NeighborhoodHelper.focalHelperMin();
             break;
         case focalType.SUM:
             crl = createFocalWindowCircle(radius, out outLst);
             cArr = (from int i in crl select System.Convert.ToDouble(i)).ToArray();
             return convolutionRasterFunction(iR1,crl.GetUpperBound(0)+1,crl.GetUpperBound(1)+1,cArr);
         case focalType.MEAN:
             crl = createFocalWindowCircle(radius, out outLst);
             sumCircle = (from int i in crl select System.Convert.ToDouble(i)).Sum();
             cArr = (from int i in crl select System.Convert.ToDouble(i)).ToArray();
             IFunctionRasterDataset conRsMean = convolutionRasterFunction(iR1, crl.GetUpperBound(0) + 1, crl.GetUpperBound(1) + 1, cArr);
             return calcArithmaticFunction(conRsMean, sumCircle, esriRasterArithmeticOperation.esriRasterDivide);
         case focalType.MODE:
             rsFunc = new FunctionRasters.NeighborhoodHelper.focalHelperMode();
             break;
         case focalType.MEDIAN:
             rsFunc = new FunctionRasters.NeighborhoodHelper.focalHelperMedian();
             break;
         case focalType.VARIANCE:
             crl = createFocalWindowCircle(radius, out outLst);
             cArr = (from int i in crl select System.Convert.ToDouble(i)).ToArray();
             double sumCr = cArr.Sum();
             IFunctionRasterDataset rs2 = calcMathRasterFunction(iR1, transType.SQUARED);
             IFunctionRasterDataset sumRs2 = convolutionRasterFunction(rs2, crl.GetUpperBound(0) + 1, crl.GetUpperBound(1) + 1, cArr);
             IFunctionRasterDataset sumRs2M = calcArithmaticFunction(sumRs2, sumCr, esriRasterArithmeticOperation.esriRasterDivide);
             IFunctionRasterDataset sumRs = convolutionRasterFunction(iR1, crl.GetUpperBound(0) + 1, crl.GetUpperBound(1) + 1, cArr);
             IFunctionRasterDataset sumRsSquared = calcMathRasterFunction(sumRs, transType.SQUARED);
             IFunctionRasterDataset difRs = calcArithmaticFunction(sumRsSquared, sumRs2, esriRasterArithmeticOperation.esriRasterMinus);
             return calcArithmaticFunction(difRs, sumCr, esriRasterArithmeticOperation.esriRasterDivide);
         case focalType.STD:
             IRaster var = createRaster(calcFocalStatisticsFunction(iR1, radius, focalType.VARIANCE));
             return calcMathRasterFunction(var, transType.SQRT);
         case focalType.UNIQUE:
             rsFunc = new FunctionRasters.NeighborhoodHelper.focalHelperUnique();
             break;
         case focalType.ENTROPY:
             rsFunc = new FunctionRasters.NeighborhoodHelper.focalHelperEntropy();
             break;
         case focalType.ASM:
             rsFunc = new FunctionRasters.NeighborhoodHelper.focalHelperProbability();
             break;
         default:
             rsFunc = new FunctionRasters.NeighborhoodHelper.focalHelperMax();
             break;
     }
     FunctionRasters.FocalFunctionArguments args = new FunctionRasters.FocalFunctionArguments(this);
     args.Radius = radius;
     args.InRaster = iR1;
     args.Operation = statType;
     frDset.Init(rsFunc, args);
     return frDset;
 }
 /// <summary>
 /// Will perform a focal raster operation on an input raster all bands
 /// </summary>
 /// <param name="inRaster">either IRaster, IRasterDataset, or a valid path pointing to a raster</param>
 /// <param name="clm">number of columns (cells)</param>
 /// <param name="rws">number of rows</param>
 /// <param name="statType">the type of operation</param>
 /// <returns>a IRaster that can be used for further analysis</returns>
 public IFunctionRasterDataset calcFocalStatisticsFunction(object inRaster, int clm, int rws, focalType statType)
 {
     IFunctionRasterDataset iR1 = createIdentityRaster(inRaster,rstPixelType.PT_FLOAT);
     string tempAr = funcDir + "\\" + FuncCnt + ".afr";
     IFunctionRasterDataset frDset = new FunctionRasterDatasetClass();
     IFunctionRasterDatasetName frDsetName = new FunctionRasterDatasetNameClass();
     frDsetName.FullName = tempAr;
     frDset.FullName = (IName)frDsetName;
     IRasterFunction rsFunc = null;
     switch (statType)
     {
         case focalType.MIN:
         case focalType.MAX:
         case focalType.MEAN:
         case focalType.STD:
             return calcFocalStatisticsRectangle(inRaster, clm, rws, statType);
         case focalType.SUM:
             IFunctionRasterDataset mRs = calcFocalStatisticsFunction(inRaster, clm, rws, focalType.MEAN);
             return calcArithmaticFunction(mRs, clm * rws, esriRasterArithmeticOperation.esriRasterMultiply);
             //rsFunc = new FunctionRasters.NeighborhoodHelper.focalHelperSum();
             //break;
         case focalType.MODE:
             rsFunc = new FunctionRasters.NeighborhoodHelper.focalHelperMode();
             break;
         case focalType.MEDIAN:
             rsFunc = new FunctionRasters.NeighborhoodHelper.focalHelperMedian();
             break;
         case focalType.VARIANCE:
             IFunctionRasterDataset rs = calcFocalStatisticsFunction(inRaster, clm, rws,focalType.STD);
             return calcArithmaticFunction(rs,2,esriRasterArithmeticOperation.esriRasterPower);
         case focalType.UNIQUE:
             rsFunc = new FunctionRasters.NeighborhoodHelper.focalHelperUnique();
             break;
         case focalType.ENTROPY:
             rsFunc = new FunctionRasters.NeighborhoodHelper.focalHelperEntropy();
             break;
         case focalType.ASM:
             rsFunc = new FunctionRasters.NeighborhoodHelper.focalHelperProbability();
             break;
         default:
             break;
     }
     FunctionRasters.FocalFunctionArguments args = new FunctionRasters.FocalFunctionArguments(this);
     args.Rows = rws;
     args.Columns = clm;
     //args.WindowType = windowType.RECTANGLE;
     args.InRaster = iR1;
     args.Operation = statType;
     frDset.Init(rsFunc, args);
     return frDset;
 }
 public IFunctionRasterDataset calcFocalSampleFunction(object inRaster, HashSet<string> offset, focalType statType)
 {
     IFunctionRasterDataset iR1 = createIdentityRaster(inRaster);
     string tempAr = funcDir + "\\" + FuncCnt + ".afr";
     IFunctionRasterDataset frDset = new FunctionRasterDatasetClass();
     IFunctionRasterDatasetName frDsetName = new FunctionRasterDatasetNameClass();
     frDsetName.FullName = tempAr;
     frDset.FullName = (IName)frDsetName;
     IRasterFunction rsFunc = null;
     switch (statType)
     {
         case focalType.MIN:
             rsFunc = new FunctionRasters.NeighborhoodHelper.focalSampleHelperMin();
             break;
         case focalType.SUM:
             rsFunc = new FunctionRasters.NeighborhoodHelper.focalSampleHelperSum();
             break;
         case focalType.MEAN:
             rsFunc = new FunctionRasters.NeighborhoodHelper.focalSampleHelperMean();
             break;
         case focalType.MODE:
             rsFunc = new FunctionRasters.NeighborhoodHelper.focalSampleHelperMode();
             break;
         case focalType.MEDIAN:
             rsFunc = new FunctionRasters.NeighborhoodHelper.focalSampleHelperMedian();
             break;
         case focalType.VARIANCE:
             rsFunc = new FunctionRasters.NeighborhoodHelper.focalSampleHelperVariance();
             break;
         case focalType.STD:
             rsFunc = new FunctionRasters.NeighborhoodHelper.focalSampleHelperStd();
             break;
         case focalType.UNIQUE:
             rsFunc = new FunctionRasters.NeighborhoodHelper.focalSampleHelperUnique();
             break;
         case focalType.ENTROPY:
             rsFunc = new FunctionRasters.NeighborhoodHelper.focalSampleHelperEntropy();
             break;
         case focalType.ASM:
             rsFunc = new FunctionRasters.NeighborhoodHelper.focalSampleHelperASM();
             break;
         default:
             rsFunc = new FunctionRasters.NeighborhoodHelper.focalSampleHelperMax();
             break;
     }
     FunctionRasters.focalSampleArguments args = new FunctionRasters.focalSampleArguments(this);
     args.OffSets = offset;
     args.Operation = statType;
     //args.WindowType = windowType.RECTANGLE;
     args.InRaster = iR1;
     frDset.Init(rsFunc, args);
     return frDset;
 }
 /// <summary>
 /// performs block summarization
 /// </summary>
 /// <param name="inRaster"></param>
 /// <param name="outWks"></param>
 /// <param name="outRsName"></param>
 /// <param name="numCells"></param>
 /// <returns></returns>
 public IFunctionRasterDataset calcAggregationFunction(object inRaster, int cells, focalType statType)
 {
     IFunctionRasterDataset iR1 = createIdentityRaster(inRaster);
     string tempAr = funcDir + "\\" + FuncCnt + ".afr";
     IFunctionRasterDataset frDset = new FunctionRasterDatasetClass();
     IFunctionRasterDatasetName frDsetName = new FunctionRasterDatasetNameClass();
     frDsetName.FullName = tempAr;
     frDset.FullName = (IName)frDsetName;
     IRasterFunction rsFunc = null;
     switch (statType)
     {
         case focalType.MIN:
             rsFunc = new FunctionRasters.NeighborhoodHelper.aggregationHelperMin();
             break;
         case focalType.SUM:
             rsFunc = new FunctionRasters.NeighborhoodHelper.aggregationHelperSum();
             break;
         case focalType.MEAN:
             rsFunc = new FunctionRasters.NeighborhoodHelper.aggregationHelperMean();
             break;
         case focalType.MODE:
             rsFunc = new FunctionRasters.NeighborhoodHelper.aggregationHelperMode();
             break;
         case focalType.MEDIAN:
             rsFunc = new FunctionRasters.NeighborhoodHelper.aggregationHelperMedian();
             break;
         case focalType.VARIANCE:
             rsFunc = new FunctionRasters.NeighborhoodHelper.aggregationHelperVar();
             break;
         case focalType.STD:
             rsFunc = new FunctionRasters.NeighborhoodHelper.aggregationHelperStd();
             break;
         case focalType.UNIQUE:
             rsFunc = new FunctionRasters.NeighborhoodHelper.aggregationHelperUnique();
             break;
         case focalType.ENTROPY:
             rsFunc = new FunctionRasters.NeighborhoodHelper.aggregationHelperEntropy();
             break;
         case focalType.ASM:
             rsFunc = new FunctionRasters.NeighborhoodHelper.aggregationHelperASM();
             break;
         default:
             rsFunc = new FunctionRasters.NeighborhoodHelper.aggregationHelperMax();
             break;
     }
     FunctionRasters.aggregationFunctionArguments args = new FunctionRasters.aggregationFunctionArguments(this);
     args.Cells = cells;
     args.InRaster = iR1;
     frDset.Init(rsFunc, args);
     return frDset;
 }
 private IFunctionRasterDataset calcFocalStatisticsRectangle(object iR1, int clm, int rws, focalType statType)
 {
     //Console.WriteLine(statType);
     //Console.WriteLine((esriFocalStatisticType)statType);
     string tempAr = funcDir + "\\" + FuncCnt + ".afr";
     IFunctionRasterDataset frDset = new FunctionRasterDatasetClass();
     IFunctionRasterDatasetName frDsetName = new FunctionRasterDatasetNameClass();
     frDsetName.FullName = tempAr;
     frDset.FullName = (IName)frDsetName;
     IRasterFunction rsFunc = new StatisticsFunctionClass();
     //IStatisticsFunctionArguments2 args = new StatisticsFunctionArgumentsClass();
     IStatisticsFunctionArguments args = new StatisticsFunctionArgumentsClass();
     args.Raster = createIdentityRaster(iR1,rstPixelType.PT_FLOAT);
     args.Columns = clm;
     args.Rows = rws;
     args.Type = (esriFocalStatisticType)statType;
     //args.FillNoDataOnly = false;
     frDset.Init(rsFunc, args);
     return frDset;
 }
 /// <summary>
 /// Will perform a focal raster operation on an input raster all bands
 /// </summary>
 /// <param name="inRaster">either IRaster, IRasterDataset, or a valid path pointing to a raster</param>
 /// <param name="radius">number of cells that make up the radius of the moving window</param>
 /// <param name="statType">the type of operation</param>
 /// <param name="landType">the type of metric</param>
 /// <returns>a IRaster that can be used for further analysis</returns>
 public IFunctionRasterDataset calcLandscapeFunction(object inRaster, int radius, focalType statType, landscapeType landType)
 {
     IFunctionRasterDataset iR1 = createIdentityRaster(inRaster);
     string tempAr = funcDir + "\\" + FuncCnt + ".afr";
     IFunctionRasterDataset frDset = new FunctionRasterDatasetClass();
     IFunctionRasterDatasetName frDsetName = new FunctionRasterDatasetNameClass();
     frDsetName.FullName = tempAr;
     frDset.FullName = (IName)frDsetName;
     IRasterFunction rsFunc = new FunctionRasters.landscapeFunctionDataset();
     FunctionRasters.LandscapeFunctionArguments args = new FunctionRasters.LandscapeFunctionArguments(this);
     args.WindowType = windowType.CIRCLE;
     args.Radius = radius;
     args.InRaster = iR1;
     args.Operation = statType;
     args.LandscapeType = landType;
     frDset.Init(rsFunc, args);
     return frDset;
 }