Arcade for complex line symbology

1344
7
Jump to solution
03-15-2021 05:22 AM
Labels (2)
Anzhi
by
New Contributor II

Hello
I have a line feature class, in the attributes of which there is a field "Type", and "Thickness", I need to make a complex Symbology that unites these 2 fields.
It would seem an easy task, but the lines are constantly updated and the values in the "Thickness" field as well.
I need to make sure that the "Thickness" field is graded, such as from 0 - 2, 2.5-4, etc. and at the same time it was merged with the "Type" field as in the picture

Symbology.png

 
I am completely new to using Arcade, but I think that you can create an expression that will solve my problem
 
regards
0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

Yes, that's possible as well! However, in order to use an expression-based classification, you'll either need to lump all your evaluations (type and width together) into one expression, or the expression needs to be done via a property connection.

All in One

This is probably the route you want to go, since your numeric value is in discrete classes. We'll take the Type value and just append to it different text based on the width. Unless there's more going on than your screenshot implies, it looks like you just want the "type" field value, without any further evaluation, combined with a numeric classification.

Set the symbology to Unique Values and set the Field to an expression like the following:

var w = $feature.width
var width_str

// Here we define the width classification ranges
if(w < 0.8){
    width_str = ' up to 0.8'
} else if (w < 2) {
    width_str = ' between 0.8 and 2'
} else if ....

// and so on

return $feature.Type + width_str

 

Because the if/else if statements evaluate in order, there's no need to do a "w > N and w < M", as the "greater than" portion is accounted for in the preceding if statement.

- Josh Carlson
Kendall County GIS

View solution in original post

0 Kudos
7 Replies
MohamadAchour
New Contributor III

I think you can only represent one field for each feature layer.

One solution is to make a copy of the line file: The first one will represent the "type" field, and the other one will represent the "thickness field"

 

0 Kudos
jcarlson
MVP Esteemed Contributor

There are a couple of ways to accomplish this.

Vary Symbology by Attribute

On the symbology pane, click over to the second tab:

jcarlson_0-1615813534689.png

You can either "peg" the line's thickness to a field's value, as shown below, or you can check the box Enable Size Range, to scale the line's thickness to its relative position in the full range of values in the field. Useful for when your field goes up fairly high, say for a "max speed" field, where you don't want 60-pt lines.

jcarlson_1-1615814354549.png

Setting any color, size, or transparency attribute on this tab will be in addition to the symbology settings on the main tab. So in the situation you've posted about, you can set the "type" symbols any way you like, then define the width as being controlled by the thickness field here.

 

Symbol Property Connections

This is one of my favorite things in complex symbology. On the Symbology by Attribute pane, there's a checkbox to allow symbol property connections, visible in the first image above. Checking that box adds little symbols to the symbology tab.

jcarlson_3-1615814606111.png

Clicking on one of those will set a property as being connected to an attribute (or an expression). You'll notice in the image above that there is an up arrow next to width. This indicates that the width attribute is being overridden by the setting I put in place earlier, and I cannot put an addition property connection onto it.

Using this option does not automatically scale your values to a defined range as in the section above, but some basic  Arcade scripting can accomplish the same effect if it is needed.

- Josh Carlson
Kendall County GIS
Anzhi
by
New Contributor II

Thanks a lot @jcarlson  very interesting tool.

But for now I would like to create Categories with using Arcade like:

If( $feature.Thickness< 0.8 + $feature.Type == 'Secondary')
{
return "Secondary up to 0.8"

}
else if ($feature.Thickness < 0.8 + $feature.Type == 'Secondary')
{
return "Vein up to 0.8"

}

after this code everythink is OK in Arcade window, but after when I click OK, I have message "Requested operation could not be completed"

could you please advise

regards,

Anz

 

0 Kudos
jcarlson
MVP Esteemed Contributor

Yes, that's possible as well! However, in order to use an expression-based classification, you'll either need to lump all your evaluations (type and width together) into one expression, or the expression needs to be done via a property connection.

All in One

This is probably the route you want to go, since your numeric value is in discrete classes. We'll take the Type value and just append to it different text based on the width. Unless there's more going on than your screenshot implies, it looks like you just want the "type" field value, without any further evaluation, combined with a numeric classification.

Set the symbology to Unique Values and set the Field to an expression like the following:

var w = $feature.width
var width_str

// Here we define the width classification ranges
if(w < 0.8){
    width_str = ' up to 0.8'
} else if (w < 2) {
    width_str = ' between 0.8 and 2'
} else if ....

// and so on

return $feature.Type + width_str

 

Because the if/else if statements evaluate in order, there's no need to do a "w > N and w < M", as the "greater than" portion is accounted for in the preceding if statement.

- Josh Carlson
Kendall County GIS
0 Kudos
Anzhi
by
New Contributor II

Thanks a lot. This was very helpful.

 

regards,

Anzhelika

0 Kudos
Anzhi
by
New Contributor II

Hello,

One more question

Is it possible to add condition regarding color and thickness like:

else if (y == "Secondary" && x < 2 && x > 0.8) {
return "Medium Fault";
return rgb(0, 7, 186);

regards,

Anzhelika

0 Kudos
jcarlson
MVP Esteemed Contributor

For color, I'd just write additional if statements and create a separate symbology category, then make the changes there. Returning a color value in the symbology expression probably won't work, though I've not tested it.

- Josh Carlson
Kendall County GIS
0 Kudos