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

  • Not sure if this applies but perhaps you could use a template layer and import the symbology that way like in THIS question. – landocalrissian Dec 15 '14 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. – superrache Dec 16 '14 at 17:24
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.