5

I have to render a feature layer with a graduated colors renderer, using the ArcGIS API for Java (or VB, .NET).

As the feature layer data is created dynamically using webservices, I don't in advance the range of values, so I need to get the classification to be generated using the natural breaks algorithm.

Here is what I need to set:

Layer properties window

In addition, I need to get the largest values overlaying the smallest:

Symbol level dialog

I need to get n classes, using a AlgorithmicColorRamp from one given color to another color and symbolized by a simple line with a given width.

I tried to write this method, called after the layer data source is set:

 public static void applyGraduatedColorsLineRenderer(IGeoFeatureLayer geoFeatureLayer, String field, int count, IColor fromColor, IColor toColor, double width) throws UnknownHostException, IOException { IAlgorithmicColorRamp colorRamp = new AlgorithmicColorRamp(); colorRamp.setAlgorithm(esriColorRampAlgorithm.esriCIELabAlgorithm); colorRamp.setFromColor(fromColor); colorRamp.setToColor(toColor); colorRamp.setSize(count); boolean[] ok = new boolean[1]; colorRamp.createRamp(ok); ClassBreaksRenderer classBreaksRenderer = new ClassBreaksRenderer(); classBreaksRenderer.setField(field); classBreaksRenderer.setBreakCount(count); classBreaksRenderer.setSortClassesAscending(false); classBreaksRenderer.setFlipSymbols(false); classBreaksRenderer.setColorRampByRef(colorRamp); for(int i = 0; i < count; i++) { SimpleLineSymbol simpleLineSymbol = new SimpleLineSymbol(); simpleLineSymbol.setColor(fromColor); simpleLineSymbol.setStyle(esriSimpleLineStyle.esriSLSSolid); simpleLineSymbol.setWidth(width); classBreaksRenderer.setSymbol(i, simpleLineSymbol); } geoFeatureLayer.setRendererByRef(classBreaksRenderer); } 

The problem is that I don't get the right range for my data, and the classification method is set to "manual" instead of "Natural Breaks": enter image description here

Moreover, I don't know what is the equivalent in ArcObjects of checking "Draw this layer using the symbol levels specified below".

2
  • Not sure if this applies but perhaps you could use a template layer and import the symbology that way like in THIS question. Commented Dec 15, 2014 at 17:10
  • It doesn't work as the symbology depends on the feature class data. So I think it needs to be generated for each new data programmatically. Commented Dec 16, 2014 at 17:24

1 Answer 1

1

It's maybe too late for an answer, but I think thats what you needed - the

IClassBreaksUIProperties

IClassify classifyMethod = new NaturalBreaksClass(); (classBreaksRenderer as IClassBreaksUIProperties).Method = classifyMethod.ClassID; 

The checking "Draw this layer using the symbol levels specified below" you can also set with the UIProperties: IClassBreaksUIProperties.ShowClassGaps Property

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.