private void InitGradeChart()
        {
            List <int> groupedGrades = ComputeStatistics.GroupGrades(grades);

            gradeChart.Series = new SeriesCollection {
                new ColumnSeries
                {
                    Title  = "Grades",
                    Values = new ChartValues <int>
                    {
                        groupedGrades[0],
                        groupedGrades[1],
                        groupedGrades[2],
                        groupedGrades[3],
                        groupedGrades[4],
                        groupedGrades[5],
                        groupedGrades[6],
                        groupedGrades[7],
                        groupedGrades[8],
                        groupedGrades[9]
                    }
                }
            };
            gradeChart.AxisX = new AxesCollection {
                new Axis
                {
                    Title  = "Grade",
                    Labels = new[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }
                }
            };
            gradeChart.AxisY = new AxesCollection {
                new Axis
                {
                    Title          = "Number of Students",
                    LabelFormatter = value => value.ToString("N")
                }
            };
            averageGradeLabel.Text = "Average: " +
                                     ComputeStatistics.ComputeAverageSingles(grades).ToString();
            string mostCommon = "Most Common: ";

            foreach (int i in ComputeStatistics.ComputeMostCommonSingles(grades))
            {
                mostCommon += i.ToString() + " ";
            }
            mostCommonGradeLabel.Text = mostCommon;
            medianGradeLabel.Text     = "Median: " +
                                        ComputeStatistics.ComputeMedianSingles(grades).ToString();
            varianceGradeLabel.Text = "Variance: " +
                                      ComputeStatistics.ComputeVarianceSingles(grades).ToString();
        }
        private void InitSelfStudyHoursChart()
        {
            double[] groupedHours = ComputeStatistics.GroupHours(selfStudyHours);
            selfStudyHoursChart.Series = new SeriesCollection {
                new RowSeries
                {
                    Title  = "selfStudy Hours",
                    Values = new ChartValues <double>
                    {
                        groupedHours[0] / ratings.Count,
                        groupedHours[1] / ratings.Count,
                        groupedHours[2] / ratings.Count,
                        groupedHours[3] / ratings.Count,
                        groupedHours[4] / ratings.Count,
                    }
                }
            };
            selfStudyHoursChart.AxisY = new AxesCollection {
                new Axis
                {
                    Title  = "Hours per week",
                    Labels = new[] { "0-1", "2-3", "4-5", "6-7", "8+" }
                }
            };
            selfStudyHoursChart.AxisX = new AxesCollection {
                new Axis
                {
                    Title          = "% of Ratings",
                    LabelFormatter = value => value.ToString("N")
                }
            };
            averageSelfStudyHoursLabel.Text = "Average: " +
                                              ComputeStatistics.ComputeAverageSingles(selfStudyHours).ToString();
            string mostCommon = "Most Common: ";

            foreach (int i in ComputeStatistics.ComputeMostCommonSingles(selfStudyHours))
            {
                mostCommon += i.ToString() + " ";
            }
            mostCommonSelfStudyHoursLabel.Text = mostCommon;
            medianSelfStudyHoursLabel.Text     = "Median: " +
                                                 ComputeStatistics.ComputeMedianSingles(selfStudyHours).ToString();
            varianceSelfStudyHoursLabel.Text = "Variance: " +
                                               ComputeStatistics.ComputeVarianceSingles(selfStudyHours).ToString();
        }
        private void InitOverallChart()
        {
            overallRatingChart.Series = new SeriesCollection
            {
                new ColumnSeries
                {
                    Title  = "Overall Ratings",
                    Values = new ChartValues <double>
                    {
                        overallRatings[0] / ratings.Count,
                        overallRatings[1] / ratings.Count,
                        overallRatings[2] / ratings.Count,
                        overallRatings[3] / ratings.Count,
                        overallRatings[4] / ratings.Count
                    }
                }
            };
            overallRatingChart.AxisX = new AxesCollection {
                new Axis
                {
                    Title  = "Ratings",
                    Labels = new List <string> {
                        "1", "2", "3", "4", "5"
                    }
                }
            };
            overallRatingChart.AxisY = new AxesCollection {
                new Axis
                {
                    Title          = "% of Ratings",
                    LabelFormatter = value => (value * 100).ToString("N")
                }
            };
            averageOverallRatingLabel.Text = "Average: " + ComputeStatistics.ComputeAverageGrouped(overallRatings);
            string mostCommon = "Most Common: ";

            foreach (int i in ComputeStatistics.ComputeMostCommonGrouped(overallRatings))
            {
                mostCommon += i.ToString() + " ";
            }
            mostCommonOverallRatingLabel.Text = mostCommon;
            medianOverallRatingLabel.Text     = "Median: " + ComputeStatistics.ComputeMedianGrouped(overallRatings);
            varianceOverallRatingLabel.Text   = "Variance: " + ComputeStatistics.ComputeVarianceGrouped(overallRatings);
        }
        public void InitPassedChart()
        {
            int[] passed = ComputeStatistics.GroupPassed(gradesAndPassed);
            Func <ChartPoint, string> labelPoint = chartPoint => string.Format("{0} ({1:P})", chartPoint.Y, chartPoint.Participation);

            passedChart.Series = new SeriesCollection
            {
                new PieSeries
                {
                    Title  = "Passed on first try",
                    Values = new ChartValues <int> {
                        passed[0]
                    },
                    DataLabels = true,
                    LabelPoint = labelPoint
                },
                new PieSeries
                {
                    Title  = "Passed on second try",
                    Values = new ChartValues <int> {
                        passed[1]
                    },
                    DataLabels = true,
                    LabelPoint = labelPoint
                },
                new PieSeries
                {
                    Title  = "Failed",
                    Values = new ChartValues <int> {
                        passed[2]
                    },
                    DataLabels = true,
                    LabelPoint = labelPoint
                }
            };
        }
Пример #5
0
        static void Main(string[] args)
        {
            //string inputShapeFile = @"D:\Ashis_Work\GDAL Utilities\sample-data\FromErik\ns_lev05.shp";
            //string inputShapeFile = @"D:\Ashis_Work\GDAL Utilities\sample-data\FromErik2\smallish dataset\polygons.shp";
            //string inputShapeFile = @"D:\Ashis_Work\GDAL Utilities\sample-data\FromErik2\TEUI_5__Test_data\state_boundaries_us_100k.shp";
            //string inputShapeFile = @"D:\Ashis_Work\GDAL Utilities\sample-data\UtahGrid\Counties.shp";
            string inputShapeFile = @"D:\Ashis_Work\GDAL Utilities\sample-data\Geodatabase\EsriZonalOutputs.gdb\Counties";


            AttributeField attributeField = new AttributeField();

            attributeField.AddAttributeField(inputShapeFile);



            string infieldName = "FIPS_STR";
            //string infieldName = "STATE_FIPS";
            //string infieldName = "Id";
            //string infieldName = "OBJECTID";
            //int outRasterCellSize =30;

            double outRasterCellSize = 94.40415951;


            string outZonalCsvGDAL = "gdalZonalStat.csv";
            string outZonalCsvESRI = "esriZonalStat.csv";


            //string inValueRaster = @"D:\Ashis_Work\GDAL Utilities\sample-data\FromErik2\smallish dataset\teuitest_NED_30m_30_R1C1.img";
            //string inValueRaster = @"D:\Ashis_Work\GDAL Utilities\sample-data\FromErik\Whetstone_20080229SoilEnh.img";
            //string inValueRaster = @"D:\Ashis_Work\GDAL Utilities\sample-data\FromErik\Whetstone_20080229eDOQQMos.tif";

            //string inValueRaster = @"D:\Ashis_Work\GDAL Utilities\sample-data\FromErik2\TEUI_5__Test_data\slope_90m";
            string inValueRaster = @"D:\Ashis_Work\GDAL Utilities\sample-data\UtahGrid\dem90_utm83";

            Console.WriteLine("GDAL working...");

            DateTime gdalStart1 = DateTime.Now;

            ComputeStatistics.ComputeZonalStatistics(inValueRaster, inputShapeFile, infieldName, outRasterCellSize, outZonalCsvGDAL);
            DateTime gdalEnd1 = DateTime.Now;

            string gdbPath = @"D:\Ashis_Work\GDAL Utilities\sample-data\Geodatabase\EsriZonalOutputs.gdb";

            DateTime gdalStart2 = DateTime.Now;

            ComputeStatistics.ComputeZonalStatisticsUsingFeatureGdb(gdbPath, "Counties", inValueRaster, infieldName, outRasterCellSize, outZonalCsvGDAL);
            DateTime gdalEnd2 = DateTime.Now;

            TimeSpan gdalTimeSpan1 = gdalEnd1 - gdalStart1;
            TimeSpan gdalTimeSpan2 = gdalEnd2 - gdalStart2;

            Console.WriteLine("Total time GDAL: outside gdb- {0} inside gdb- {1}", gdalTimeSpan1, gdalTimeSpan2);


            Console.WriteLine("Esri working ...");
            DateTime esriStart = DateTime.Now;

            //string folder =@"D:\Ashis_Work\GDAL Utilities\sample-data\FromErik";
            //string folder = @"D:\Ashis_Work\GDAL Utilities\sample-data\FromErik2\smallish dataset";
            //string folder = @"D:\Ashis_Work\GDAL Utilities\sample-data\FromErik2\TEUI_5__Test_data";
            string folder = @"D:\Ashis_Work\GDAL Utilities\sample-data\UtahGrid";

            //string fileName = "teuitest_NED_30m_30_R1C1.img";
            //string fileName = "Whetstone_20080229SoilEnh.img";
            //string fileName = "slope_90m";
            string fileName = "dem90_utm83";

            //string fileName = "Whetstone_20080229eDOQQMos.tif";

            ZonalStatisticsEsri.OpenFileRasterDataset(folder, fileName, inputShapeFile, infieldName, outRasterCellSize, outZonalCsvESRI);

            DateTime esriEnd = DateTime.Now;

            TimeSpan esriTimeSpan = esriEnd - esriStart;

            Console.WriteLine("Total time ESRI: {0}", esriTimeSpan);
            Console.WriteLine("\n \n");
            Console.WriteLine(" Input shp: {0}", inputShapeFile);
            Console.WriteLine(" Output Cell: {0}", outRasterCellSize);


            Console.WriteLine("Done");
        }
Пример #6
0
        private void GetValuesFromCourses()
        {
            overallRatings     = new int[5];
            organizedRatings   = new int[5];
            interestingRatings = new int[5];
            presentedRatings   = new int[5];
            learnedRatings     = new int[5];
            List <int> contactHoursList   = new List <int>();
            List <int> selfStudyHoursList = new List <int>();
            List <int> gradesList         = new List <int>();
            List <Tuple <int, bool> > gradesAndPassedList = new List <Tuple <int, bool> >();

            foreach (Rating rating in Ratings)
            {
                overallRatings[rating.OverallRating - 1]++;
                organizedRatings[rating.Organized - 1]++;
                interestingRatings[rating.Interesting - 1]++;
                presentedRatings[rating.Presentation - 1]++;
                learnedRatings[rating.Learned - 1]++;
                contactHoursList.Add(rating.ContactHours);
                selfStudyHoursList.Add(rating.SelfStudyHours);
                gradesList.Add(rating.Grade);
                gradesAndPassedList.Add(new Tuple <int, bool>(rating.Grade, rating.PassedFirstTime));
            }

            contactHours    = ComputeStatistics.GroupHours(contactHoursList);
            selfStudyHours  = ComputeStatistics.GroupHours(selfStudyHoursList);
            grades          = ComputeStatistics.GroupGrades(gradesList);
            gradesAndPassed = ComputeStatistics.GroupPassed(gradesAndPassedList);

            double tmp = ComputeStatistics.ComputeAverageGrouped(overallRatings);

            overallAverage  = "Average: " + tmp.ToString("0.##");
            tmp             = ComputeStatistics.ComputeMedianGrouped(overallRatings);
            overallMedian   = "Median: " + tmp.ToString("0.##");
            tmp             = ComputeStatistics.ComputeVarianceGrouped(overallRatings);
            overallVariance = "Variance: " + tmp.ToString("0.####");
            List <int> tmpList = ComputeStatistics.ComputeMostCommonGrouped(overallRatings);

            overallMostCommon = "Most common: " + string.Join(',', tmpList);

            tmp = ComputeStatistics.ComputeAverageGrouped(organizedRatings);
            organizedAverage = "Average: " + tmp.ToString("0.##");
            tmp                 = ComputeStatistics.ComputeMedianGrouped(organizedRatings);
            organizedMedian     = "Median: " + tmp.ToString("0.##");
            tmp                 = ComputeStatistics.ComputeVarianceGrouped(organizedRatings);
            organizedVariance   = "Variance: " + tmp.ToString("0.####");
            tmpList             = ComputeStatistics.ComputeMostCommonGrouped(organizedRatings);
            organizedMostCommon = "Most common: " + string.Join(',', tmpList);

            tmp = ComputeStatistics.ComputeAverageGrouped(presentedRatings);
            presentedAverage = "Average: " + tmp.ToString("0.##");
            tmp                 = ComputeStatistics.ComputeMedianGrouped(presentedRatings);
            presentedMedian     = "Median: " + tmp.ToString("0.##");
            tmp                 = ComputeStatistics.ComputeVarianceGrouped(presentedRatings);
            presentedVariance   = "Variance: " + tmp.ToString("0.####");
            tmpList             = ComputeStatistics.ComputeMostCommonGrouped(presentedRatings);
            presentedMostCommon = "Most common: " + string.Join(',', tmpList);

            tmp = ComputeStatistics.ComputeAverageGrouped(interestingRatings);
            interestingAverage = "Average: " + tmp.ToString("0.##");
            tmp = ComputeStatistics.ComputeMedianGrouped(interestingRatings);
            interestingMedian = "Median: " + tmp.ToString("0.##");
            tmp = ComputeStatistics.ComputeVarianceGrouped(interestingRatings);
            interestingVariance   = "Variance: " + tmp.ToString("0.####");
            tmpList               = ComputeStatistics.ComputeMostCommonGrouped(interestingRatings);
            interestingMostCommon = "Most common: " + string.Join(',', tmpList);

            tmp               = ComputeStatistics.ComputeAverageGrouped(learnedRatings);
            learnedAverage    = "Average: " + tmp.ToString("0.##");
            tmp               = ComputeStatistics.ComputeMedianGrouped(learnedRatings);
            learnedMedian     = "Median: " + tmp.ToString("0.##");
            tmp               = ComputeStatistics.ComputeVarianceGrouped(learnedRatings);
            learnedVariance   = "Variance: " + tmp.ToString("0.####");
            tmpList           = ComputeStatistics.ComputeMostCommonGrouped(learnedRatings);
            learnedMostCommon = "Most common: " + string.Join(',', tmpList);

            tmp = ComputeStatistics.ComputeAverageSingles(contactHoursList);
            contactHoursAverage = "Average: " + tmp.ToString("0.##");
            tmp = ComputeStatistics.ComputeMedianSingles(contactHoursList);
            contactHoursMedian = "Median: " + tmp.ToString("0.##");
            tmp = ComputeStatistics.ComputeVarianceSingles(contactHoursList);
            contactHoursVariance = "Variance: " + tmp.ToString("0.####");
            tmpList = ComputeStatistics.ComputeMostCommonSingles(contactHoursList);
            contactHoursMostCommon = "Most common: " + string.Join(',', tmpList);

            tmp = ComputeStatistics.ComputeAverageSingles(selfStudyHoursList);
            selfStudyHoursAverage = "Average: " + tmp.ToString("0.##");
            tmp = ComputeStatistics.ComputeMedianSingles(selfStudyHoursList);
            selfStudyHoursMedian = "Median: " + tmp.ToString("0.##");
            tmp = ComputeStatistics.ComputeVarianceSingles(selfStudyHoursList);
            selfStudyHoursVariance = "Variance: " + tmp.ToString("0.####");
            tmpList = ComputeStatistics.ComputeMostCommonSingles(selfStudyHoursList);
            selfStudyHoursMostCommon = "Most common: " + string.Join(',', tmpList);

            tmp              = ComputeStatistics.ComputeAverageSingles(gradesList);
            gradesAverage    = "Average: " + tmp.ToString("0.##");
            tmp              = ComputeStatistics.ComputeMedianSingles(gradesList);
            gradesMedian     = "Median: " + tmp.ToString("0.##");
            tmp              = ComputeStatistics.ComputeVarianceSingles(gradesList);
            gradesVariance   = "Variance: " + tmp.ToString("0.####");
            tmpList          = ComputeStatistics.ComputeMostCommonSingles(gradesList);
            gradesMostCommon = "Most common: " + string.Join(',', tmpList);
        }