public void getDaModel(string modelPath) { using (System.IO.StreamReader sr = new System.IO.StreamReader(modelPath)) { string mType = sr.ReadLine(); esriUtil.Statistics.dataPrepBase.modelTypes m = (esriUtil.Statistics.dataPrepBase.modelTypes)Enum.Parse(typeof(esriUtil.Statistics.dataPrepBase.modelTypes), mType); if (m != esriUtil.Statistics.dataPrepBase.modelTypes.Normalize) { System.Windows.Forms.MessageBox.Show("Model file specified is not a Normalizatoin model!!", "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return; } PercentAreaChange = System.Convert.ToDouble(sr.ReadLine()); rsType = (rstPixelType)Enum.Parse(typeof(rstPixelType), sr.ReadLine()); int coefLength = System.Convert.ToInt32(sr.ReadLine()); coef = new double[coefLength][]; cellCount = new int[coefLength]; for (int i = 0; i < coefLength; i++) { cellCount[i] = 100; } for (int i = 0; i < coefLength; i++) { double[] vlArr = (from string s in (sr.ReadLine().Split(new char[] { ',' })) select System.Convert.ToDouble(s)).ToArray(); coef[i] = vlArr; } sr.Close(); } }
/// <summary> /// 判断数据库和镶嵌数据集是否存在的,存在就读取,不存在,就创建 /// </summary> /// <param name="filegdb"></param> /// <param name="mosaicDatasetName"></param> /// <returns></returns> public IMosaicDataset CreateMD(string filegdb, string mosaicDatasetName) { ISpatialReference mosaicSrs = null; int mosaicDatasetBands = 0; rstPixelType mosaicDatasetBits = rstPixelType.PT_UNKNOWN; string configKeyword = ""; IWorkspace wk = null; if (System.IO.Directory.Exists(filegdb)) { wk = OpenFileGDB(filegdb); } else { wk = CreateFileGDB(filegdb); } IMosaicDataset theMosaicDataset = null; IWorkspace2 wk2 = wk as IWorkspace2; if (wk2.get_NameExists(esriDatasetType.esriDTMosaicDataset, mosaicDatasetName)) { theMosaicDataset = OpenMosaicDataset(ref wk, mosaicDatasetName); } else { theMosaicDataset = CreateMosaicDataset(ref wk, mosaicDatasetName, mosaicSrs, mosaicDatasetBands, mosaicDatasetBits, configKeyword); } return(theMosaicDataset); }
public void Bind(object pArgument) { if (pArgument is FocalFunctionArguments) { FocalFunctionArguments args = (FocalFunctionArguments)pArgument; inrs = args.InRaster; orig = args.OriginalRaster; inop = args.Operation; inWindow = args.WindowType; lsiter = args.Fastiter; windowN = args.WindowCount; //Console.WriteLine(lsiter.Count()); clms = args.Columns; rws = args.Rows; radius = args.Radius; myFunctionHelper.Bind(inrs); myFunctionHelperOrig.Bind(orig); myRasterInfo = myFunctionHelper.RasterInfo; myPixeltype = myRasterInfo.PixelType; myValidFlag = true; } else { throw new System.Exception("Incorrect arguments object. Expected: FocalFunctonArguments"); } }
public void Bind(object pArgument) { if (pArgument is glcmFunctionArguments) { glcmFunctionArguments args = (glcmFunctionArguments)pArgument; inrs = args.InRaster; orig = args.OriginalRaster; inWindow = args.WindowType; iter = args.GenericIterator; clms = args.Columns; rws = args.Rows; radius = args.Radius; glcmMetrics = args.GLCMMETRICS; horizontal = args.Horizontal; myFunctionHelper.Bind(inrs); myFunctionHelperOrig.Bind(orig); myRasterInfo = myFunctionHelper.RasterInfo; myPixeltype = myRasterInfo.PixelType; myValidFlag = true; } else { throw new System.Exception("Incorrect arguments object. Expected: glcmFunctonArguments"); } }
public override void getOutPutVl(IPixelBlock3 pb, System.Array[] inArr, float vl, int c, int r) { float[] orgArr = new float[bndCnt]; float[] sortArr = new float[bndCnt]; orgArr[0] = vl; sortArr[0] = vl; for (int p = 1; p < bndCnt; p++) { float vl2 = System.Convert.ToSingle(inArr[p].GetValue(c, r)); orgArr[p] = vl2; sortArr[p] = vl2; } System.Array.Sort(sortArr); for (int p = 0; p < bndCnt; p++) { rstPixelType ptyp = pb.get_PixelType(p); float orgVl = orgArr[p]; int indexSort = System.Array.LastIndexOf(sortArr, orgVl); float prc = indexSort / bndCntf; object newVl = rasterUtil.getSafeValue(prc, ptyp); inArr[p].SetValue(newVl, c, r); } //int[] cntLst = new int[100]; //float[] probLst = new float[100]; //float[] orgLst = new float[bndCnt]; //int[] indexvl = new int[bndCnt]; //float min = float.MaxValue; //float max = float.MinValue; //float TCnt = 0; //for (int i = 0; i < coefPb.Planes; i++) //{ // object objVl = coefPb.GetVal(i, c, r); // if (objVl != null) // { // float vl = (float)objVl; // orgLst[i] = vl; // if (vl > max) max = vl; // if (vl < min) min = vl; // TCnt+=1; // } //} //float rng = max - min; //for (int i = 0; i < orgLst.Length; i++) //{ // int indexVl = (int)(99*(orgLst[i] - min) / rng); // indexvl[i] = indexVl; // cntLst[indexVl] = cntLst[indexVl] + 1; //} //int sumCnt = 0; //for (int i = 0; i < cntLst.Length; i++) //{ // sumCnt = sumCnt + cntLst[i]; // probLst[i] = sumCnt/TCnt; //} //for (int i = 0; i < orgLst.Length; i++) //{ // updateArr[i].SetValue(probLst[indexvl[i]], c, r); //} }
private object splitArray(int[] vls, IPixelBlock3 pb3) { int width = pb3.Width; int height = pb3.Height; int cnt = 0; System.Array outArr = (System.Array)pb3.get_PixelData(0); rstPixelType rsp = pb3.get_PixelType(0); foreach (int i in vls) { double div = System.Convert.ToDouble(cnt) / width; int r = (int)div; int c = cnt - (r * width); try { object newvl = rasterUtil.getSafeValue(i, rsp); outArr.SetValue(i, c, r); } catch { object newvl = rasterUtil.getSafeValue(900, rsp); outArr.SetValue(900, c, r); } cnt++; } return(outArr); }
public void Bind(object pArgument) { if (pArgument is combineFunctionArguments) { combineFunctionArguments args = (combineFunctionArguments)pArgument; inrs = args.InRasterDataset; outRs = args.OutRaster; myFunctionHelper.Bind(outRs); //myFunctionHelperCoef.Bind(inrs); myRasterInfo = myFunctionHelper.RasterInfo; myPixeltype = myRasterInfo.PixelType; myValidFlag = true; object tnd = myRasterInfo.NoData; if (tnd == null) { } else { noDataVl = ((System.Array)myRasterInfo.NoData).GetValue(0); } } else { throw new System.Exception("Incorrect arguments object. Expected: combineFunctonArguments"); } }
public void Bind(object pArgument) { if (pArgument is combineFunctionArguments) { combineFunctionArguments args = (combineFunctionArguments)pArgument; inrs = args.InRasterDataset; outRs = args.OutRaster; myFunctionHelper.Bind(outRs); //myFunctionHelperCoef.Bind(inrs); myRasterInfo = myFunctionHelper.RasterInfo; myPixeltype = myRasterInfo.PixelType; myValidFlag = true; object tnd = myRasterInfo.NoData; if(tnd==null) { } else { noDataVl = ((System.Array)myRasterInfo.NoData).GetValue(0); } } else { throw new System.Exception("Incorrect arguments object. Expected: combineFunctonArguments"); } }
public static string GetDescription(rstPixelType type) { switch (type) { case rstPixelType.PT_U1: return("U1"); case rstPixelType.PT_U2: return("U2"); case rstPixelType.PT_U4: return("U4"); case rstPixelType.PT_UCHAR: return("U8"); case rstPixelType.PT_CHAR: return("S8"); case rstPixelType.PT_USHORT: return("U16"); case rstPixelType.PT_SHORT: return("S16"); case rstPixelType.PT_ULONG: return("U32"); case rstPixelType.PT_LONG: return("S32"); case rstPixelType.PT_FLOAT: return("F32"); case rstPixelType.PT_DOUBLE: return("F64"); case rstPixelType.PT_COMPLEX: return("C64"); case rstPixelType.PT_DCOMPLEX: return("C128"); case rstPixelType.PT_UNKNOWN: default: return("UNKNOWN"); } }
private void btnClip_Click(object sender, EventArgs e) { string rstNm = cmbInRaster1.Text; string outNm = txtOutName.Text; string pixelNm = cmbPixel.Text; if (pixelNm == "" || pixelNm == null || rstNm == "" || rstNm == null) { MessageBox.Show("You must have a raster layer selected and a pixel type selected", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (outNm == "" || outNm == null) { MessageBox.Show("You must specify an output raster name", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } this.Visible = false; esriUtil.Forms.RunningProcess.frmRunningProcessDialog rp = new RunningProcess.frmRunningProcessDialog(false); DateTime dt = DateTime.Now; rp.addMessage("Transforming Raster. This may take a while..."); rp.stepPGBar(10); rp.TopMost = true; rp.Show(); try { IRaster rst = rstDic[rstNm]; rstPixelType pType = (rstPixelType)Enum.Parse(typeof(rstPixelType), pixelNm); outraster = rsUtil.returnRaster(rst, pType); if (mp != null && addToMap) { rp.addMessage("Calculating Statistics..."); rp.Refresh(); IRasterLayer rstLyr = new RasterLayerClass(); //rsUtil.calcStatsAndHist(((IRaster2)outraster).RasterDataset); rstLyr.CreateFromRaster(outraster); rstLyr.Name = outNm; rstLyr.Visible = false; mp.AddLayer(rstLyr); } outrastername = outNm; this.DialogResult = DialogResult.OK; } catch (Exception ex) { rp.addMessage(ex.ToString()); } finally { DateTime dt2 = DateTime.Now; TimeSpan ts = dt2.Subtract(dt); string t = " in " + ts.Days.ToString() + " days " + ts.Hours.ToString() + " hours " + ts.Minutes.ToString() + " minutes and " + ts.Seconds.ToString() + " seconds ."; rp.stepPGBar(100); rp.addMessage("Finished Converting Raster" + t); rp.enableClose(); this.Close(); } }
//获取最大最小栅格值 private void SetMaxMinValue(int flag) { if (flag == 1) { textBoxMax.Text = "高:255"; textBoxMin.Text = "低:0"; return; } uint valueMax = 50; uint valueMin = 50; IRasterLayer pRasterLayer = m_layer as IRasterLayer; IRaster pRaster = pRasterLayer.Raster; IRasterProps pRasterProps = pRaster as IRasterProps; int Height = pRasterProps.Height; int Width = pRasterProps.Width; double dX = pRasterProps.MeanCellSize().X; double dY = pRasterProps.MeanCellSize().Y; //栅格的高度 IEnvelope extent = pRasterProps.Extent; //当前栅格数据集的范围 rstPixelType pixelType = pRasterProps.PixelType; //当前栅格像素类型 IPnt pntSize = new PntClass(); pntSize.SetCoords(dX, dY); IPixelBlock pixelBlock = pRaster.CreatePixelBlock(pntSize); IPnt pnt = new PntClass(); for (int i = 0; i < Height; i += 10) { for (int j = 0; j < Width; j += 10) { pnt.SetCoords(i, j); pRaster.Read(pnt, pixelBlock); if (pixelBlock != null) { object obj = pixelBlock.GetVal(0, 0, 0); uint temp = Convert.ToUInt32(obj); if (temp > valueMax) { valueMax = temp; } else if (temp < valueMin) { valueMin = temp; } } } } textBoxMax.Text = "高:" + valueMax.ToString(); textBoxMin.Text = "低:" + valueMin.ToString(); }
public static string PixelType2NetType(rstPixelType pixelType) { string result = ""; switch (pixelType) { case rstPixelType.PT_U1: result = "1_BIT"; break; case rstPixelType.PT_U2: result = "2_BIT"; break; case rstPixelType.PT_U4: result = "4_BIT"; break; case rstPixelType.PT_UCHAR: result = "8_BIT_UNSIGNED"; break; case rstPixelType.PT_CHAR: result = "8_BIT_SIGNED"; break; case rstPixelType.PT_USHORT: result = "16_BIT_UNSIGNED"; break; case rstPixelType.PT_SHORT: result = "16_BIT_SIGNED"; break; case rstPixelType.PT_ULONG: result = "32_BIT_UNSIGNED"; break; case rstPixelType.PT_LONG: result = "32_BIT_SIGNED"; break; case rstPixelType.PT_FLOAT: result = "32_BIT_FLOAT"; break; case rstPixelType.PT_DOUBLE: result = "64_BIT"; break; } return(result); }
/// <summary> /// Read pixels from the input Raster and fill the PixelBlock provided with processed pixels. /// The RasterFunctionHelper object is used to handle pixel type conversion and resampling. /// The log raster is the natural log of the raster. /// </summary> /// <param name="pTlc">Point to start the reading from in the Raster</param> /// <param name="pRaster">Reference Raster for the PixelBlock</param> /// <param name="pPixelBlock">PixelBlock to be filled in</param> public void Read(IPnt pTlc, IRaster pRaster, IPixelBlock pPixelBlock) { try { System.Array noDataValueArr = (System.Array)((IRasterProps)pRaster).NoDataValue; myFunctionHelper.Read(pTlc, null, pRaster, pPixelBlock); int pBHeight = pPixelBlock.Height; int pBWidth = pPixelBlock.Width; IPixelBlock3 ipPixelBlock = (IPixelBlock3)pPixelBlock; IPnt pbBigSize = new PntClass(); IPnt pbBigLoc = new PntClass(); int pbBigWd = pBWidth + clms; int pbBigHt = pBHeight + rws; int l, t; l = (clms - 1) / 2; t = (rws - 1) / 2; //Console.WriteLine("lt = " + (pTlc.X - l).ToString() + ":" + (pTlc.Y - t).ToString()); pbBigSize.SetCoords(pbBigWd, pbBigHt); pbBigLoc.SetCoords((pTlc.X - l), (pTlc.Y - t)); IPixelBlock3 pbBig = (IPixelBlock3)myFunctionHelperOrig.Raster.CreatePixelBlock(pbBigSize); myFunctionHelperOrig.Read(pbBigLoc, null, myFunctionHelperOrig.Raster, (IPixelBlock)pbBig); for (int nBand = 0; nBand < pbBig.Planes; nBand++) { System.Array pixelValues = (System.Array)(ipPixelBlock.get_PixelData(nBand)); rstPixelType rsp = ipPixelBlock.get_PixelType(nBand); //System.Array pixelValuesBig = (System.Array)(pbBig.get_PixelData(nBand)); for (int r = 0; r < pBHeight; r++) { for (int c = 0; c < pBWidth; c++) { object objVl = ipPixelBlock.GetVal(nBand, c, r); if (objVl == null) { continue; } else { float outVl = System.Convert.ToSingle(getTransformedValue(pbBig, c + l, r + t, nBand)); object newVl = rasterUtil.getSafeValue(outVl, rsp); //Console.WriteLine(outVl.ToString()); pixelValues.SetValue(newVl, c, r); } } } ((IPixelBlock3)pPixelBlock).set_PixelData(nBand, pixelValues); } } catch (Exception e) { Console.WriteLine(e.ToString()); } }
/// <summary> /// Read pixels from the input Raster and fill the PixelBlock provided with processed pixels. /// The RasterFunctionHelper object is used to handle pixel type conversion and resampling. /// The log raster is the natural log of the raster. /// </summary> /// <param name="pTlc">Point to start the reading from in the Raster</param> /// <param name="pRaster">Reference Raster for the PixelBlock</param> /// <param name="pPixelBlock">PixelBlock to be filled in</param> public void Read(IPnt pTlc, IRaster pRaster, IPixelBlock pPixelBlock) { try { //System.Array noDataValueArr = (System.Array)((IRasterProps)pRaster).NoDataValue; myFunctionHelper.Read(pTlc, null, pRaster, pPixelBlock); int pBHeight = pPixelBlock.Height; int pBWidth = pPixelBlock.Width; IPixelBlock3 ipPixelBlock = (IPixelBlock3)pPixelBlock; IPnt pbBigSize = new PntClass(); IPnt pbBigLoc = new PntClass(); int pbBigWd = pBWidth + clms; int pbBigHt = pBHeight + rws; int l, t; l = clms / 2; t = rws / 2; pbBigSize.SetCoords(pbBigWd, pbBigHt); pbBigLoc.SetCoords((pTlc.X - l), (pTlc.Y - t)); IPixelBlock3 pbBig = (IPixelBlock3)myFunctionHelperOrig.Raster.CreatePixelBlock(pbBigSize); myFunctionHelperOrig.Read(pbBigLoc, null, myFunctionHelperOrig.Raster, (IPixelBlock)pbBig); noDataValue = float.MinValue;//System.Convert.ToSingle(noDataValueArr.GetValue(0)); for (int nBand = 0; nBand < ipPixelBlock.Planes; nBand++) { rstPixelType pbt = ipPixelBlock.get_PixelType(nBand); System.Array pixelValues = (System.Array)(ipPixelBlock.get_PixelData(nBand)); for (int r = 0; r < pBHeight; r++) { for (int c = 0; c < pBWidth; c++) { object inVlobj = ipPixelBlock.GetVal(nBand, c, r); if (inVlobj == null) { continue; } else { updateGLCMDic(pbBig, c, r, nBand); float outVl = System.Convert.ToSingle(getTransformedValue(countDic)); object newVl = rasterUtil.getSafeValue(outVl, pbt); pixelValues.SetValue(newVl, c, r); } } } ((IPixelBlock3)pPixelBlock).set_PixelData(nBand, pixelValues); } } catch (Exception e) { Console.WriteLine(e.ToString()); } }
public RasterBand(SerializationInfo info, StreamingContext context) : base(info, context) { this._oidFieldName = info.GetString("oidFieldName"); this._isInteger = info.GetBoolean("isInteger"); this._meanCellHeight = info.GetDouble("meanCellHeight"); this._meanCellWidth = info.GetDouble("meanCellWidth"); this._height = info.GetInt32("height"); this._width = info.GetInt32("width"); this._pixelType = (rstPixelType)Enum.Parse(typeof(rstPixelType), info.GetString("pixelType"), true); this._primaryField = info.GetInt32("primaryField"); this._tableType = (esriRasterTableTypeEnum)Enum.Parse(typeof(esriRasterTableTypeEnum), info.GetString("tableType"), true); this._extent = (Extent)info.GetValue("extent", typeof(Extent)); this._spatialReference = (SpatialReference)info.GetValue("spatialReference", typeof(SpatialReference)); }
/// <summary> /// Read pixels from the input Raster and fill the PixelBlock provided with processed pixels. /// The RasterFunctionHelper object is used to handle pixel type conversion and resampling. /// The log raster is the natural log of the raster. /// </summary> /// <param name="pTlc">Point to start the reading from in the Raster</param> /// <param name="pRaster">Reference Raster for the PixelBlock</param> /// <param name="pPixelBlock">PixelBlock to be filled in</param> public void Read(IPnt pTlc, IRaster pRaster, IPixelBlock pPixelBlock) { try { myFunctionHelper.Read(pTlc, null, pRaster, pPixelBlock); //System.Windows.Forms.MessageBox.Show("Read resized raster"); int pBHeight = pPixelBlock.Height; int pBWidth = pPixelBlock.Width; IPixelBlock3 ipPixelBlock = (IPixelBlock3)pPixelBlock; IPnt pbBigSize = new PntClass(); IPnt pbBigLoc = new PntClass(); int pbBigWd = pBWidth * cells; int pbBigHt = pBHeight * cells; pbBigSize.SetCoords(pbBigWd, pbBigHt); pbBigLoc.SetCoords((pTlc.X * cells), (pTlc.Y * cells)); IPixelBlock pbOrig = myFunctionHelperOrig.Raster.CreatePixelBlock(pbBigSize); //System.Windows.Forms.MessageBox.Show("Read original Raster"); myFunctionHelperOrig.Read(pbBigLoc, null, myFunctionHelperOrig.Raster, pbOrig); IPixelBlock3 pbBig = (IPixelBlock3)pbOrig; //int cnt = 0; for (int nBand = 0; nBand < ipPixelBlock.Planes; nBand++) { //Console.WriteLine(ipPixelBlock.get_PixelType(nBand).ToString()); //object noDataValue = System.Convert.ToSingle(noDataValueArr.GetValue(nBand)); //System.Array pixelValuesBig = (System.Array)(pbBig.get_PixelData(nBand)); rstPixelType pTy = pbBig.get_PixelType(nBand); System.Array pixelValues = (System.Array)(ipPixelBlock.get_PixelData(nBand)); for (int r = 0; r < pBHeight; r++) { for (int c = 0; c < pBWidth; c++) { object objVl = ipPixelBlock.GetVal(nBand, c, r); if (objVl != null) { object outVl = getTransformedValue(pbBig, nBand, c, r, cells); object newVl = rasterUtil.getSafeValue(outVl, pTy); //System.Windows.Forms.MessageBox.Show(outVl.ToString()); pixelValues.SetValue(newVl, c, r); } } } ipPixelBlock.set_PixelData(nBand, pixelValues); } } catch (Exception e) { Console.WriteLine(e.ToString()); } }
/// <summary> /// Read pixels from the input Raster and fill the PixelBlock provided with processed pixels. /// The RasterFunctionHelper object is used to handle pixel type conversion and resampling. /// The log raster is the natural log of the raster. /// </summary> /// <param name="pTlc">Point to start the reading from in the Raster</param> /// <param name="pRaster">Reference Raster for the PixelBlock</param> /// <param name="pPixelBlock">PixelBlock to be filled in</param> public void Read(IPnt pTlc, IRaster pRaster, IPixelBlock pPixelBlock) { try { // Call Read method of the Raster Function Helper object. myFunctionHelper.Read(pTlc, null, pRaster, pPixelBlock); int pBHeight = pPixelBlock.Height; int pBWidth = pPixelBlock.Width; IPnt pbSize = new PntClass(); pbSize.SetCoords(pBWidth, pBHeight); IPixelBlock3 ipPixelBlock = (IPixelBlock3)pPixelBlock; System.Array[] inArr = new System.Array[inrsBands.RasterInfo.BandCount]; IRasterBandCollection rsBc = (IRasterBandCollection)inrsBands; for (int p = 0; p < inArr.Length; p++) { IRasterBand rsB = rsBc.Item(p); IRawPixels rP = (IRawPixels)rsB; IPixelBlock pb = rP.CreatePixelBlock(pbSize); IPixelBlock3 pb3 = (IPixelBlock3)pb; rP.Read(pTlc, pb); inArr[p] = (System.Array)pb3.get_PixelData(0); } System.Array outArr = (System.Array)pPixelBlock.get_SafeArray(0); rstPixelType rsPt = pPixelBlock.get_PixelType(0); for (int r = 0; r < ipPixelBlock.Height; r++) { for (int c = 0; c < ipPixelBlock.Width; c++) { object outVlObj = ipPixelBlock.GetVal(0, c, r); if (outVlObj != null) { float outVl; if (getOutPutVl(inArr, c, r, out outVl)) { object newVl = rasterUtil.getSafeValue(outVl, rsPt);//convertVl(outVl,rsPt); outArr.SetValue(newVl, c, r); } } } } ipPixelBlock.set_PixelData(0, outArr); } catch (Exception exc) { System.Exception myExc = new System.Exception("Exception caught in Read method of localMean Function. " + exc.Message, exc); Console.Write(exc.ToString()); throw myExc; } }
/// <summary> /// Read pixels from the input Raster and fill the PixelBlock provided with processed pixels. /// The RasterFunctionHelper object is used to handle pixel type conversion and resampling. /// The log raster is the natural log of the raster. /// </summary> /// <param name="pTlc">Point to start the reading from in the Raster</param> /// <param name="pRaster">Reference Raster for the PixelBlock</param> /// <param name="pPixelBlock">PixelBlock to be filled in</param> public void Read(IPnt pTlc, IRaster pRaster, IPixelBlock pPixelBlock) { try { // Call Read method of the Raster Function Helper object. myFunctionHelper.Read(pTlc, null, pRaster, pPixelBlock); int pBHeight = pPixelBlock.Height; int pBWidth = pPixelBlock.Width; IPnt pbSize = new PntClass(); pbSize.SetCoords(pBWidth, pBHeight); IPixelBlock3 outPb = (IPixelBlock3)myFunctionHelperCoef.Raster.CreatePixelBlock(pbSize); myFunctionHelperCoef.Read(pTlc, null, myFunctionHelperCoef.Raster, (IPixelBlock)outPb); int pBRowIndex = 0; int pBColIndex = 0; IPixelBlock3 ipPixelBlock = (IPixelBlock3)pPixelBlock; System.Array outArr = (System.Array)ipPixelBlock.get_PixelData(0); rstPixelType pty = ipPixelBlock.get_PixelType(0); double[] vArr = new double[outPb.Planes]; for (int i = pBRowIndex; i < pBHeight; i++) { for (int k = pBColIndex; k < pBWidth; k++) { bool checkVl = true; for (int coefnBand = 0; coefnBand < outPb.Planes; coefnBand++) { object vlObj = outPb.GetVal(0, k, i); if (vlObj == null) { checkVl = false; break; } vArr[coefnBand] = System.Convert.ToDouble(vlObj); } if (checkVl) { double tVl = glm.computeNew(vArr); object newVl = rasterUtil.getSafeValue(tVl, pty); outArr.SetValue(newVl, k, i); } } } ipPixelBlock.set_PixelData(0, outArr); } catch (Exception exc) { System.Exception myExc = new System.Exception("Exception caught in Read method of GLM Function. " + exc.Message, exc); Console.WriteLine(exc.ToString()); } }
/// <summary> /// Convert the csharp value to the ArcObject pixel value. /// </summary> /// <param name="csharpValue">Cshapr value</param> /// <param name="pixelValueType">The pixel type of ouput value</param> /// <param name="pixelValue">Output pixel value</param> /// <returns>A value indicating whether the convention is successful</returns> public static bool CSharpValue2PixelValue(object csharpValue, rstPixelType pixelValueType, out object pixelValue) { try { switch (pixelValueType) { case rstPixelType.PT_UCHAR: pixelValue = (object)Convert.ToByte(csharpValue); return(true); case rstPixelType.PT_CHAR: pixelValue = (object)Convert.ToSByte(csharpValue); return(true); case rstPixelType.PT_SHORT: pixelValue = (object)Convert.ToInt16(csharpValue); return(true); case rstPixelType.PT_USHORT: pixelValue = (object)Convert.ToUInt16(csharpValue); return(true); case rstPixelType.PT_LONG: pixelValue = (object)Convert.ToInt32(csharpValue); return(true); case rstPixelType.PT_ULONG: pixelValue = (object)Convert.ToUInt32(csharpValue); return(true); case rstPixelType.PT_FLOAT: pixelValue = (object)Convert.ToSingle(csharpValue); return(true); case rstPixelType.PT_DOUBLE: pixelValue = (object)Convert.ToDouble(csharpValue); return(true); default: pixelValue = null; return(false); } } catch (Exception) { pixelValue = null; return(false); } }
public void Bind(object pArgument) { if (pArgument is MathFunctionArguments) { MathFunctionArguments args = (MathFunctionArguments)pArgument; inrs = args.InRaster; myFunctionHelper.Bind(inrs); myRasterInfo = myFunctionHelper.RasterInfo; myPixeltype = myRasterInfo.PixelType; myValidFlag = true; } else { throw new System.Exception("Incorrect arguments object. Expected: MathFunctionArguments"); } }
public NDVICustomFunction() { myName = "NDVI Custom Function"; myPixeltype = rstPixelType.PT_FLOAT; myDescription = "Custom NDVI Function which calculates the NDVI without any scaling."; myValidFlag = true; myFunctionHelper = new RasterFunctionHelper(); myInpPixeltype = myPixeltype; myInpNumBands = 0; myBandIndices = null; myUID = new UID(); myUID.Value = "{652642F3-9106-4EB3-9262-A4C39E03BC56}"; }
public static IRasterDataset createFileRasterDataset(IRasterWorkspace2 irasterWorkspace2_0, string string_0, int int_0, rstPixelType rstPixelType_0, ISpatialReference ispatialReference_0) { try { IRasterDataset dataset = null; IPoint origin = new Point(); origin.PutCoords(0.0, 0.0); if (ispatialReference_0 == null) { ispatialReference_0 = new UnknownCoordinateSystem() as ISpatialReference; } dataset = irasterWorkspace2_0.CreateRasterDataset(string_0, "IMAGINE Image", origin, 200, 100, 1.0, 1.0, int_0, rstPixelType_0, ispatialReference_0, true); IRawPixels pixels = null; IPixelBlock3 block = null; IPnt tlc = null; IPnt size = null; IRasterBandCollection bands = (IRasterBandCollection)dataset; pixels = (IRawPixels)bands.Item(0); IRasterProps props = (IRasterProps)pixels; tlc = new DblPnt(); tlc.SetCoords(0.0, 0.0); size = new DblPnt(); size.SetCoords((double)props.Width, (double)props.Height); block = (IPixelBlock3)pixels.CreatePixelBlock(size); pixels.Read(tlc, (IPixelBlock)block); object[,] objArray = (object[, ])block.get_PixelDataByRef(0); for (int i = 0; i < props.Width; i++) { for (int j = 0; j < props.Height; j++) { objArray[i, j] = (i * j) % 255; } } object cache = pixels.AcquireCache(); pixels.Write(tlc, (IPixelBlock)block); pixels.ReturnCache(cache); return(dataset); } catch (Exception exception) { Debug.WriteLine(exception.Message); return(null); } }
public void Bind(object pArgument) { if (pArgument is convertPixelTypeFunctionArguments) { convertPixelTypeFunctionArguments arg = (convertPixelTypeFunctionArguments)pArgument; inrs = arg.InRaster; convPType = arg.RasterPixelType; myFunctionHelper.Bind(inrs); myRasterInfo = myFunctionHelper.RasterInfo; myPixeltype = myRasterInfo.PixelType; myValidFlag = true; } else { throw new System.Exception("Incorrect arguments object. Expected: LocalFunctionArguments"); } }
/// <summary> /// Load the properties of the function from the stream provided /// </summary> /// <param name="Stream">Stream that contains the serialized form of the function</param> public void Load(IVariantStream Stream) { if (Stream is IDocumentVersion) { IDocumentVersion docVersion = (IDocumentVersion)Stream; if (docVersion.DocumentVersion >= esriArcGISVersion.esriArcGISVersion10) { esriArcGISVersion streamVersion = (esriArcGISVersion)((int)Stream.Read()); if (streamVersion >= esriArcGISVersion.esriArcGISVersion10) { myName = (string)Stream.Read(); myDescription = (string)Stream.Read(); myPixeltype = (rstPixelType)((int)Stream.Read()); } } } }
/// <summary> /// Read pixels from the input Raster and fill the PixelBlock provided with processed pixels. /// The RasterFunctionHelper object is used to handle pixel type conversion and resampling. /// The log raster is the natural log of the raster. /// </summary> /// <param name="pTlc">Point to start the reading from in the Raster</param> /// <param name="pRaster">Reference Raster for the PixelBlock</param> /// <param name="pPixelBlock">PixelBlock to be filled in</param> public void Read(IPnt pTlc, IRaster pRaster, IPixelBlock pPixelBlock) { //double vl = 0; //float pixelValue = 0f; try { //System.Array noDataValueArr = (System.Array)((IRasterProps)pRaster).NoDataValue; // Call Read method of the Raster Function Helper object. myFunctionHelper.Read(pTlc, null, pRaster, pPixelBlock); IPixelBlock3 pb3 = (IPixelBlock3)pPixelBlock; #region Load log object for (int nBand = 0; nBand < pPixelBlock.Planes; nBand++) { //float noDataValue = System.Convert.ToSingle(noDataValueArr.GetValue(nBand)); System.Array dArr = (System.Array)pb3.get_PixelData(nBand); rstPixelType pbT = pb3.get_PixelType(nBand); for (int r = 0; r < pPixelBlock.Height; r++) { for (int c = 0; c < pPixelBlock.Width; c++) { object objVl = pb3.GetVal(nBand, c, r); if (objVl == null) { continue; } else { //vl = System.Convert.ToSingle(objVl); //pixelValue = (float)getFunctionValue(vl); double objVl2 = getFunctionValue(System.Convert.ToDouble(objVl)); object newVl = rasterUtil.getSafeValue(objVl2, pbT); dArr.SetValue(newVl, c, r); } } } pb3.set_PixelData(nBand, dArr); } #endregion } catch (Exception exc) { System.Exception myExc = new System.Exception("Exception caught in Read method math Function. " + exc.Message, exc); throw myExc; } }
public void Bind(object pArgument) { if (pArgument is LocalRescaleFunctionArguments) { LocalRescaleFunctionArguments arg = (LocalRescaleFunctionArguments)pArgument; inrsBands = arg.InRaster; bndCnt = inrsBands.RasterInfo.BandCount; bndCntf = System.Convert.ToSingle(bndCnt-1); myFunctionHelper.Bind(inrsBands); myRasterInfo = myFunctionHelper.RasterInfo; myPixeltype = myRasterInfo.PixelType; myValidFlag = true; } else { throw new System.Exception("Incorrect arguments object. Expected: LocalFunctionArguments"); } }
public void Bind(object pArgument) { if (pArgument is LocalRescaleFunctionArguments) { LocalRescaleFunctionArguments arg = (LocalRescaleFunctionArguments)pArgument; inrsBands = arg.InRaster; bndCnt = inrsBands.RasterInfo.BandCount; bndCntf = System.Convert.ToSingle(bndCnt - 1); myFunctionHelper.Bind(inrsBands); myRasterInfo = myFunctionHelper.RasterInfo; myPixeltype = myRasterInfo.PixelType; myValidFlag = true; } else { throw new System.Exception("Incorrect arguments object. Expected: LocalFunctionArguments"); } }
public void Bind(object pArgument) { if (pArgument is PixelBlockToRasterFunctionArguments) { PixelBlockToRasterFunctionArguments args = (PixelBlockToRasterFunctionArguments)pArgument; inrs = args.InRaster; vPb = (IPixelBlock3)args.ValuePixelBlock; tlLoc = args.TopLeft; myFunctionHelper.Bind(inrs); myRasterInfo = myFunctionHelper.RasterInfo; myPixeltype = myRasterInfo.PixelType; myValidFlag = true; } else { throw new System.Exception("Incorrect arguments object. Expected: PixelBlockToRasterArguments"); } }
public void Bind(object pArgument) { if (pArgument is conditionalFunctionArguments) { conditionalFunctionArguments args = (conditionalFunctionArguments)pArgument; coefRs = args.CoefRaster; outRs = args.OutRaster; myFunctionHelper.Bind(outRs); myFunctionHelperCoef.Bind(coefRs); myRasterInfo = myFunctionHelper.RasterInfo; myPixeltype = myRasterInfo.PixelType; myValidFlag = true; } else { throw new System.Exception("Incorrect arguments object. Expected: Conditional arguments"); } }
public void Bind(object pArgument) { if (pArgument is LocalFunctionArguments) { LocalFunctionArguments arg = (LocalFunctionArguments)pArgument; inrsBands = arg.InRaster; inrs = arg.outRaster; myFunctionHelper.Bind(inrs); //myFunctionHelperCoef.Bind(inrsBands); myRasterInfo = myFunctionHelper.RasterInfo; myPixeltype = myRasterInfo.PixelType; myValidFlag = true; } else { throw new System.Exception("Incorrect arguments object. Expected: LocalFunctionArguments"); } }
public WatermarkFunction() { myWatermarkImagePath = ""; myBlendPercentage = 50.00; // Default value for the blending percentage. blendValue = 0.50; // Default value for the blend value. myName = "SeanWatermarkFunction"; myPixeltype = rstPixelType.PT_UNKNOWN; // Default value for the pixel type. myDescription = "Add a watermark to the request."; myValidFlag = true; myFunctionHelper = new RasterFunctionHelperClass(); myWatermarkImage = null; myUID = new UIDClass(); myUID.Value = "{" + "25BE29A6-AAF9-496E-AE73-130D5947682D" + "}"; }
private object convertVl(object outVl, rstPixelType pType) { //Console.WriteLine(myFunctionHelper.RasterInfo.PixelType.ToString()); object newVl = 0; switch (pType) { case rstPixelType.PT_CHAR: newVl = System.Convert.ToSByte(outVl); break; case rstPixelType.PT_LONG: newVl = System.Convert.ToInt32(outVl); break; case rstPixelType.PT_SHORT: newVl = System.Convert.ToInt16(outVl); break; case rstPixelType.PT_U1: newVl = System.Convert.ToBoolean(outVl); break; case rstPixelType.PT_U2: case rstPixelType.PT_U4: case rstPixelType.PT_UCHAR: //Console.WriteLine("Converting Values"); newVl = System.Convert.ToByte(outVl); break; case rstPixelType.PT_ULONG: newVl = System.Convert.ToUInt32(outVl); break; case rstPixelType.PT_USHORT: newVl = System.Convert.ToUInt16(outVl); break; default: newVl = outVl; break; } return(newVl); }
public void Bind(object pArgument) { if (pArgument is meanShiftFunctionArguments) { meanShiftFunctionArguments args = (meanShiftFunctionArguments)pArgument; inrs = args.InRaster; radius = args.Radius; valrs = args.ValueRaster; myFunctionHelper.Bind(inrs); myFunctionHelper2.Bind(valrs); myRasterInfo = myFunctionHelper.RasterInfo; myPixeltype = myRasterInfo.PixelType; myValidFlag = true; } else { throw new System.Exception("Incorrect arguments object. Expected: meanShiftArguments"); } }
public void Bind(object pArgument) { if (pArgument is pcaArguments) { pcaArguments arg = (pcaArguments)pArgument; inrsBandsCoef = arg.InRasterCoefficients; outrs = arg.OutRaster; pca = arg.PCA; myFunctionHelper.Bind(outrs); myFunctionHelperCoef.Bind(inrsBandsCoef); myRasterInfo = myFunctionHelper.RasterInfo; myPixeltype = myRasterInfo.PixelType; myValidFlag = true; } else { throw new System.Exception("Incorrect arguments object. Expected: pcaFunctionArguments"); } }
public void Bind(object pArgument) { if (pArgument is focalBandFunctionArguments) { focalBandFunctionArguments arg = (focalBandFunctionArguments)pArgument; inrsBands = arg.InRaster; myFunctionHelper.Bind(inrsBands); bandsBefore = arg.BandsBefore; bandsAfter = arg.BandsAfter; tBands = 1 + bandsBefore + bandsAfter; myRasterInfo = myFunctionHelper.RasterInfo; myPixeltype = myRasterInfo.PixelType; myValidFlag = true; } else { throw new System.Exception("Incorrect arguments object. Expected: focalBandArguments"); } }
public void Bind(object pArgument) { if (pArgument is polytomousLogisticFunctionArguments) { polytomousLogisticFunctionArguments arg = (polytomousLogisticFunctionArguments)pArgument; inrsBandsCoef = arg.InRasterCoefficients; slopes = arg.Slopes; outrs = arg.OutRaster; myFunctionHelper.Bind(outrs); myFunctionHelperCoef.Bind(inrsBandsCoef); myRasterInfo = myFunctionHelper.RasterInfo; myPixeltype = myRasterInfo.PixelType; myValidFlag = true; } else { throw new System.Exception("Incorrect arguments object. Expected: regressionFunctionArguments"); } }
Bitmap myWatermarkImage; // Watermark Image object. #endregion public WatermarkFunction() { myWatermarkImagePath = ""; myBlendPercentage = 50.00; // Default value for the blending percentage. blendValue = 0.50; // Default value for the blend value. myWatermarkLocation = esriWatermarkLocation.esriWatermarkBottomRight; myName = "WatermarkFunction"; myPixeltype = rstPixelType.PT_UNKNOWN; // Default value for the pixel type. myDescription = "Add a watermark to the request."; myValidFlag = true; myFunctionHelper = new RasterFunctionHelperClass(); myWatermarkImage = null; myUID = new UIDClass(); myUID.Value = "{" + "168721E7-7010-4a36-B886-F644437B164D" + "}"; }
public void Bind(object pArgument) { if (pArgument is tobitFunctionArguments) { tobitFunctionArguments arg = (tobitFunctionArguments)pArgument; inrsBandsCoef = arg.InRasterCoefficients; slopes = arg.Slopes; outrs = arg.OutRaster; censored = arg.CensoredValue; myFunctionHelper.Bind(outrs); myFunctionHelperCoef.Bind(inrsBandsCoef); myRasterInfo = myFunctionHelper.RasterInfo; myPixeltype = myRasterInfo.PixelType; myValidFlag = true; } else { throw new System.Exception("Incorrect arguments object. Expected: tobitnFunctionArguments"); } }
public void Bind(object pArgument) { if (pArgument is mergeFunctionArguments) { mergeFunctionArguments arg = (mergeFunctionArguments)pArgument; inrs = arg.InRaster; outrs = arg.OutRaster; //Console.WriteLine("Number of Bands in outrs = " + ((IRasterBandCollection)outrs).Count.ToString()); ftrCls = arg.Boundary; IRasterProps rsProp = (IRasterProps)outrs; myFunctionHelper.Bind(outrs); myRasterInfo = myFunctionHelper.RasterInfo; myPixeltype = myRasterInfo.PixelType; myValidFlag = true; } else { throw new System.Exception("Incorrect arguments object. Expected: mergeFunctionArguments"); } }
public void Bind(object pArgument) { if (pArgument is clipFunctionArgument) { clipFunctionArgument args = (clipFunctionArgument)pArgument; inrs = args.InRaster; outrs = args.OutRaster; noDataValue = ((System.Array)((IRasterProps)outrs).NoDataValue).GetValue(0); geo = args.Geometry; cType = args.ClipType; myFunctionHelper.Bind(outrs); myRasterInfo = myFunctionHelper.RasterInfo; myPixeltype = myRasterInfo.PixelType; myValidFlag = true; } else { throw new System.Exception("Incorrect arguments object. Expected: clipFunctonArguments"); } }
public void Bind(object pArgument) { if (pArgument is aggregationFunctionArguments) { aggregationFunctionArguments args = (aggregationFunctionArguments)pArgument; inrs = args.InRaster; orig = args.OriginalRaster; cells = args.Cells; myFunctionHelper.Bind(inrs); myFunctionHelperOrig.Bind(orig); //System.Windows.Forms.MessageBox.Show(orig.RasterInfo.CellSize.X.ToString()+"\n" + inrs.RasterInfo.CellSize.X.ToString()); myRasterInfo = myFunctionHelper.RasterInfo; myPixeltype = myRasterInfo.PixelType; myValidFlag = true; } else { throw new System.Exception("Incorrect arguments object. Expected: aggregationFunctonArguments"); } }
public void Bind(object pArgument) { if (pArgument is clusterFunctionArguments) { clusterFunctionArguments arg = (clusterFunctionArguments)pArgument; inrsBandsCoef = arg.InRasterCoefficients; outrs = arg.OutRaster; //Console.WriteLine("Number of Bands in outrs = " + ((IRasterBandCollection)outrs).Count.ToString()); cluster = (Statistics.dataPrepClusterBinary)arg.ClusterModel; myFunctionHelper.Bind(outrs); myFunctionHelperCoef.Bind(inrsBandsCoef); myRasterInfo = myFunctionHelper.RasterInfo; myPixeltype = myRasterInfo.PixelType; myValidFlag = true; } else { throw new System.Exception("Incorrect arguments object. Expected: plrFunctionArguments"); } }
/// <summary> /// Convert the csharp value to the ArcObject pixel value. /// </summary> /// <param name="csharpValue">Cshapr value</param> /// <param name="pixelValueType">The pixel type of ouput value</param> /// <param name="pixelValue">Output pixel value</param> /// <returns>A value indicating whether the convention is successful</returns> public static bool CSharpValue2PixelValue(object csharpValue, rstPixelType pixelValueType, out object pixelValue) { try { switch (pixelValueType) { case rstPixelType.PT_UCHAR: pixelValue = (object)Convert.ToByte(csharpValue); return true; case rstPixelType.PT_CHAR: pixelValue = (object)Convert.ToSByte(csharpValue); return true; case rstPixelType.PT_SHORT: pixelValue = (object)Convert.ToInt16(csharpValue); return true; case rstPixelType.PT_USHORT: pixelValue = (object)Convert.ToUInt16(csharpValue); return true; case rstPixelType.PT_LONG: pixelValue = (object)Convert.ToInt32(csharpValue); return true; case rstPixelType.PT_ULONG: pixelValue = (object)Convert.ToUInt32(csharpValue); return true; case rstPixelType.PT_FLOAT: pixelValue = (object)Convert.ToSingle(csharpValue); return true; case rstPixelType.PT_DOUBLE: pixelValue = (object)Convert.ToDouble(csharpValue); return true; default: pixelValue = null; return false; } } catch (Exception) { pixelValue = null; return false; } }
public void Bind(object pArgument) { if (pArgument is softMaxFunctionArguments) { softMaxFunctionArguments arg = (softMaxFunctionArguments)pArgument; inrsBandsCoef = arg.InRasterCoefficients; outrs = arg.OutRaster; xVls = new double[((IRasterBandCollection)inrsBandsCoef).Count]; //Console.WriteLine("Number of Bands in outrs = " + ((IRasterBandCollection)outrs).Count.ToString()); lm = arg.LogitModel; myFunctionHelper.Bind(outrs); myFunctionHelperCoef.Bind(inrsBandsCoef); myRasterInfo = myFunctionHelper.RasterInfo; myPixeltype = myRasterInfo.PixelType; myValidFlag = true; } else { throw new System.Exception("Incorrect arguments object. Expected: plrFunctionArguments"); } }
public void Bind(object pArgument) { if (pArgument is pairedttestFunctionArguments) { pairedttestFunctionArguments arg = (pairedttestFunctionArguments)pArgument; inrsBandsCoef = arg.InRasterCoefficients; outrs = arg.OutRaster; //Console.WriteLine("Number of Bands in outrs = " + ((IRasterBandCollection)outrs).Count.ToString()); tDic = arg.TTestDictionary; IRasterProps rsProp = (IRasterProps)outrs; myFunctionHelper.Bind(outrs); myFunctionHelperCoef.Bind(inrsBandsCoef); myRasterInfo = myFunctionHelper.RasterInfo; myPixeltype = myRasterInfo.PixelType; myValidFlag = true; } else { throw new System.Exception("Incorrect arguments object. Expected: plrFunctionArguments"); } }
public void Bind(object pArgument) { if (pArgument is focalSampleArguments) { focalSampleArguments args = (focalSampleArguments)pArgument; inrs = args.InRaster; orig = args.OriginalRaster; inop = args.Operation; offset = args.OffSets; getPlusWidthHeight(); myFunctionHelper.Bind(inrs); myFunctionHelperOrig.Bind(orig); myRasterInfo = myFunctionHelper.RasterInfo; myPixeltype = myRasterInfo.PixelType; myValidFlag = true; } else { throw new System.Exception("Incorrect arguments object. Expected: focalSampleFunctonArguments"); } }
public void Bind(object pArgument) { if (pArgument is regionGroupFunctionArguments) { regionGroupFunctionArguments arg = (regionGroupFunctionArguments)pArgument; inrs = arg.InRaster; outrs = arg.OutRaster; //Console.WriteLine("Number of Bands in outrs = " + ((IRasterBandCollection)outrs).Count.ToString()); rsProp = (IRasterProps)outrs; width = rsProp.Width; height = rsProp.Height; myFunctionHelper.Bind(outrs); myFunctionHelperInput.Bind(inrs); myRasterInfo = myFunctionHelper.RasterInfo; myPixeltype = myRasterInfo.PixelType; myValidFlag = true; } else { throw new System.Exception("Incorrect arguments object. Expected: randomForestArguments"); } }
public void Bind(object pArgument) { if (pArgument is LandscapeFunctionArguments) { LandscapeFunctionArguments args = (LandscapeFunctionArguments)pArgument; inrs = args.InRaster; orig = args.OriginalRaster; inop = args.Operation; landType = args.LandscapeType; inWindow = args.WindowType; clms = args.Columns; rws = args.Rows; radius = args.Radius; myFunctionHelper.Bind(inrs); myFunctionHelperCoef.Bind(orig); myRasterInfo = myFunctionHelper.RasterInfo; myPixeltype = myRasterInfo.PixelType; myValidFlag = true; } else { throw new System.Exception("Incorrect arguments object. Expected: FocalFunctonArguments"); } }
public normalization(IFunctionRasterDataset ReferenceRaster, IFunctionRasterDataset TransformRaster, int PercentChange = 20, rasterUtil rasterUtility = null) { referenceRaster = ReferenceRaster; IRasterBandCollection rsBc = (IRasterBandCollection)referenceRaster; rsType = referenceRaster.RasterInfo.PixelType; cellCount = new int[rsBc.Count]; minArray = new double[rsBc.Count]; maxArray = new double[rsBc.Count]; sumX2Array = new double[rsBc.Count]; sumXArray = new double[rsBc.Count]; sumXYArray = new double[rsBc.Count]; sumYArray = new double[rsBc.Count]; sumY2Array = new double[rsBc.Count]; coef = new double[rsBc.Count][]; blockCellCount = new int[rsBc.Count]; difDic = new Dictionary<double, int>[rsBc.Count]; for (int i = 0; i < rsBc.Count; i++) { difDic[i] = new Dictionary<double, int>(); } transformRaster = TransformRaster; pChange = System.Convert.ToDouble(PercentChange) / 200d; rsUtil = rasterUtility; }
public static void estimateStatistics(IRaster outRaster, rstPixelType pType) { IRasterBandCollection rsbco = (IRasterBandCollection)outRaster; for (int i = 0; i < rsbco.Count; i++) { IRasterBand rsBo = rsbco.Item(i); IRasterStatistics rsBStatso = rsBo.Statistics; if (rsBStatso == null) { rsBStatso = new RasterStatistics(); } switch (pType) { case rstPixelType.PT_CHAR: rsBStatso.Maximum = Char.MaxValue; rsBStatso.Minimum = Char.MinValue + 1; break; case rstPixelType.PT_FLOAT: rsBStatso.Maximum = Single.MaxValue; rsBStatso.Minimum = Single.MinValue + 1; break; case rstPixelType.PT_LONG: rsBStatso.Maximum = long.MaxValue; rsBStatso.Minimum = long.MinValue + 1; break; case rstPixelType.PT_SHORT: rsBStatso.Maximum = short.MaxValue; rsBStatso.Minimum = short.MinValue + 1; break; case rstPixelType.PT_U1: rsBStatso.Maximum = 1; rsBStatso.Minimum = 0; break; case rstPixelType.PT_U2: rsBStatso.Maximum = 3; rsBStatso.Minimum = 0; break; case rstPixelType.PT_U4: rsBStatso.Maximum = 15; rsBStatso.Minimum = 0; break; case rstPixelType.PT_UCHAR: rsBStatso.Maximum = 255; rsBStatso.Minimum = 0; break; case rstPixelType.PT_ULONG: rsBStatso.Maximum = ulong.MaxValue-1; rsBStatso.Minimum = 0; break; case rstPixelType.PT_USHORT: rsBStatso.Maximum = ushort.MaxValue-1; rsBStatso.Minimum = 0; break; default: break; } } }
/// <summary> /// Deserialize the Raster Function from the datastream provided /// </summary> /// <param name="data">Xml stream to deserialize the function from</param> public void Deserialize(IXMLSerializeData data) { myName = data.GetString(data.Find("Name")); myDescription = data.GetString(data.Find("Description")); myPixeltype = (rstPixelType)(data.GetInteger(data.Find("PixelType"))); }
public static string GetDescription(rstPixelType type) { switch (type) { case rstPixelType.PT_U1: return "U1"; case rstPixelType.PT_U2: return "U2"; case rstPixelType.PT_U4: return "U4"; case rstPixelType.PT_UCHAR: return "U8"; case rstPixelType.PT_CHAR: return "S8"; case rstPixelType.PT_USHORT: return "U16"; case rstPixelType.PT_SHORT: return "S16"; case rstPixelType.PT_ULONG: return "U32"; case rstPixelType.PT_LONG: return "S32"; case rstPixelType.PT_FLOAT: return "F32"; case rstPixelType.PT_DOUBLE: return "F64"; case rstPixelType.PT_COMPLEX: return "C64"; case rstPixelType.PT_DCOMPLEX: return "C128"; case rstPixelType.PT_UNKNOWN: default: return "UNKNOWN"; } }
private object convertVl(object outVl, rstPixelType pType) { //Console.WriteLine(myFunctionHelper.RasterInfo.PixelType.ToString()); object newVl = 0; switch (pType) { case rstPixelType.PT_CHAR: newVl = System.Convert.ToSByte(outVl); break; case rstPixelType.PT_LONG: newVl = System.Convert.ToInt32(outVl); break; case rstPixelType.PT_SHORT: newVl = System.Convert.ToInt16(outVl); break; case rstPixelType.PT_U1: newVl = System.Convert.ToBoolean(outVl); break; case rstPixelType.PT_U2: case rstPixelType.PT_U4: case rstPixelType.PT_UCHAR: //Console.WriteLine("Converting Values"); newVl = System.Convert.ToByte(outVl); break; case rstPixelType.PT_ULONG: newVl = System.Convert.ToUInt32(outVl); break; case rstPixelType.PT_USHORT: newVl = System.Convert.ToUInt16(outVl); break; default: newVl = outVl; break; } return newVl; }