Пример #1
0
        private void ApplyButton_Clicked(object sender, EventArgs e)
        {
            StandardDeviationStretchParameters parameters = new StandardDeviationStretchParameters(_pickerModel.SelectedFactor);

            int[] bands = { 0, 1, 2 };
            _rasterLayer.Renderer = new RgbRenderer(parameters, bands, null, true);
        }
Пример #2
0
        private void InputStretchParamsButton_Click(object sender, EventArgs e)
        {
            // Fire the OnStretchInputsEntered event and provide the stretch parameter input.
            if (OnStretchInputsEntered != null)
            {
                // Create a new StretchParametersEventArgs to contain the input values.
                StretchParameters inputStretchParams = null;

                // Create the right type of stretch parameters defined by the user.
                switch (_stretchParamsType)
                {
                // - Minimum and maximum RGB values.
                case "Min Max RGB":
                    // Get the models that contains the min/max red, green, and blue picker choices.
                    RgbValuePickerModel minRgbModel = _minRgbPicker.Model as RgbValuePickerModel;
                    RgbValuePickerModel maxRgbModel = _maxRgbPicker.Model as RgbValuePickerModel;

                    // Read min/max RGB values that were chosen.
                    double[] minValues = { minRgbModel.SelectedRed, minRgbModel.SelectedGreen, minRgbModel.SelectedBlue };
                    double[] maxValues = { maxRgbModel.SelectedRed, maxRgbModel.SelectedGreen, maxRgbModel.SelectedBlue };

                    // Create a new MinMaxStretchParameters object with the values.
                    inputStretchParams = new MinMaxStretchParameters(minValues, maxValues);

                    break;

                // - Minimum and maximum percent clip values.
                case "% Clip":
                    // Read min/max percent values that were chosen.
                    double minPercent = _minPercentSlider.Value;
                    double maxPercent = _maxPercentSlider.Value;
                    inputStretchParams = new PercentClipStretchParameters(minPercent, maxPercent);

                    break;

                // Standard deviation factor.
                case "Std Dev":
                    // Get the model that contains the standard deviation factor choices.
                    StdDevFactorPickerModel factorModel = _stdDevPicker.Model as StdDevFactorPickerModel;

                    // Get the selected factor.
                    double standardDevFactor = factorModel.SelectedFactor;
                    inputStretchParams = new StandardDeviationStretchParameters(standardDevFactor);

                    break;
                }

                // Create a new StretchParametersEventArgs and provide the stretch parameters.
                StretchParametersEventArgs inputParamsEventArgs = new StretchParametersEventArgs(inputStretchParams);

                // Raise the event with the custom arguments.
                OnStretchInputsEntered(sender, inputParamsEventArgs);
            }
        }
        private void ApplyRendererButton_Click(object sender, EventArgs e)
        {
            // Create the correct type of StretchParameters with the corresponding user inputs.
            StretchParameters stretchParameters = null;

            // See which type is selected and apply the corresponding input parameters to create the renderer.
            switch (_parameterInputTypeSpinner.SelectedItem.ToString())
            {
            case "Min Max":
                // Read the minimum and maximum values for the red, green, and blue bands.
                double minRed   = Convert.ToDouble(_minRedSpinner.SelectedItem);
                double minGreen = Convert.ToDouble(_minGreenSpinner.SelectedItem);
                double minBlue  = Convert.ToDouble(_minBlueSpinner.SelectedItem);
                double maxRed   = Convert.ToDouble(_maxRedSpinner.SelectedItem);
                double maxGreen = Convert.ToDouble(_maxGreenSpinner.SelectedItem);
                double maxBlue  = Convert.ToDouble(_maxBlueSpinner.SelectedItem);

                // Create an array of the minimum and maximum values.
                double[] minValues = { minRed, minGreen, minBlue };
                double[] maxValues = { maxRed, maxGreen, maxBlue };

                // Create a new MinMaxStretchParameters with the values.
                stretchParameters = new MinMaxStretchParameters(minValues, maxValues);
                break;

            case "Percent Clip":
                // Get the percentile cutoff below which values in the raster dataset are to be clipped.
                double minimumPercent = Convert.ToDouble(_minPercentClipSlider.Progress);

                // Get the percentile cutoff above which pixel values in the raster dataset are to be clipped.
                double maximumPercent = Convert.ToDouble(_maxPercentClipSlider.Progress);

                // Create a new PercentClipStretchParameters with the inputs.
                stretchParameters = new PercentClipStretchParameters(minimumPercent, maximumPercent);
                break;

            case "Standard Deviation":
                // Read the standard deviation factor (the number of standard deviations used to define the range of pixel values).
                double standardDeviationFactor = Convert.ToDouble(_stdDeviationFactorSpinner.SelectedItem);

                // Create a new StandardDeviationStretchParameters with the selected number of standard deviations.
                stretchParameters = new StandardDeviationStretchParameters(standardDeviationFactor);
                break;
            }

            // Create an array to specify the raster bands (red, green, blue).
            int[] bands = { 0, 1, 2 };

            // Create the RgbRenderer with the stretch parameters created above, then apply it to the raster layer.
            RgbRenderer rasterRenderer = new RgbRenderer(stretchParameters, bands, null, true);

            _rasterLayer.Renderer = rasterRenderer;
        }
Пример #4
0
        private async void OnUpdateRendererClicked(object sender, RoutedEventArgs e)
        {
            // Convert the text to doubles and return if they're invalid.
            double input1;
            double input2;

            try
            {
                input1 = Convert.ToDouble(FirstParameterInput.Text);
                input2 = Convert.ToDouble(SecondParameterInput.Text);
            }
            catch (Exception ex)
            {
                await new MessageDialog(ex.Message).ShowAsync();
                return;
            }

            // Get the user choice for the raster stretch render
            string myRendererTypeChoice = RendererTypes.SelectedValue.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 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;
        }
        private void UpdateRendererButton_Clicked(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.

            // Convert the input text to doubles and return if they're invalid.
            double input1;
            double input2;

            try
            {
                input1 = Convert.ToDouble(_inputParameter1.Text);
                input2 = Convert.ToDouble(_inputParameter2.Text);
            }
            catch (Exception ex)
            {
                new UIAlertView("alert", ex.Message, (IUIAlertViewDelegate)null, "OK", null).Show();
                return;
            }

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

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

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

            switch (_rendererTypes.SelectedSegment)
            {
            case 0:

                // 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.

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

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

                    // Create a new MinMaxStretchParameters based on the user choice for min and max stretch values.
                    MinMaxStretchParameters minMaxStretchParameters = new MinMaxStretchParameters(minValues, maxValues);

                    // Create the stretch renderer based on the user defined min/max stretch values, empty gamma values, statistic estimates, and a predefined color ramp.
                    stretchRenderer = new StretchRenderer(minMaxStretchParameters, gammaValues, true, colorRamp);
                }
                catch (ArgumentException)
                {
                    ShowMessage("Error configuring renderer.", "Ensure all values are valid and try again.");
                    return;
                }

                break;

            case 1:

                // 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.

                try
                {
                    // Create a new PercentClipStretchParameters based on the user choice for min and max percent clip values.
                    PercentClipStretchParameters percentClipStretchParameters = 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.
                    stretchRenderer = new StretchRenderer(percentClipStretchParameters, gammaValues, true, colorRamp);
                }
                catch (Exception)
                {
                    ShowMessage("Error configuring renderer.", "Ensure all values are valid and try again.");
                    return;
                }

                break;

            case 2:

                // 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

                try
                {
                    // Create a new StandardDeviationStretchParameters based on the user choice for standard deviation value.
                    StandardDeviationStretchParameters standardDeviationStretchParameters = 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.
                    stretchRenderer = new StretchRenderer(standardDeviationStretchParameters, gammaValues, true, colorRamp);
                }
                catch (Exception)
                {
                    ShowMessage("Error configuring renderer.", "Ensure all values are valid and try again.");
                    return;
                }

                break;
            }

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

            // Apply the stretch renderer to the raster layer.
            rasterLayer.Renderer = stretchRenderer;
        }
Пример #6
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
            UITableViewSource myUITableViewSource = _myRenderChoiceType.Source;
            TableSource       myTableSource       = (TableSource)myUITableViewSource;
            string            myRendererTypeChoice;

            if (myTableSource.SelectedValue == 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 = myTableSource.SelectedValue;
            }

            // 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 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 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 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;
        }
Пример #7
0
        private void OnUpdateRendererClicked(object sender, EventArgs e)
        {
            // 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> {
                    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 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 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;
        }
Пример #8
0
        private void ApplyRgbRendererButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            // Create the correct type of StretchParameters with the corresponding user inputs.
            StretchParameters stretchParameters = null;

            // See which type is selected and apply the corresponding input parameters to create the renderer.
            switch (StretchTypeComboBox.SelectedValue.ToString())
            {
            case "Min Max":
                // Read the minimum and maximum values for the red, green, and blue bands.
                double minRed   = Convert.ToDouble(MinRedComboBox.SelectedValue);
                double minGreen = Convert.ToDouble(MinGreenComboBox.SelectedValue);
                double minBlue  = Convert.ToDouble(MinBlueComboBox.SelectedValue);
                double maxRed   = Convert.ToDouble(MaxRedComboBox.SelectedValue);
                double maxGreen = Convert.ToDouble(MaxGreenComboBox.SelectedValue);
                double maxBlue  = Convert.ToDouble(MaxBlueComboBox.SelectedValue);

                // Create an array of the minimum and maximum values.
                double[] minValues = { minRed, minGreen, minBlue };
                double[] maxValues = { maxRed, maxGreen, maxBlue };

                // Create a new MinMaxStretchParameters with the values.
                stretchParameters = new MinMaxStretchParameters(minValues, maxValues);
                break;

            case "Percent Clip":
                // Get the percentile cutoff below which values in the raster dataset are to be clipped.
                double minimumPercent = MinimumValueSlider.SelectedIndex;

                // Get the percentile cutoff above which pixel values in the raster dataset are to be clipped.
                double maximumPercent = MaximumValueSlider.SelectedIndex;

                // Create a new PercentClipStretchParameters with the inputs.
                stretchParameters = new PercentClipStretchParameters(minimumPercent, maximumPercent);
                break;

            case "Standard Deviation":
                // Read the standard deviation factor (the number of standard deviations used to define the range of pixel values).
                double standardDeviationFactor = Convert.ToDouble(StdDeviationFactorComboBox.SelectedValue);

                // Create a new StandardDeviationStretchParameters with the selected number of standard deviations.
                stretchParameters = new StandardDeviationStretchParameters(standardDeviationFactor);
                break;
            }

            // Create an array to specify the raster bands (red, green, blue).
            int[] bands = { 0, 1, 2 };

            // Create the RgbRenderer with the stretch parameters created above, then apply it to the raster layer.

            RgbRenderer     rgbRenderer;
            StretchRenderer stretchRenderer;

            if (stretchItem.IsEnabled == false)
            {
                rgbRenderer           = new RgbRenderer(stretchParameters, bands, null, true);
                _rasterLayer.Renderer = rgbRenderer;
            }
            else if (stretchItem.IsEnabled == true)
            {
                PresetColorRampType pcrt;
                int colorType = Convert.ToInt32(ColorRampCsy.SelectedIndex - 1);
                switch (colorType)
                {
                case -1:
                    pcrt = PresetColorRampType.Elevation;
                    break;

                case 0:
                    pcrt = PresetColorRampType.Elevation;
                    break;

                case 1:
                    pcrt = PresetColorRampType.DemScreen;
                    break;

                case 2:
                    pcrt = PresetColorRampType.DemScreen;
                    break;

                default:
                    pcrt = PresetColorRampType.DemScreen;
                    break;
                }
                uint colorSize = Convert.ToUInt32(ColorRampSizeCsy.SelectedValue);
                stretchRenderer       = new StretchRenderer(stretchParameters, null, true, ColorRamp.Create(pcrt, colorSize));
                _rasterLayer.Renderer = stretchRenderer;
            }
        }