public IFunctionRasterDataset setValueRangeToNodata(object inRaster,IStringArray sArray) { string tempAr = funcDir + "\\" + FuncCnt + ".afr"; IFunctionRasterDataset frDset = new FunctionRasterDatasetClass(); IFunctionRasterDatasetName frDsetName = new FunctionRasterDatasetNameClass(); frDsetName.FullName = tempAr; frDset.FullName = (IName)frDsetName; IRasterFunction rsFunc = new MaskFunctionClass(); IMaskFunctionArguments args = new MaskFunctionArgumentsClass(); //IMaskFunctionArguments2 args = new MaskFunctionArgumentsClass(); args.Raster = returnRaster(inRaster); args.NoDataValues = sArray; //args.NoDataInterpretation = esriNoDataInterpretation.esriNoDataMatchAll; frDset.Init(rsFunc, args); return frDset; //IRaster rs = returnRaster(inRaster); //IRasterProps rsProps = (IRasterProps)rs; //IRasterBandCollection rsBc = (IRasterBandCollection)rs; //int bCnt = rsBc.Count; //System.Array noDataArr = (System.Array)rsProps.NoDataValue; //IRasterBandCollection rsBcOut = new RasterClass(); //for (int i = 0; i < bCnt; i++) //{ // IRaster brs = getBand(rs, i); // double noData = System.Convert.ToDouble(noDataArr.GetValue(i)); // IRemapFilter rFilt = new RemapFilterClass(); // foreach (double[] d in minMaxList) // { // rFilt.AddClass(d[0], d[1], noData); // } // rsBcOut.AppendBands((IRasterBandCollection)calcRemapFunction(brs, rFilt)); //} //return (IRaster)rsBcOut; }
/// <summary> /// creates a mask of valid values (greater than equal to min and less than equal to max) /// </summary> /// <param name="inRaster"></param> /// <param name="BandRanges"></param> /// <returns></returns> public IFunctionRasterDataset maskDataRange(object inRaster, double[][] BandRanges) { string tempAr = funcDir + "\\" + FuncCnt + ".afr"; IFunctionRasterDataset frDset = new FunctionRasterDatasetClass(); IFunctionRasterDatasetName frDsetName = new FunctionRasterDatasetNameClass(); frDsetName.FullName = tempAr; frDset.FullName = (IName)frDsetName; IRasterFunction rsFunc = new MaskFunctionClass(); IMaskFunctionArguments args = new MaskFunctionArgumentsClass(); IDoubleArray dbArray = new DoubleArrayClass(); foreach (double[] d in BandRanges) { dbArray.Add(d[0]); dbArray.Add(d[1]); } args.Raster = returnRaster(inRaster); args.IncludedRanges = dbArray; frDset.Init(rsFunc, args); return frDset; }