Beispiel #1
0
        private void btnHistogram_Click(object sender, EventArgs e)
        {
            try
            {
                string strLayerName = cboTargetLayer.Text;
                string strFieldName = cboFieldName.Text;

                m_pForm       = System.Windows.Forms.Application.OpenForms["MainForm"] as MainForm;
                m_pActiveView = m_pForm.axMapControl1.ActiveView;

                int intLIndex = m_pSnippet.GetIndexNumberFromLayerName(m_pActiveView, strLayerName);
                if (intLIndex == -1)
                {
                    return;
                }

                int intNFeatureCount = 0;

                ILayer        pLayer  = m_pForm.axMapControl1.get_Layer(intLIndex);
                IFeatureLayer pFLayer = (IFeatureLayer)pLayer;

                IFeatureCursor pFCursor = pFLayer.Search(null, true);
                intNFeatureCount = pFLayer.FeatureClass.FeatureCount(null);

                if (intNFeatureCount == 0)
                {
                    return;
                }

                IFeature pFeature = pFCursor.NextFeature();

                int intFieldIdx = pFLayer.FeatureClass.Fields.FindField(strFieldName);

                double[] arrValue = new double[intNFeatureCount];

                int i = 0;
                while (pFeature != null)
                {
                    arrValue[i] = Convert.ToDouble(pFeature.get_Value(intFieldIdx));
                    i++;
                    pFeature = pFCursor.NextFeature();
                }

                //This procedure is not working in ArcGIS 10.5 022417HK
                //IDataHistogram pDataHistogram = new DataHistogramClass();
                ////DataHistogram pDataHistogram = new DataHistogramClass();

                ////IDataHistogram pDataHistogram = new DataHistogram();
                //pDataHistogram.SetData(arrValue);
                //    IBasicHistogram pHistogram = (IBasicHistogram)pDataHistogram;

                //    object xVals, frqs;
                //    pHistogram.GetHistogram(out xVals, out frqs);

                //    IClassifyGEN pClassifyGEN = new EqualIntervalClass();

                //    int intBreakCount = Convert.ToInt32(nudBinsCnt.Value);
                //    pClassifyGEN.Classify(xVals, frqs, intBreakCount);

                //    double[] cb = (double[])pClassifyGEN.ClassBreaks;
                //    Double[] vecMids = new Double[intBreakCount];
                //    for (int j = 0; j < cb.Length - 1; j++)
                //    {
                //        vecMids[j] = (cb[j + 1] + cb[j]) / 2.0F;

                //    }

                //    Double[] vecCounts = new Double[intBreakCount];


                //    for (int j = 0; j < arrValue.Length; j++)
                //    {
                //        for (int k = 0; k < intBreakCount; k++)
                //        {
                //            if (arrValue[j] >= cb[k] && arrValue[j] <= cb[k + 1])
                //                vecCounts[k]++;
                //        }
                //    }
                int intBreakCount = Convert.ToInt32(nudBinsCnt.Value) - 1;

                NumericVector vecValue = m_pEngine.CreateNumericVector(arrValue);
                m_pEngine.SetSymbol(strFieldName, vecValue);

                m_pEngine.Evaluate("hist.sample <- hist(" + strFieldName + ", plot = FALSE, nclass=" + intBreakCount.ToString() + ")");

                Double[] vecMids   = m_pEngine.Evaluate("hist.sample$mids").AsNumeric().ToArray();
                Double[] vecCounts = m_pEngine.Evaluate("hist.sample$counts").AsNumeric().ToArray();
                Double[] dblBreaks = m_pEngine.Evaluate("hist.sample$breaks").AsNumeric().ToArray();

                frmHistResults pfrmTemp = new frmHistResults();
                pfrmTemp.Text = "Histogram of " + pFLayer.Name;
                pfrmTemp.pChart.Series.Clear();

                var series1 = new System.Windows.Forms.DataVisualization.Charting.Series
                {
                    Name              = "Series1",
                    Color             = System.Drawing.Color.White,
                    BorderColor       = System.Drawing.Color.Black,
                    IsVisibleInLegend = false,
                    IsXValueIndexed   = true,
                    ChartType         = SeriesChartType.Column,
                };

                pfrmTemp.pChart.Series.Add(series1);

                int intNBins = vecMids.Length;

                for (int j = 0; j < intNBins; j++)
                {
                    series1.Points.AddXY(vecMids[j], vecCounts[j]);
                }

                pfrmTemp.pChart.Series[0]["PointWidth"]   = "1";
                pfrmTemp.pChart.ChartAreas[0].AxisX.Title = strFieldName;
                pfrmTemp.pChart.ChartAreas[0].AxisY.Title = "Frequency";

                pfrmTemp.pChart.ChartAreas[0].AxisX.MajorTickMark.Enabled = false;

                pfrmTemp.dblBreaks    = dblBreaks;
                pfrmTemp.m_pForm      = m_pForm;
                pfrmTemp.pActiveView  = m_pActiveView;
                pfrmTemp.pFLayer      = pFLayer;
                pfrmTemp.strFieldName = strFieldName;
                pfrmTemp.intNBins     = intNBins;
                pfrmTemp.vecCounts    = vecCounts;
                pfrmTemp.vecMids      = vecMids;

                double dblInterval      = dblBreaks[1] - dblBreaks[0];
                int    intDecimalPlaces = 1;
                string strDecimalPlaces = "N" + intDecimalPlaces.ToString();
                for (int n = 0; n < dblBreaks.Length; n++)
                {
                    CustomLabel pcutsomLabel = new CustomLabel();
                    pcutsomLabel.FromPosition = n;
                    pcutsomLabel.ToPosition   = n + 1;
                    pcutsomLabel.Text         = dblBreaks[n].ToString(strDecimalPlaces);

                    pfrmTemp.pChart.ChartAreas[0].AxisX.CustomLabels.Add(pcutsomLabel);
                }

                pfrmTemp.Show();
                //this.Close();
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }
Beispiel #2
0
        public string RemoveWarningByBrushingTechnique(IFeatureLayer pFLayer)
        {
            //try
            //{
            FormCollection pFormCollection = System.Windows.Forms.Application.OpenForms;
            //IActiveView pActiveView = mForm.axMapControl1.ActiveView;
            string strRelatedPlotName = string.Empty;

            for (int j = 0; j < pFormCollection.Count; j++)
            {
                if (pFormCollection[j].Name == "frmHistResults")//Brushing to Histogram
                {
                    frmHistResults pfrmHistResults = pFormCollection[j] as frmHistResults;
                    if (pfrmHistResults.pFLayer == pFLayer)
                    {
                        strRelatedPlotName += "Histogram, ";
                    }
                }
                if (pFormCollection[j].Name == "frmScatterPlotResults") //Brushing to Scatterplot
                {
                    frmScatterPlotResults pfrmPointsPlot = pFormCollection[j] as frmScatterPlotResults;
                    if (pfrmPointsPlot.m_pFLayer == pFLayer)
                    {
                        strRelatedPlotName += "Scatter plot, ";
                    }
                }
                if (pFormCollection[j].Name == "frmQQPlotResults") //Brushing to QQPlot
                {
                    frmQQPlotResults pfrmQQPlotResult = pFormCollection[j] as frmQQPlotResults;
                    if (pfrmQQPlotResult.m_pFLayer == pFLayer)
                    {
                        strRelatedPlotName += "QQ-plot, ";
                    }
                }
                //if (pFormCollection[j].Name == "frmAttributeTable")//Brushing to AttributeTable
                //{
                //    frmAttributeTable pfrmAttTable = pFormCollection[j] as frmAttributeTable;
                //    BrushingToAttTable(pfrmAttTable, pFLayer, featureSelection);
                //}
                if (pFormCollection[j].Name == "frmBoxPlotResults")//Brushing to AttributeTable
                {
                    frmBoxPlotResults pfrmBoxPlotResult = pFormCollection[j] as frmBoxPlotResults;
                    if (pfrmBoxPlotResult.pFLayer == pFLayer)
                    {
                        strRelatedPlotName += "Boxplot, ";
                    }
                }
                //if (pFormCollection[j].Name == "frmClassificationGraph")//Brushing to Optiize Graph
                //{
                //    frmClassificationGraph pfrmClassGraph = pFormCollection[j] as frmClassificationGraph;
                //    BrushingToOptimizeGraph(pfrmClassGraph, pFLayer, featureSelection);
                //}
                //if (pFormCollection[j].Name == "frmCSDesign")//Brushing to CS Graph
                //{
                //    frmCSDesign pfrmCSDesign = pFormCollection[j] as frmCSDesign;
                //    if (pfrmCSDesign.pFLayer == pFLayer)
                //        strRelatedPlotName += "Uncertainty Classification, ";
                //}
                if (pFormCollection[j].Name == "frmMScatterResults")//Brushing to Moran ScatterPlot
                {
                    frmMScatterResults pfrmMScatterPlot = pFormCollection[j] as frmMScatterResults;
                    if (pfrmMScatterPlot.m_pFLayer == pFLayer)
                    {
                        strRelatedPlotName += "Moran Scatter Plot, ";
                    }
                }
            }
            if (strRelatedPlotName != string.Empty)
            {
                strRelatedPlotName = strRelatedPlotName.Remove(strRelatedPlotName.Length - 2);
            }
            return(strRelatedPlotName);
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show("Exception:" + ex.Message);
            //    return;
            //}
        }
Beispiel #3
0
        private void BrushingToHistogram(frmHistResults pfrmHistResults, IFeatureLayer pFLayer, IFeatureSelection featureSelection)
        {
            try
            {
                if (pfrmHistResults.pFLayer == pFLayer)
                {
                    IFeatureClass pFeatureClass = pFLayer.FeatureClass;
                    int           intVarIdx     = pFeatureClass.FindField(pfrmHistResults.strFieldName);

                    ICursor pCursor = null;
                    featureSelection.SelectionSet.Search(null, false, out pCursor);
                    IRow pRow = pCursor.NextRow();

                    var series2 = new System.Windows.Forms.DataVisualization.Charting.Series
                    {
                        Name              = "SelSeries",
                        Color             = System.Drawing.Color.Red,
                        BorderColor       = System.Drawing.Color.Black,
                        BackHatchStyle    = ChartHatchStyle.DiagonalCross,
                        IsVisibleInLegend = false,
                        IsXValueIndexed   = true,
                        ChartType         = SeriesChartType.StackedColumn,
                    };

                    var series1 = new System.Windows.Forms.DataVisualization.Charting.Series
                    {
                        Name              = "Series1",
                        Color             = System.Drawing.Color.White,
                        BorderColor       = System.Drawing.Color.Black,
                        IsVisibleInLegend = false,
                        IsXValueIndexed   = true,
                        ChartType         = SeriesChartType.StackedColumn,
                    };
                    var checkDup1 = pfrmHistResults.pChart.Series.FindByName("Series1");
                    if (checkDup1 != null)
                    {
                        if (pfrmHistResults.pChart.Series.Count == 1)
                        {
                            pfrmHistResults.pChart.Series.RemoveAt(0);
                        }
                        else
                        {
                            pfrmHistResults.pChart.Series.RemoveAt(1);
                        }
                    }

                    var checkDup2 = pfrmHistResults.pChart.Series.FindByName("SelSeries");
                    if (checkDup2 != null)
                    {
                        pfrmHistResults.pChart.Series.RemoveAt(0);
                    }

                    pfrmHistResults.pChart.Series.Add(series2);
                    pfrmHistResults.pChart.Series.Add(series1);

                    int      intNBins       = pfrmHistResults.intNBins;
                    int[]    intFrequencies = new int[intNBins];
                    Double[] vecMids        = pfrmHistResults.vecMids;
                    Double[] dblBreaks      = pfrmHistResults.dblBreaks;
                    Double[] vecCounts      = pfrmHistResults.vecCounts;

                    while (pRow != null)
                    {
                        double dblValue = Convert.ToDouble(pRow.get_Value(intVarIdx));
                        for (int j = 0; j < intNBins; j++)
                        {
                            if (dblValue > dblBreaks[j] && dblValue <= dblBreaks[j + 1])
                            {
                                intFrequencies[j] = intFrequencies[j] + 1;
                            }
                        }
                        pRow = pCursor.NextRow();
                    }

                    for (int j = 0; j < intNBins; j++)
                    {
                        series1.Points.AddXY(vecMids[j], vecCounts[j] - intFrequencies[j]);
                        series2.Points.AddXY(vecMids[j], intFrequencies[j]);
                    }

                    pfrmHistResults.pChart.Series[1]["PointWidth"] = "1";
                    pfrmHistResults.pChart.Series[0]["PointWidth"] = "1";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception:" + ex.Message);
                return;
            }
        }
Beispiel #4
0
        public void BrushingToOthers(IFeatureLayer pFLayer, IntPtr intPtrParent)
        {
            try
            {
                FormCollection pFormCollection = System.Windows.Forms.Application.OpenForms;
                //IActiveView pActiveView = mForm.axMapControl1.ActiveView;

                if (pFLayer.Visible)
                {
                    //Brushing to Mapcontrol
                    string            ShapeFieldName   = pFLayer.FeatureClass.ShapeFieldName;
                    IFeatureSelection featureSelection = (IFeatureSelection)pFLayer;


                    for (int j = 0; j < pFormCollection.Count; j++)
                    {
                        if (pFormCollection[j].Handle != intPtrParent)       // Brushing to Others
                        {
                            if (pFormCollection[j].Name == "frmHistResults") //Brushing to Histogram
                            {
                                frmHistResults pfrmHistResults = pFormCollection[j] as frmHistResults;
                                BrushingToHistogram(pfrmHistResults, pFLayer, featureSelection);
                            }
                            if (pFormCollection[j].Name == "frmScatterPlotResults") //Brushing to Scatterplot
                            {
                                frmScatterPlotResults pfrmPointsPlot = pFormCollection[j] as frmScatterPlotResults;
                                BrushingToScatterPlot(pfrmPointsPlot, pFLayer, featureSelection);
                            }
                            if (pFormCollection[j].Name == "frmQQPlotResults") //Brushing to QQPlot
                            {
                                frmQQPlotResults pfrmQQPlotResult = pFormCollection[j] as frmQQPlotResults;
                                BrushingToQQPlot(pfrmQQPlotResult, pFLayer, featureSelection);
                            }
                            if (pFormCollection[j].Name == "frmAttributeTable")//Brushing to AttributeTable
                            {
                                frmAttributeTable pfrmAttTable = pFormCollection[j] as frmAttributeTable;
                                BrushingToAttTable(pfrmAttTable, pFLayer, featureSelection);
                            }
                            if (pFormCollection[j].Name == "frmBoxPlotResults")//Brushing to AttributeTable
                            {
                                frmBoxPlotResults pfrmBoxPlotResult = pFormCollection[j] as frmBoxPlotResults;
                                BrushingToBoxPlot(pfrmBoxPlotResult, pFLayer, featureSelection);
                            }
                            //if (pFormCollection[j].Name == "frmClassificationGraph")//Brushing to Optiize Graph
                            //{
                            //    frmClassificationGraph pfrmClassGraph = pFormCollection[j] as frmClassificationGraph;
                            //    BrushingToOptimizeGraph(pfrmClassGraph, pFLayer, featureSelection);
                            //}
                            //if (pFormCollection[j].Name == "frmCSDesign")//Brushing to CS Graph
                            //{
                            //    frmCSDesign pfrmCSDesign = pFormCollection[j] as frmCSDesign;
                            //    BrushingToClassSepGraph(pfrmCSDesign, pFLayer, featureSelection);
                            //}
                            if (pFormCollection[j].Name == "frmMScatterResults")//Brushing to Moran ScatterPlot
                            {
                                frmMScatterResults pfrmMScatterPlot = pFormCollection[j] as frmMScatterResults;
                                BrushingToMScatterPlot(pfrmMScatterPlot, pFLayer, featureSelection);
                            }
                            if (pFormCollection[j].Name == "frmCCMapsResults")//Brushing to Moran ScatterPlot
                            {
                                frmCCMapsResults pfrmCCMApsResults = pFormCollection[j] as frmCCMapsResults;
                                BrushingToCCMaps(pfrmCCMApsResults, pFLayer, featureSelection);
                            }
                            if (pFormCollection[j].Name == "frmBoxCox")//Brushing to Box-Cox transformation tool
                            {
                                frmBoxCox pfrmBoxCox = pFormCollection[j] as frmBoxCox;
                                BrushingToBoxCox(pfrmBoxCox, pFLayer, featureSelection);
                            }
                            if (pFormCollection[j].Name == "frmCorrelogram_local")//Brushing to Correlogram
                            {
                                frmCorrelogram_local pfrmCorrelogram = pFormCollection[j] as frmCorrelogram_local;
                                BrushingToCorrelogram(pfrmCorrelogram, pFLayer, featureSelection);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception:" + ex.Message);
                return;
            }
        }
Beispiel #5
0
        public void CloseAllRelatedPlots(IFeatureLayer pFLayer)
        {
            //try
            //{
            FormCollection pFormCollection = System.Windows.Forms.Application.OpenForms;
            List <int>     lstPlotIdx      = new List <int>();

            for (int j = 0; j < pFormCollection.Count; j++)
            {
                if (pFormCollection[j].Name == "frmHistResults")//Brushing to Histogram
                {
                    frmHistResults pfrmHistResults = pFormCollection[j] as frmHistResults;
                    if (pfrmHistResults.pFLayer == pFLayer)
                    {
                        lstPlotIdx.Add(j);
                    }
                }
                if (pFormCollection[j].Name == "frmScatterPlotResults") //Brushing to Scatterplot
                {
                    frmScatterPlotResults pfrmPointsPlot = pFormCollection[j] as frmScatterPlotResults;
                    if (pfrmPointsPlot.m_pFLayer == pFLayer)
                    {
                        lstPlotIdx.Add(j);
                    }
                }
                if (pFormCollection[j].Name == "frmQQPlotResults") //Brushing to QQPlot
                {
                    frmQQPlotResults pfrmQQPlotResult = pFormCollection[j] as frmQQPlotResults;
                    if (pfrmQQPlotResult.m_pFLayer == pFLayer)
                    {
                        lstPlotIdx.Add(j);
                    }
                }
                if (pFormCollection[j].Name == "frmAttributeTable")//Brushing to AttributeTable
                {
                    frmAttributeTable pfrmAttTable = pFormCollection[j] as frmAttributeTable;
                    if (pfrmAttTable.m_pLayer == (ILayer)pFLayer)
                    {
                        lstPlotIdx.Add(j);
                    }
                }
                if (pFormCollection[j].Name == "frmBoxPlotResults")//Brushing to AttributeTable
                {
                    frmBoxPlotResults pfrmBoxPlotResult = pFormCollection[j] as frmBoxPlotResults;
                    if (pfrmBoxPlotResult.pFLayer == pFLayer)
                    {
                        lstPlotIdx.Add(j);
                    }
                }
                //if (pFormCollection[j].Name == "frmClassificationGraph")//Brushing to Optiize Graph
                //{
                //    frmClassificationGraph pfrmClassGraph = pFormCollection[j] as frmClassificationGraph;
                //    BrushingToOptimizeGraph(pfrmClassGraph, pFLayer, featureSelection);
                //}
                //if (pFormCollection[j].Name == "frmCSDesign")//Brushing to CS Graph
                //{
                //    frmCSDesign pfrmCSDesign = pFormCollection[j] as frmCSDesign;
                //    if (pfrmCSDesign.pFLayer == pFLayer)
                //        lstPlotIdx.Add(j);
                //}
                if (pFormCollection[j].Name == "frmMScatterResults")//Brushing to Moran ScatterPlot
                {
                    frmMScatterResults pfrmMScatterPlot = pFormCollection[j] as frmMScatterResults;
                    if (pfrmMScatterPlot.m_pFLayer == pFLayer)
                    {
                        lstPlotIdx.Add(j);
                    }
                }
                if (pFormCollection[j].Name == "frmCorrelogram_local")//Brushing to Correlogram
                {
                    frmCorrelogram_local pfrmCorrelogram = pFormCollection[j] as frmCorrelogram_local;
                    if (pfrmCorrelogram.m_pFLayer == pFLayer)
                    {
                        lstPlotIdx.Add(j);
                    }
                }
            }

            lstPlotIdx.Sort();
            for (int j = lstPlotIdx.Count - 1; j >= 0; j--)
            {
                pFormCollection[lstPlotIdx[j]].Close();
            }
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show("Exception:" + ex.Message);
            //    return;
            //}
        }
Beispiel #6
0
        public int RemoveBrushing(MainForm mForm, IFeatureLayer pFLayer)
        {
            try
            {
                FormCollection pFormCollection = System.Windows.Forms.Application.OpenForms;
                IActiveView    pActiveView     = mForm.axMapControl1.ActiveView;
                int            intFormCnt      = 0;
                if (pFLayer.Visible)
                {
                    //Brushing to Mapcontrol
                    string ShapeFieldName = pFLayer.FeatureClass.ShapeFieldName;
                    //IFeatureSelection featureSelection = (IFeatureSelection)pFLayer;


                    for (int j = 0; j < pFormCollection.Count; j++)
                    {
                        if (pFormCollection[j].Name == "frmHistResults")//Brushing to Histogram
                        {
                            frmHistResults pfrmHistResults = pFormCollection[j] as frmHistResults;
                            if (pfrmHistResults.pFLayer == pFLayer)
                            {
                                intFormCnt++;
                            }
                        }
                        if (pFormCollection[j].Name == "frmScatterPlotResults") //Brushing to Scatterplot
                        {
                            frmScatterPlotResults pfrmPointsPlot = pFormCollection[j] as frmScatterPlotResults;
                            if (pfrmPointsPlot.m_pFLayer == pFLayer)
                            {
                                intFormCnt++;
                            }
                        }
                        if (pFormCollection[j].Name == "frmQQPlotResults") //Brushing to QQPlot
                        {
                            frmQQPlotResults pfrmQQPlotResult = pFormCollection[j] as frmQQPlotResults;
                            if (pfrmQQPlotResult.m_pFLayer == pFLayer)
                            {
                                intFormCnt++;
                            }
                        }
                        if (pFormCollection[j].Name == "frmAttributeTable")//Brushing to AttributeTable
                        {
                            frmAttributeTable pfrmAttTable = pFormCollection[j] as frmAttributeTable;
                            if ((IFeatureLayer)pfrmAttTable.m_pLayer == pFLayer)
                            {
                                intFormCnt++;
                            }
                        }
                        if (pFormCollection[j].Name == "frmBoxPlotResults")//Brushing to AttributeTable
                        {
                            frmBoxPlotResults pfrmBoxPlotResult = pFormCollection[j] as frmBoxPlotResults;
                            if (pfrmBoxPlotResult.pFLayer == pFLayer)
                            {
                                intFormCnt++;
                            }
                        }
                        //if (pFormCollection[j].Name == "frmClassificationGraph")//Brushing to Optiize Graph
                        //{
                        //    frmClassificationGraph pfrmClassGraph = pFormCollection[j] as frmClassificationGraph;
                        //    if (pfrmClassGraph.m_pFLayer == pFLayer)
                        //        intFormCnt++;
                        //}
                        if (pFormCollection[j].Name == "frmMScatterResults")//Brushing to Moran ScatterPlot
                        {
                            frmMScatterResults pfrmMScatterPlot = pFormCollection[j] as frmMScatterResults;
                            if (pfrmMScatterPlot.m_pFLayer == pFLayer)
                            {
                                intFormCnt++;
                            }
                        }
                    }
                    return(intFormCnt);
                }
                else
                {
                    return(-1);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception:" + ex.Message);
                return(-1);
            }
        }