private void OnUpdateRendererClicked(object sender, EventArgs e)
        {
            // Convert the input text to doubles and return if they're invalid.
            double input1;
            double input2;

            try
            {
                input1 = Convert.ToDouble(Input_Parameter1.Text);
                input2 = Convert.ToDouble(Input_Parameter2.Text);
            }
            catch (Exception ex)
            {
                ((Page)Parent).DisplayAlert("Alert", ex.Message, "OK");
                return;
            }

            // Get the user choice for the raster stretch render
            string myRendererTypeChoice = RendererTypes.SelectedItem.ToString();

            // Create an IEnumerable from an empty list of doubles for the gamma values in the stretch render
            IEnumerable <double> myGammaValues = new List <double>();

            // Create a color ramp for the stretch renderer
            ColorRamp myColorRamp = ColorRamp.Create(PresetColorRampType.DemLight, 1000);

            // Create the place holder for the stretch renderer
            StretchRenderer myStretchRenderer = null;

            switch (myRendererTypeChoice)
            {
            case "Min Max":

                // This section creates a stretch renderer based on a MinMaxStretchParameters
                // TODO: Add you own logic to ensure that accurate min/max stretch values are used

                // Create an IEnumerable from a list of double min stretch value doubles
                IEnumerable <double> myMinValues = new List <double> {
                    input1
                };

                // Create an IEnumerable from a list of double max stretch value doubles
                IEnumerable <double> myMaxValues = new List <double> {
                    input2
                };

                // Create a new MinMaxStretchParameters based on the user choice for min and max stretch values
                MinMaxStretchParameters myMinMaxStretchParameters = new MinMaxStretchParameters(myMinValues, myMaxValues);

                // Create the stretch renderer based on the user defined min/max stretch values, empty gamma values, statistic estimates, and a predefined color ramp
                myStretchRenderer = new Esri.ArcGISRuntime.Rasters.StretchRenderer(myMinMaxStretchParameters, myGammaValues, true, myColorRamp);

                break;

            case "Percent Clip":

                // This section creates a stretch renderer based on a PercentClipStretchParameters
                // TODO: Add you own logic to ensure that accurate min/max percent clip values are used

                // Create a new PercentClipStretchParameters based on the user choice for min and max percent clip values
                PercentClipStretchParameters myPercentClipStretchParameters = new PercentClipStretchParameters(input1, input2);

                // Create the percent clip renderer based on the user defined min/max percent clip values, empty gamma values, statistic estimates, and a predefined color ramp
                myStretchRenderer = new StretchRenderer(myPercentClipStretchParameters, myGammaValues, true, myColorRamp);

                break;

            case "Standard Deviation":

                // This section creates a stretch renderer based on a StandardDeviationStretchParameters
                // TODO: Add you own logic to ensure that an accurate standard deviation value is used

                // Create a new StandardDeviationStretchParameters based on the user choice for standard deviation value
                StandardDeviationStretchParameters myStandardDeviationStretchParameters = new StandardDeviationStretchParameters(input1);

                // Create the standard deviation renderer based on the user defined standard deviation value, empty gamma values, statistic estimates, and a predefined color ramp
                myStretchRenderer = new StretchRenderer(myStandardDeviationStretchParameters, myGammaValues, true, myColorRamp);

                break;
            }

            // Get the existing raster layer in the map
            RasterLayer myRasterLayer = (RasterLayer)MyMapView.Map.OperationalLayers[0];

            // Apply the stretch renderer to the raster layer
            myRasterLayer.Renderer = myStretchRenderer;
        }
示例#2
0
        private void OnUpdateRendererClicked(object sender, EventArgs e)
        {
            // This function acquires the user selection of the stretch renderer from the table view
            // along with the parameters specified, then a stretch renderer is created and applied to
            // the raster layer

            // Get the user choice for the raster stretch render
            string myRendererTypeChoice;

            if (_RendererTypes.SelectedItem == null)
            {
                // If the user does not click on a choice in the table but just clicks the
                // button, the selected value will be null so use the initial
                // stretch renderer option
                myRendererTypeChoice = "Min Max";
            }
            else
            {
                // The user clicked on an option in the table and thus the selected value
                // will contain a valid choice
                myRendererTypeChoice = _RendererTypes.SelectedItem.ToString();
            }

            // Create an IEnumerable from an empty list of doubles for the gamma values in the stretch render
            IEnumerable <double> myGammaValues = new List <double> {
            };

            // Create a color ramp for the stretch renderer
            ColorRamp myColorRamp = ColorRamp.Create(PresetColorRampType.DemLight, 1000);

            // Create the place holder for the stretch renderer
            StretchRenderer myStretchRenderer = null;

            switch (myRendererTypeChoice)
            {
            case "Min Max":

                // This section creates a stretch renderer based on a MinMaxStretchParameters
                // TODO: Add you own logic to ensure that accurate min/max stretch values are used

                // Create an IEnumerable from a list of double min stretch value doubles
                IEnumerable <double> myMinValues = new List <double> {
                    Convert.ToDouble(_Input_Parameter1.Text)
                };

                // Create an IEnumerable from a list of double max stretch value doubles
                IEnumerable <double> myMaxValues = new List <double> {
                    Convert.ToDouble(_Input_Parameter2.Text)
                };

                // Create a new MinMaxStretchParameters based on the user choice for min and max stretch values
                MinMaxStretchParameters myMinMaxStretchParameters = new MinMaxStretchParameters(myMinValues, myMaxValues);

                // Create the stretch renderer based on the user defined min/max stretch values, empty gamma values, statistic estimates, and a predefined color ramp
                myStretchRenderer = new Esri.ArcGISRuntime.Rasters.StretchRenderer(myMinMaxStretchParameters, myGammaValues, true, myColorRamp);

                break;

            case "Percent Clip":

                // This section creates a stretch renderer based on a PercentClipStretchParameters
                // TODO: Add you own logic to ensure that accurate min/max percent clip values are used

                // Create a new PercentClipStretchParameters based on the user choice for min and max percent clip values
                PercentClipStretchParameters myPercentClipStretchParameters = new PercentClipStretchParameters(Convert.ToDouble(_Input_Parameter1.Text), Convert.ToDouble(_Input_Parameter2.Text));

                // Create the percent clip renderer based on the user defined min/max percent clip values, empty gamma values, statistic estimates, and a predefined color ramp
                myStretchRenderer = new Esri.ArcGISRuntime.Rasters.StretchRenderer(myPercentClipStretchParameters, myGammaValues, true, myColorRamp);

                break;

            case "Standard Deviation":

                // This section creates a stretch renderer based on a StandardDeviationStretchParameters
                // TODO: Add you own logic to ensure that an accurate standard deviation value is used

                // Create a new StandardDeviationStretchParameters based on the user choice for standard deviation value
                StandardDeviationStretchParameters myStandardDeviationStretchParameters = new StandardDeviationStretchParameters(Convert.ToDouble(_Input_Parameter1.Text));

                // Create the standard deviation renderer based on the user defined standard deviation value, empty gamma values, statistic estimates, and a predefined color ramp
                myStretchRenderer = new Esri.ArcGISRuntime.Rasters.StretchRenderer(myStandardDeviationStretchParameters, myGammaValues, true, myColorRamp);

                break;
            }

            // Get the existing raster layer in the map
            RasterLayer myRasterLayer = (RasterLayer)_myMapView.Map.OperationalLayers[0];

            // Apply the stretch renderer to the raster layer
            myRasterLayer.Renderer = myStretchRenderer;
        }