/// <summary> /// Renders a feature layer using proportional symbols to draw quantities. /// ![Proportional Symbols renderer](http://Esri.github.io/arcgis-pro-sdk/images/Renderers/proportional-renderer.png) /// </summary> /// <remarks></remarks> /// <returns></returns> internal static Task ProportionalRendererAsync() { //Check feature layer name //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data var featureLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType <FeatureLayer>().FirstOrDefault(f => f.Name == "USDemographics"); if (featureLayer == null) { MessageBox.Show("This renderer works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data", "Data missing"); return(Task.FromResult(0)); } return(QueuedTask.Run(() => { //Gets the first numeric field of the feature layer var firstNumericFieldOfFeatureLayer = SDKHelpers.GetNumericField(featureLayer); //Gets the min and max value of the field var sizes = SDKHelpers.GetFieldMinMax(featureLayer, firstNumericFieldOfFeatureLayer); ProportionalRendererDefinition prDef = new ProportionalRendererDefinition() { Field = firstNumericFieldOfFeatureLayer, MinimumSymbolSize = 4, MaximumSymbolSize = 50, LowerSizeStop = Convert.ToDouble(sizes.Item1), UpperSizeStop = Convert.ToDouble(sizes.Item2) }; CIMProportionalRenderer propRndr = (CIMProportionalRenderer)featureLayer.CreateRenderer(prDef); featureLayer.SetRenderer(propRndr); })); }
/// <summary> /// Renders a feature layer using an unclassed color gradient. /// ![cb-unclassed.png](http://Esri.github.io/arcgis-pro-sdk/images/Renderers/cb-unclassed.png "Class breaks unclassed renderer.") /// </summary> /// <returns> /// </returns> internal static Task UnclassedRenderer() { //Check feature layer name //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data var featureLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType <FeatureLayer>().FirstOrDefault(f => f.Name == "U.S. National Transportation Atlas Interstate Highways"); if (featureLayer == null) { MessageBox.Show("This renderer works with the U.S. National Transportation Atlas Interstate Highways feature layer available with the ArcGIS Pro SDK Sample data", "Data missing"); return(Task.FromResult(0)); } return(QueuedTask.Run(() => { //Gets the first numeric field of the feature layer var firstNumericFieldOfFeatureLayer = SDKHelpers.GetNumericField(featureLayer); //Gets the min and max value of the field var labels = SDKHelpers.GetFieldMinMax(featureLayer, firstNumericFieldOfFeatureLayer); UnclassedColorsRendererDefinition ucDef = new UnclassedColorsRendererDefinition() { Field = firstNumericFieldOfFeatureLayer, ColorRamp = SDKHelpers.GetColorRamp(), LowerColorStop = Convert.ToDouble(labels.Item1), UpperColorStop = Convert.ToDouble(labels.Item2), UpperLabel = labels.Item2, LowerLabel = labels.Item1, }; CIMClassBreaksRenderer renderer = (CIMClassBreaksRenderer)featureLayer.CreateRenderer(ucDef); featureLayer?.SetRenderer(renderer); })); }
/// <summary> /// Renders a feature layer using graduated colors to draw quantities. The outline width is varied based on attributes. /// ![graduatedColorOutline.png](http://Esri.github.io/arcgis-pro-sdk/images/Renderers/graduatedColorOutline.png "Graduated colors with natural breaks renderer.") /// </summary> /// <returns></returns> internal static Task CBRendererGraduatedColorsOutlineAsync() { //Check feature layer name //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data var featureLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType <FeatureLayer>().FirstOrDefault(f => f.Name == "USDemographics"); if (featureLayer == null) { MessageBox.Show("This renderer works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data", "Data missing"); return(Task.FromResult(0)); } return(QueuedTask.Run(() => { //Gets the first numeric field of the feature layer var firstNumericFieldOfFeatureLayer = SDKHelpers.GetNumericField(featureLayer); //Gets the min and max value of the field var minMax = SDKHelpers.GetFieldMinMax(featureLayer, firstNumericFieldOfFeatureLayer); GraduatedColorsRendererDefinition gcDef = new GraduatedColorsRendererDefinition() { ClassificationField = SDKHelpers.GetNumericField(featureLayer), ClassificationMethod = ClassificationMethod.NaturalBreaks, BreakCount = 5, ColorRamp = SDKHelpers.GetColorRamp() }; CIMClassBreaksRenderer renderer = (CIMClassBreaksRenderer)featureLayer.CreateRenderer(gcDef); //Create array of CIMVisualVariables to hold the outline information. var visualVariables = new CIMVisualVariable[] { new CIMSizeVisualVariable { ValueExpressionInfo = new CIMExpressionInfo { Title = "Custom", Expression = "$feature.AREA", ReturnType = ExpressionReturnType.Default }, AuthoringInfo = new CIMVisualVariableAuthoringInfo { MinSliderValue = Convert.ToDouble(minMax.Item1), MaxSliderValue = Convert.ToDouble(minMax.Item2), ShowLegend = false, Heading = firstNumericFieldOfFeatureLayer }, VariableType = SizeVisualVariableType.Graduated, Target = "outline", MinSize = 1, MaxSize = 13, MinValue = Convert.ToDouble(minMax.Item1), MaxValue = Convert.ToDouble(minMax.Item2) }, }; renderer.VisualVariables = visualVariables; featureLayer?.SetRenderer(renderer); })); }
/// <summary> /// Renders a feature layer using graduated colors to draw quantities. The outline width is varied based on attributes. /// ![graduatedColorOutline.png](http://Esri.github.io/arcgis-pro-sdk/images/Renderers/graduatedColorOutline.png "Graduated colors with natural breaks renderer.") /// </summary> /// <param name="featureLayer"></param> /// <returns></returns> internal static Task CBRendererGraduatedColorsOutline(FeatureLayer featureLayer) { return(QueuedTask.Run(() => { //Gets the first numeric field of the feature layer var firstNumericFieldOfFeatureLayer = SDKHelpers.GetNumericField(featureLayer); //Gets the min and max value of the field var minMax = SDKHelpers.GetFieldMinMax(featureLayer, firstNumericFieldOfFeatureLayer); GraduatedColorsRendererDefinition gcDef = new GraduatedColorsRendererDefinition() { ClassificationField = SDKHelpers.GetNumericField(featureLayer), ClassificationMethod = ClassificationMethod.NaturalBreaks, BreakCount = 5, ColorRamp = SDKHelpers.GetColorRamp() }; CIMClassBreaksRenderer renderer = (CIMClassBreaksRenderer)featureLayer.CreateRenderer(gcDef); //Create array of CIMVisualVariables to hold the outline information. var visualVariables = new CIMVisualVariable[] { new CIMSizeVisualVariable { ValueExpressionInfo = new CIMExpressionInfo { Title = "Custom", Expression = "$feature.AREA", ReturnType = ExpressionReturnType.Default }, AuthoringInfo = new CIMVisualVariableAuthoringInfo { MinSliderValue = Convert.ToDouble(minMax.Item1), MaxSliderValue = Convert.ToDouble(minMax.Item2), ShowLegend = false, Heading = firstNumericFieldOfFeatureLayer }, VariableType = SizeVisualVariableType.Graduated, Target = "outline", MinSize = 1, MaxSize = 13, MinValue = Convert.ToDouble(minMax.Item1), MaxValue = Convert.ToDouble(minMax.Item2) }, }; renderer.VisualVariables = visualVariables; featureLayer?.SetRenderer(renderer); })); }
/// <summary> /// Renders a feature layer using proportional symbols to draw quantities. /// ![Proportional Symbols renderer](http://Esri.github.io/arcgis-pro-sdk/images/Renderers/proportional-renderer.png) /// </summary> /// <remarks></remarks> /// <param name="featureLayer"></param> /// <returns></returns> internal static Task ProportionalRenderer(FeatureLayer featureLayer) { return(QueuedTask.Run(() => { //Gets the first numeric field of the feature layer var firstNumericFieldOfFeatureLayer = SDKHelpers.GetNumericField(featureLayer); //Gets the min and max value of the field var sizes = SDKHelpers.GetFieldMinMax(featureLayer, firstNumericFieldOfFeatureLayer); ProportionalRendererDefinition prDef = new ProportionalRendererDefinition() { Field = firstNumericFieldOfFeatureLayer, MinimumSymbolSize = 4, MaximumSymbolSize = 50, LowerSizeStop = Convert.ToDouble(sizes.Item1), UpperSizeStop = Convert.ToDouble(sizes.Item2) }; CIMProportionalRenderer propRndr = (CIMProportionalRenderer)featureLayer.CreateRenderer(prDef); featureLayer.SetRenderer(propRndr); })); }
/// <summary> /// Renders a feature layer using an unclassed color gradient. /// ![cb-unclassed.png](http://Esri.github.io/arcgis-pro-sdk/images/Renderers/cb-unclassed.png "Class breaks unclassed renderer.") /// </summary> /// <param name="featureLayer"></param> /// <returns> /// </returns> internal static Task UnclassedRenderer(FeatureLayer featureLayer) { return(QueuedTask.Run(() => { //Gets the first numeric field of the feature layer var firstNumericFieldOfFeatureLayer = SDKHelpers.GetNumericField(featureLayer); //Gets the min and max value of the field var labels = SDKHelpers.GetFieldMinMax(featureLayer, firstNumericFieldOfFeatureLayer); UnclassedColorsRendererDefinition ucDef = new UnclassedColorsRendererDefinition() { Field = firstNumericFieldOfFeatureLayer, ColorRamp = SDKHelpers.GetColorRamp(), LowerColorStop = Convert.ToDouble(labels.Item1), UpperColorStop = Convert.ToDouble(labels.Item2), UpperLabel = labels.Item2, LowerLabel = labels.Item1, }; CIMClassBreaksRenderer renderer = (CIMClassBreaksRenderer)featureLayer.CreateRenderer(ucDef); featureLayer?.SetRenderer(renderer); })); }