0

I am using ArcGIS Pro.

Is it possible to change polygon colour after i change it's geometry?

For example, if there were five vertices, the figure is green, and after i change it to be four vertices I want it to become black.

2 Answers 2

2

You can use Arcade to create an expression.

I dont really know what im doing (first time using Arcade). Just pasted the code from: VxCount = !shape!.pointcount fuction in AGOL and modified last line to output 0 for even number of vertices and 1 for odd. You can of course change this to output whatever value you want with some if/else:

Function CountVertices(geom) {
    var cnt_vertices = Null;
    var geom_type = TypeOf(geom);
    Console(geom_type);
    if (geom_type == "Point") {
        cnt_vertices = 1;
    } else if (geom_type == "Multipoint") {
        cnt_vertices = Count(geom.points);
    } else if (geom_type == "Polyline") {
        var cnt_line = 0;
        for (var i = 0; i < Count(geom.paths); i++) { 
            cnt_line += Count(geom.paths[i]);
        }
        cnt_vertices = cnt_line;
    } else if (geom_type == "Polygon") {
        var cnt_pol = 0;
        for (var i = 0; i < Count(geom.rings); i++) { 
            cnt_pol += Count(geom.rings[i]);
        }
        cnt_vertices = cnt_pol;
    } else {
        // this should not happen...    
    }
    return cnt_vertices;
}


return (CountVertices(Geometry($feature))-1)%2

enter image description here

2
  • Hmm. Well, i'am new to any scripting at all :)) But i have like 10 different options with verteces count. It would work too ? In which line should i write those values in script... ?
    – Darius
    Commented Jan 23, 2020 at 11:21
  • Somewhere near the end, not sure. Or use the original code (see link in my answer) to return vertice count. You dont need to specify each option, the Unique values symbology with symbolize all of them.
    – Bera
    Commented Jan 23, 2020 at 11:26
0

I think that this could be semi-automated by using Attribute-driven color in symbology:

You can customize feature symbols by leveraging data attributes as symbol property values.

I would start by adding a field that gets populated with the number of vertices, then I would add another field to store color values and set those colors based on the number of vertices.

To become fully automated you could try combining attribute driven symbology with Calculation attribute rules:

Calculation rules are used to automatically populate attribute configurations on a feature. They can be created as immediate calculation rules ...

  • Immediate calculation rules—Rule evaluation occurs immediately during edit operations. The type of triggering event specified during rule creation allows rule evaluation to occur based on insert, update, or delete operations.

I have used attribute driven symbology successfully for other purposes, but I have not tried calculation attribute rules.

2
  • I have a field with vertices, but they dont change automaticaly, after editing. I have to run script again, to see.
    – Darius
    Commented Jan 23, 2020 at 8:22
  • That's what I mean by semi-automated,
    – PolyGeo
    Commented Jan 23, 2020 at 8:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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