// Computes Class Statistics for the image layer using user input graphics as class definition polygons private async void ComputeClassStatisticsButton_Click(object sender, RoutedEventArgs e) { try { if (_graphicsOverlay.Graphics.Count < 2) throw new ArgumentException("Before computing statistics, enter two or more class definition areas by clicking the image on the map."); progress.Visibility = Visibility.Visible; if (MyMapView.Editor.IsActive) MyMapView.Editor.Cancel.Execute(null); var statsTask = new ComputeClassStatisticsTask(new Uri(_imageLayer.ServiceUri)); var statsParam = new ComputeClassStatisticsParameters(); statsParam.ClassDescriptions = _graphicsOverlay.Graphics .Select((g, idx) => new ClassDescription(idx, idx.ToString(), g.Geometry as Polygon)).ToList(); var result = await statsTask.ComputeClassStatisticsAsync(statsParam); _imageLayer.RenderingRule = new RenderingRule() { RasterFunctionName = "MLClassify", VariableName = "Raster", RasterFunctionArguments = new Dictionary<string, object> { { "SignatureFile", result.GSG } }, }; } catch (Exception ex) { var _ = new MessageDialog(ex.Message, "Sample Error").ShowAsync(); } finally { progress.Visibility = Visibility.Collapsed; } }
// Computes Class Statistics for the image layer using user input graphics as class definition polygons private async void ComputeClassStatisticsButton_Click(object sender, RoutedEventArgs e) { try { progress.Visibility = Visibility.Visible; if (mapView.Editor.IsActive) mapView.Editor.Cancel.Execute(null); var statsTask = new ComputeClassStatisticsTask(new Uri(imageLayer.ServiceUri)); var statsParam = new ComputeClassStatisticsParameters(); statsParam.ClassDescriptions = graphicsLayer.Graphics .Select((g, idx) => new ClassDescription(idx, idx.ToString(), g.Geometry as Polygon)).ToList(); var result = await statsTask.ComputeClassStatisticsAsync(statsParam); imageLayer.RenderingRule = new RenderingRule() { RasterFunctionName = "MLClassify", VariableName = "Raster", RasterFunctionArguments = new Dictionary<string, object> { { "SignatureFile", result.GSG } }, }; } catch (Exception ex) { MessageBox.Show(ex.Message, "Sample Error"); } finally { progress.Visibility = Visibility.Collapsed; } }
// Computes Class Statistics for the image layer using user input graphics as class definition polygons private async void ComputeClassStatisticsButton_Click(object sender, RoutedEventArgs e) { try { if (_graphicsOverlay.Graphics.Count < 2) { throw new ArgumentException("Before computing statistics, enter two or more class definition areas by clicking the image on the map."); } progress.Visibility = Visibility.Visible; if (MyMapView.Editor.IsActive) { MyMapView.Editor.Cancel.Execute(null); } var statsTask = new ComputeClassStatisticsTask(new Uri(_imageLayer.ServiceUri)); var statsParam = new ComputeClassStatisticsParameters(); statsParam.ClassDescriptions = _graphicsOverlay.Graphics .Select((g, idx) => new ClassDescription(idx, idx.ToString(), g.Geometry as Polygon)).ToList(); var result = await statsTask.ComputeClassStatisticsAsync(statsParam); _imageLayer.RenderingRule = new RenderingRule() { RasterFunctionName = "MLClassify", VariableName = "Raster", RasterFunctionArguments = new Dictionary <string, object> { { "SignatureFile", result.GSG } }, }; } catch (Exception ex) { var _ = new MessageDialog(ex.Message, "Sample Error").ShowAsync(); } finally { progress.Visibility = Visibility.Collapsed; } }
// Computes Class Statistics for the image layer using user input graphics as class definition polygons private async void ComputeClassStatisticsButton_Click(object sender, RoutedEventArgs e) { try { progress.Visibility = Visibility.Visible; if (mapView.Editor.IsActive) { mapView.Editor.Cancel.Execute(null); } var statsTask = new ComputeClassStatisticsTask(new Uri(imageLayer.ServiceUri)); var statsParam = new ComputeClassStatisticsParameters(); statsParam.ClassDescriptions = graphicsLayer.Graphics .Select((g, idx) => new ClassDescription(idx, idx.ToString(), g.Geometry as Polygon)).ToList(); var result = await statsTask.ComputeClassStatisticsAsync(statsParam); imageLayer.RenderingRule = new RenderingRule() { RasterFunctionName = "MLClassify", VariableName = "Raster", RasterFunctionArguments = new Dictionary <string, object> { { "SignatureFile", result.GSG } }, }; } catch (Exception ex) { MessageBox.Show(ex.Message, "Sample Error"); } finally { progress.Visibility = Visibility.Collapsed; } }