Пример #1
0
 private void addRegenFields()
 {
     foreach (string s in rUnSp)
     {
         string fldNm = "RTPA_" + s;
         if (SampleFeatureClass.FindField(fldNm) > -1)
         {
         }
         else
         {
             geoDbUtil.createField(SampleFeatureClass, fldNm, esriFieldType.esriFieldTypeDouble);
         }
     }
 }
Пример #2
0
        private void fillFields()
        {
            if (rd != null)
            {
                rd.addMessage("Output table name = " + wks.PathName + "\\" + tblName);
            }
            //bool weCreate = true;
            //if (!geoUtil.ftrExists(wks, tblName))
            //{
            IFields     nflds  = new FieldsClass();
            IFieldsEdit nfldsE = (IFieldsEdit)nflds;
            IField      nfld   = new FieldClass();
            IFieldEdit  nfldE  = (IFieldEdit)nfld;

            nfldE.Name_2 = "Band";
            nfldE.Type_2 = esriFieldType.esriFieldTypeDouble;
            nfldsE.AddField(nfldE);
            IField     nfld2  = new FieldClass();
            IFieldEdit nfld2E = (IFieldEdit)nfld2;

            nfld2E.Name_2 = "Zone";
            nfld2E.Type_2 = esriFieldType.esriFieldTypeDouble;
            nfldsE.AddField(nfld2E);
            IField     nfld3  = new FieldClass();
            IFieldEdit nfld3E = (IFieldEdit)nfld3;

            nfld3E.Name_2 = "Count";
            nfld3E.Type_2 = esriFieldType.esriFieldTypeDouble;
            nfldsE.AddField(nfld3E);
            oTbl = geoUtil.createTable(wks, tblName, nflds);
            int[] fldIndex = new int[ZoneTypes.Length];
            for (int zIndex = 0; zIndex < ZoneTypes.Length; zIndex++)
            {
                string fldNm = ZoneTypes[zIndex].ToString();
                fldNm            = geoUtil.createField(oTbl, fldNm, esriFieldType.esriFieldTypeDouble);
                fldIndex[zIndex] = oTbl.FindField(fldNm);
            }
            IWorkspaceEdit wksE = (IWorkspaceEdit)wks;

            if (wksE.IsBeingEdited())
            {
                wksE.StopEditing(true);
            }
            try
            {
                int        bdIndex  = oTbl.FindField("Band");
                int        vlIndex  = oTbl.FindField("Zone");
                int        cntIndex = oTbl.FindField("Count");
                int        bndCnt   = 1;
                ICursor    cur      = oTbl.Insert(true);
                IRowBuffer rw       = oTbl.CreateRowBuffer();
                foreach (Dictionary <double, object[]> zoneValueDicOut in zoneValueDicArr)
                {
                    foreach (KeyValuePair <double, object[]> kVp in zoneValueDicOut)
                    {
                        double   key = kVp.Key;
                        object[] vl  = kVp.Value;
                        Dictionary <rasterUtil.zoneType, double> vDic = getValueDic(vl);

                        //IRow rw = null;
                        //if (!weCreate)
                        //{
                        //    string qry = "Band = " + bndCnt.ToString() + " and Zone = " + key;
                        //    IQueryFilter qf = new QueryFilterClass();
                        //    qf.WhereClause = qry;
                        //    ISelectionSet tblSelectionSet = oTbl.Select(qf, esriSelectionType.esriSelectionTypeIDSet, esriSelectionOption.esriSelectionOptionOnlyOne, wks);
                        //    if (tblSelectionSet.Count > 0)
                        //    {
                        //        int id = tblSelectionSet.IDs.Next();
                        //        rw = oTbl.GetRow(id);
                        //    }
                        //    else
                        //    {
                        //        rw = oTbl.CreateRow();
                        //    }

                        //}
                        //else
                        //{
                        //rw = oTbl.CreateRow();
                        //}
                        //Console.WriteLine(key.ToString());
                        rw.set_Value(bdIndex, bndCnt);
                        rw.set_Value(vlIndex, key);
                        rw.set_Value(cntIndex, vl[0]);
                        for (int zIndex = 0; zIndex < ZoneTypes.Length; zIndex++)// (rasterUtil.zoneType zT in ZoneTypes)
                        {
                            rasterUtil.zoneType zT = ZoneTypes[zIndex];
                            double zVl             = vDic[zT];
                            //Console.WriteLine("\t"+fldNm+ ": " + zVl.ToString());
                            rw.set_Value(fldIndex[zIndex], zVl);
                        }
                        //rw.Store();
                        cur.InsertRow(rw);
                    }
                    bndCnt += 1;
                }
                //trs.CommitTransaction();
                cur.Flush();
                System.Runtime.InteropServices.Marshal.ReleaseComObject(cur);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(rw);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                //trs.AbortTransaction();
            }
            finally
            {
            }
        }
Пример #3
0
        public static void transformData(ITable zoneTable, string linkFieldName, ITable zonalSummaryTable, string prefix = "")
        {
            string prf = "";

            if (prefix != "" && prefix != null)
            {
                prf = prefix + "_";
            }
            IObjectClassInfo2 oi2 = (IObjectClassInfo2)zoneTable;

            if (!oi2.CanBypassEditSession())
            {
                System.Windows.Forms.MessageBox.Show("Table has a composite relationship. Please export data to a simple object and try again.");
                return;
            }
            geoDatabaseUtility geoUtil = new geoDatabaseUtility();
            IFields            zsFlds  = zonalSummaryTable.Fields;
            IFields            zFlds   = zoneTable.Fields;

            foreach (string s in new string[] { "Band", "Zone", "Count" })
            {
                if (zsFlds.FindField(s) == -1)
                {
                    System.Windows.Forms.MessageBox.Show("Not a valid Zonal Summary table!!!", "Format", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                    return;
                }
            }
            if (zFlds.FindField(linkFieldName) == -1)
            {
                System.Windows.Forms.MessageBox.Show("Not a valid Zone table!!!", "Format", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                return;
            }
            IDataStatistics dStat = new DataStatisticsClass();

            dStat.Cursor = zonalSummaryTable.Search(null, false);
            dStat.Field  = "Band";
            int unqCnt = 0;

            System.Collections.IEnumerator en = dStat.UniqueValues;
            en.MoveNext();
            do
            {
                //Console.WriteLine(en.Current.ToString());
                unqCnt++;
            } while (en.MoveNext());
            int exRwCnt  = zoneTable.RowCount(null) * unqCnt;
            int sumRwCnt = zonalSummaryTable.RowCount(null);

            //Console.WriteLine("zonal*bands = " + exRwCnt.ToString() + "zoneSumCnt = " + sumRwCnt.ToString());
            if (exRwCnt != sumRwCnt)
            {
                System.Windows.Forms.MessageBox.Show("Zone and Zonal Summary tables row counts do not match! You must update your zonal statistics before running this tool!", "Format", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                return;
            }
            List <string> newFldNames = new List <string>();
            List <string> zsFldNames  = new List <string>();

            for (int i = 0; i < zsFlds.FieldCount; i++)
            {
                IField fld = zsFlds.get_Field(i);
                if (fld.Type == esriFieldType.esriFieldTypeDouble)
                {
                    string nm = fld.Name;
                    if (nm.ToLower() != "zone" && nm.ToLower() != "band")
                    {
                        zsFldNames.Add(nm);
                        for (int j = 0; j < unqCnt; j++)
                        {
                            string nnm = prf + nm + "_" + (j + 1).ToString();
                            newFldNames.Add(geoUtil.createField(zoneTable, nnm, esriFieldType.esriFieldTypeDouble, false));
                        }
                    }
                }
            }
            int[] zsFldNamesIndex = new int[zsFldNames.Count];
            for (int i = 0; i < zsFldNames.Count; i++)
            {
                string vl = zsFldNames[i];
                zsFldNamesIndex[i] = zonalSummaryTable.FindField(vl);
            }
            int[] newFldNamesIndex = new int[newFldNames.Count];
            for (int i = 0; i < newFldNames.Count; i++)
            {
                string vl = newFldNames[i];
                newFldNamesIndex[i] = zoneTable.FindField(vl);
            }
            //IQueryFilter qfz = new QueryFilterClass();
            //IQueryFilterDefinition qfzD = (IQueryFilterDefinition)qfz;
            //qfzD.PostfixClause = "ORDER BY " + linkFieldName;
            //IQueryFilter qfzs = new QueryFilterClass();
            //IQueryFilterDefinition qfzsD = (IQueryFilterDefinition)qfzs;
            //qfzsD.PostfixClause = "ORDER BY Zone, Band";
            //ICursor curZ = zoneTable.Update(qfz, false);
            //ICursor curZs = zonalSummaryTable.Search(qfzs, false);
            ITableSort tblSortZ = new TableSortClass();

            tblSortZ.Table  = zoneTable;
            tblSortZ.Fields = linkFieldName;
            ITableSort tblSortZs = new TableSortClass();

            tblSortZs.Table  = zonalSummaryTable;
            tblSortZs.Fields = "Zone, Band";
            tblSortZs.Sort(null);
            tblSortZ.Sort(null);
            ICursor curZ  = tblSortZ.Rows;
            ICursor curZs = tblSortZs.Rows;
            IRow    rwZ   = curZ.NextRow();

            while (rwZ != null)
            {
                for (int i = 0; i < unqCnt; i++)
                {
                    IRow rwZs = curZs.NextRow();
                    for (int j = 0; j < zsFldNames.Count; j++)
                    {
                        string zsN           = zsFldNames[j];
                        int    zsNIndex      = zsFldNamesIndex[j];
                        double zsVl          = System.Convert.ToDouble(rwZs.get_Value(zsNIndex));
                        string newZName      = prf + zsN + "_" + (i + 1).ToString();
                        int    newZNameIndex = newFldNamesIndex[newFldNames.IndexOf(newZName)];
                        rwZ.set_Value(newZNameIndex, zsVl);
                    }
                }
                rwZ.Store();
                //curZ.UpdateRow(rwZ);
                rwZ = curZ.NextRow();
            }
            System.Runtime.InteropServices.Marshal.ReleaseComObject(curZ);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(curZs);
        }
        public static void transformData(ITable zoneTable, string linkFieldName, ITable zonalSummaryTable, string prefix="")
        {
            string prf = "";
            if (prefix != ""&&prefix!=null) prf = prefix + "_";
            IObjectClassInfo2 oi2 = (IObjectClassInfo2)zoneTable;
            if (!oi2.CanBypassEditSession())
            {
                System.Windows.Forms.MessageBox.Show("Table has a composite relationship. Please export data to a simple object and try again.");
                return;
            }
            geoDatabaseUtility geoUtil = new geoDatabaseUtility();
            IFields zsFlds = zonalSummaryTable.Fields;
            IFields zFlds = zoneTable.Fields;
            foreach (string s in new string[] { "Band", "Zone", "Count" })
            {
                if (zsFlds.FindField(s) == -1)
                {
                    System.Windows.Forms.MessageBox.Show("Not a valid Zonal Summary table!!!", "Format", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                    return;
                }
            }
            if (zFlds.FindField(linkFieldName) == -1)
            {
                System.Windows.Forms.MessageBox.Show("Not a valid Zone table!!!", "Format", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                return;
            }
            IDataStatistics dStat = new DataStatisticsClass();
            dStat.Cursor = zonalSummaryTable.Search(null, false);
            dStat.Field = "Band";
            int unqCnt = 0;
            System.Collections.IEnumerator en = dStat.UniqueValues;
            en.MoveNext();
            do
            {
                //Console.WriteLine(en.Current.ToString());
                unqCnt++;
            } while (en.MoveNext());
            int exRwCnt = zoneTable.RowCount(null) * unqCnt;
            int sumRwCnt = zonalSummaryTable.RowCount(null);
            //Console.WriteLine("zonal*bands = " + exRwCnt.ToString() + "zoneSumCnt = " + sumRwCnt.ToString());
            if (exRwCnt != sumRwCnt)
            {

                System.Windows.Forms.MessageBox.Show("Zone and Zonal Summary tables row counts do not match! You must update your zonal statistics before running this tool!", "Format", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                return;

            }
            List<string> newFldNames = new List<string>();
            List<string> zsFldNames = new List<string>();
            for (int i = 0; i < zsFlds.FieldCount; i++)
            {
                IField fld = zsFlds.get_Field(i);
                if (fld.Type == esriFieldType.esriFieldTypeDouble)
                {
                    string nm = fld.Name;
                    if (nm.ToLower() != "zone" && nm.ToLower() != "band")
                    {
                        zsFldNames.Add(nm);
                        for (int j = 0; j < unqCnt; j++)
                        {
                            string nnm = prf+nm + "_" + (j + 1).ToString();
                            newFldNames.Add(geoUtil.createField(zoneTable, nnm, esriFieldType.esriFieldTypeDouble,false));
                        }
                    }

                }
            }
            int[] zsFldNamesIndex = new int[zsFldNames.Count];
            for (int i = 0; i < zsFldNames.Count; i++)
            {
                string vl = zsFldNames[i];
                zsFldNamesIndex[i] = zonalSummaryTable.FindField(vl);
            }
            int[] newFldNamesIndex = new int[newFldNames.Count];
            for (int i = 0; i < newFldNames.Count; i++)
            {
                string vl = newFldNames[i];
                newFldNamesIndex[i] = zoneTable.FindField(vl);
            }
            //IQueryFilter qfz = new QueryFilterClass();
            //IQueryFilterDefinition qfzD = (IQueryFilterDefinition)qfz;
            //qfzD.PostfixClause = "ORDER BY " + linkFieldName;
            //IQueryFilter qfzs = new QueryFilterClass();
            //IQueryFilterDefinition qfzsD = (IQueryFilterDefinition)qfzs;
            //qfzsD.PostfixClause = "ORDER BY Zone, Band";
            //ICursor curZ = zoneTable.Update(qfz, false);
            //ICursor curZs = zonalSummaryTable.Search(qfzs, false);
            ITableSort tblSortZ = new TableSortClass();
            tblSortZ.Table = zoneTable;
            tblSortZ.Fields = linkFieldName;
            ITableSort tblSortZs = new TableSortClass();
            tblSortZs.Table = zonalSummaryTable;
            tblSortZs.Fields = "Zone, Band";
            tblSortZs.Sort(null);
            tblSortZ.Sort(null);
            ICursor curZ = tblSortZ.Rows;
            ICursor curZs = tblSortZs.Rows;
            IRow rwZ = curZ.NextRow();
            while (rwZ != null)
            {
                for (int i = 0; i < unqCnt; i++)
                {
                    IRow rwZs = curZs.NextRow();
                    for (int j = 0; j < zsFldNames.Count; j++)
                    {
                        string zsN = zsFldNames[j];
                        int zsNIndex = zsFldNamesIndex[j];
                        double zsVl = System.Convert.ToDouble(rwZs.get_Value(zsNIndex));
                        string newZName = prf+zsN + "_" + (i + 1).ToString();
                        int newZNameIndex = newFldNamesIndex[newFldNames.IndexOf(newZName)];
                        rwZ.set_Value(newZNameIndex, zsVl);
                    }
                }
                rwZ.Store();
                //curZ.UpdateRow(rwZ);
                rwZ = curZ.NextRow();
            }
            System.Runtime.InteropServices.Marshal.ReleaseComObject(curZ);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(curZs);
        }
Пример #5
0
        /// <summary>
        /// Adds Probabilities confidence intervals to the map given the plr model
        /// </summary>

        public void addConfidenceIntervals()
        {
            IEnumerable <string> hdArr = null;
            Dictionary <string, IEnumerable <string> > vlDic = new Dictionary <string, IEnumerable <string> >();

            using (System.IO.StreamReader sr = new System.IO.StreamReader(SasOutputFile))
            {
                string ln = sr.ReadLine();
                hdArr = ln.Split(new char[] { ',' }).Skip(2);
                foreach (string s in hdArr)
                {
                    if (InTable.FindField(s) == -1)
                    {
                        geoUtil.createField(InTable, s, esriFieldType.esriFieldTypeSingle);
                    }
                }
                while ((ln = sr.ReadLine()) != null)
                {
                    string[]             vlArr   = ln.Split(new char[] { ',' });
                    string               mpCls   = vlArr[0];
                    IEnumerable <string> enumVls = vlArr.Skip(2);
                    vlDic[mpCls] = enumVls;
                }
                sr.Close();
            }
            IDataset       dSet    = (IDataset)InTable;
            IWorkspace     wks     = dSet.Workspace;
            IWorkspaceEdit wksE    = (IWorkspaceEdit)wks;
            bool           weStart = true;

            if (wksE.IsBeingEdited())
            {
                weStart = false;
            }
            else
            {
                wksE.StartEditing(false);
            }
            wksE.StartEditOperation();
            ICursor uCur     = InTable.Update(null, false);
            int     valIndex = uCur.FindField(MapField);
            IRow    uRow     = uCur.NextRow();

            while (uRow != null)
            {
                string mpVl = uRow.get_Value(valIndex).ToString();
                IEnumerable <string> vls;
                if (vlDic.TryGetValue(mpVl, out vls))
                {
                    for (int i = 0; i < hdArr.Count(); i++)
                    {
                        string fldNm    = hdArr.ElementAt(i);
                        float  fldVl    = System.Convert.ToSingle(vls.ElementAt(i));
                        int    fldIndex = uCur.FindField(fldNm);
                        uRow.set_Value(fldIndex, fldVl);
                    }
                    uCur.UpdateRow(uRow);
                }
                uRow = uCur.NextRow();
            }
            wksE.StopEditOperation();
            if (weStart)
            {
                wksE.StopEditing(true);
            }
        }
Пример #6
0
 public void RunCloudMetrics(IFeatureClass sampleLocation, float sampleRadius, string LasDir, string DtmDir = "", double cutBelow = 0, double cutAbove = 150, int shape = 0)
 {
     if (fusionInstalled)
     {
         string      LasDatasetPath  = LasDir + "\\LasFile.lasd";
         string      LasFeatureClass = LasDir + "\\LasBoundary.shp";
         ILasDataset lsDset          = new LasDatasetClass();
         ((ILasDataset2)lsDset).SaveAs(LasDatasetPath, true);
         ILasDatasetEdit lsDsetE = (ILasDatasetEdit)lsDset;
         IStringArray    sArr;
         lsDsetE.AddFolder(LasDir, "las", true, out sArr);
         lsDsetE.Save();
         ISpatialReference sp        = lsDset.SpatialReference;
         IFeatureClass     extFtrCls = geoUtil.createFeatureClass(LasFeatureClass, null, esriGeometryType.esriGeometryPolygon, sp);
         string            lasName   = geoUtil.createField(extFtrCls, "LasName", esriFieldType.esriFieldTypeString, false);
         IFeatureCursor    ftrCur    = extFtrCls.Insert(true);
         IFeatureBuffer    ftrBuff   = extFtrCls.CreateFeatureBuffer();
         int lasNameIndex            = extFtrCls.FindField(lasName);
         for (int i = 0; i < lsDset.FileCount; i++)
         {
             ILasFile  lsFile = lsDset.get_File(i);
             string    lsPath = lsFile.Name;
             IEnvelope lsEnv  = lsFile.Extent;
             IPolygon  poly   = new PolygonClass();
             poly.SpatialReference = sp;
             IPointCollection pCol = (IPointCollection)poly;
             pCol.AddPoint(lsEnv.LowerLeft);
             pCol.AddPoint(lsEnv.UpperLeft);
             pCol.AddPoint(lsEnv.UpperRight);
             pCol.AddPoint(lsEnv.LowerRight);
             poly.Close();
             ftrBuff.Shape = poly;
             ftrBuff.set_Value(lasNameIndex, lsPath);
             ftrCur.InsertFeature(ftrBuff);
         }
         ftrCur.Flush();
         System.Runtime.InteropServices.Marshal.ReleaseComObject(ftrCur);
         int[]          cloudMetricFieldsIndex = addCloudMetricFields(sampleLocation);
         IFeatureCursor pntCur = sampleLocation.Update(null, true);
         IFeature       pntftr = pntCur.NextFeature();
         while (pntftr != null)
         {
             Console.WriteLine("Working on Plot OID = " + pntftr.OID.ToString());
             IGeometry geo = pntftr.Shape;
             IPoint    pnt = (IPoint)geo;
             IEnvelope env = new EnvelopeClass();
             env.PutCoords(pnt.X - sampleRadius, pnt.Y - sampleRadius, pnt.X + sampleRadius, pnt.Y + sampleRadius);
             ISpatialFilter sf = new SpatialFilterClass();
             sf.Geometry   = env;
             sf.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
             IFeatureCursor polyCur  = extFtrCls.Search(sf, true);
             IFeature       polyftr  = polyCur.NextFeature();
             List <string>  lasFiles = new List <string>();
             while (polyftr != null)
             {
                 lasFiles.Add(polyftr.get_Value(lasNameIndex).ToString());
                 polyftr = polyCur.NextFeature();
             }
             System.Runtime.InteropServices.Marshal.ReleaseComObject(polyCur);
             if (lasFiles.Count > 0)
             {
                 //Console.WriteLine("Number of las files for point " + pntftr.OID.ToString() + " = " + lasFiles.Count.ToString());
                 object[] metricValues = extractCloudMetrics(env, lasFiles, 0, DtmDir, cutBelow, cutAbove, shape);
                 for (int i = 0; i < metricValues.Length; i++)
                 {
                     object vl      = metricValues[i];
                     int    vlIndex = cloudMetricFieldsIndex[i];
                     if (vlIndex > -1)
                     {
                         pntftr.set_Value(vlIndex, vl);
                     }
                 }
             }
             pntCur.UpdateFeature(pntftr);
             pntftr = pntCur.NextFeature();
         }
     }
 }
Пример #7
0
        private static void calcStandMeans(IFeatureClass strataFtr, IFeatureClass standsFtr, int[] meanStrataFldIndex, int[] varStrataFldIndex, int[] countFldStrataIndex, IField[] fldsToSummarize, geoDatabaseUtility geoUtil)
        {
            int cnt = 0;

            int[] ptFldIndex   = new int[fldsToSummarize.Length];
            int[] meanFldIndex = new int[fldsToSummarize.Length];
            int[] varFldIndex  = new int[fldsToSummarize.Length];
            int[] cntFldIndex  = new int[fldsToSummarize.Length];
            foreach (IField fld in fldsToSummarize)
            {
                string sName = geoUtil.createField(standsFtr, "v_" + fld.Name, esriFieldType.esriFieldTypeDouble, false);
                varFldIndex[cnt] = standsFtr.FindField(sName);
                string mName = geoUtil.createField(standsFtr, "m_" + fld.Name, esriFieldType.esriFieldTypeDouble, false);
                meanFldIndex[cnt] = standsFtr.FindField(mName);
                string cName = geoUtil.createField(standsFtr, "n_" + fld.Name, esriFieldType.esriFieldTypeDouble, false);
                cntFldIndex[cnt] = standsFtr.FindField(cName);
                cnt++;
            }
            IFeatureCursor uCur = standsFtr.Update(null, true);
            IFeature       uFtr = uCur.NextFeature();

            while (uFtr != null)
            {
                ESRI.ArcGIS.Geometry.IGeometry geo = uFtr.Shape;
                ISpatialFilter spFlt = new SpatialFilter();
                spFlt.Geometry   = geo;
                spFlt.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                double         totalArea = 0;
                IFeatureCursor sCur      = strataFtr.Search(spFlt, true);
                IFeature       sFtr      = sCur.NextFeature();
                double[][]     vlArr     = new double[meanFldIndex.Length][];
                for (int i = 0; i < meanFldIndex.Length; i++)
                {
                    vlArr[i] = new double[3];
                }
                while (sFtr != null)
                {
                    ESRI.ArcGIS.Geometry.IGeometry             sgeo  = sFtr.Shape;
                    ESRI.ArcGIS.Geometry.ITopologicalOperator4 topo  = (ESRI.ArcGIS.Geometry.ITopologicalOperator4)sgeo;
                    ESRI.ArcGIS.Geometry.IGeometry             sgeo2 = topo.Intersect(geo, ESRI.ArcGIS.Geometry.esriGeometryDimension.esriGeometry2Dimension);
                    double subArea = (((ESRI.ArcGIS.Geometry.IArea)sgeo2).Area);
                    totalArea += subArea;
                    for (int i = 0; i < meanFldIndex.Length; i++)
                    {
                        vlArr[i][0] += System.Convert.ToDouble(sFtr.get_Value(meanStrataFldIndex[i])) * subArea;
                        vlArr[i][1] += System.Convert.ToDouble(sFtr.get_Value(varStrataFldIndex[i])) * subArea;
                        vlArr[i][2] += System.Convert.ToDouble(sFtr.get_Value(countFldStrataIndex[i]));
                    }
                    sFtr = sCur.NextFeature();
                }
                System.Runtime.InteropServices.Marshal.ReleaseComObject(sCur);
                if (totalArea != 0)
                {
                    for (int i = 0; i < meanFldIndex.Length; i++)
                    {
                        uFtr.set_Value(meanFldIndex[i], vlArr[i][0] / totalArea);
                        uFtr.set_Value(varFldIndex[i], vlArr[i][1] / totalArea);
                        uFtr.set_Value(cntFldIndex[i], vlArr[i][2]);
                    }
                    uCur.UpdateFeature(uFtr);
                }
                uFtr = uCur.NextFeature();
            }
            System.Runtime.InteropServices.Marshal.ReleaseComObject(uCur);
        }