Select to view content in your preferred language

Symbolising a feature baced on an Arcade expresson on the web map.

740
3
Jump to solution
07-09-2021 11:45 AM
Laura_m_Conner
Regular Contributor

All,

On a web map, I want to symbolize a feature based on whether the value is greater than, less than, or equal to a set amount. What is the easiest way to achieve this? If I were to do it in an Arcade expression, what would the expression be?

I have a layer (water mains) that I need to highlight the mains with diameters 10 inches or greater. In our system, there are about 50 different pipe diameter sizes. Initially, I tried to do the symbols by pulling in each unique value and grouping the sizes. However, I can't seem to group them in the web map.

Next, I tried using unique symbols based on the evaluation of an Arcade expression. I have yet to get this to work as intended. First, I tried the simple expression:

$feature.DIAMETER >= 10,

Testing the expression returned no errors. However, all the mains evaluated as "other". None were 'True' (10-inch diameter or above) or "False" (diameter under 10 inches). All the mains should have evaluated as either "true" or "false". To address the issue, I tried the expression in an if-then statement:

IIf($feature.DIAMETER >= 10, "true", "false").

Again testing the statement returned no errors. When I saved and applied the expression, it came up with a warning that "the expression did not have enough information to change the display." I tried the if-then expression with numerical values for True and false. I.e.:

IIf($feature.DIAMETER >= 10, 10, 9).

That also had the same issue. I could not find documentation on the command/function to render a symbol.

After the if-then statement, I tried a "when" statement. Again the same thing happened, the test of the expression would no errors, but the warning the expression did not have enough information to change the display occurred.

I tried to research Arcade expressions, but I could not find much. I could not find any documentation pertaining to my situation or issue. Also, I could not find a list of the command/function for Arcade. If you could provide links to some resources on this issue or arcade functions, please do so.

I was working with a Feature Layer in the new map viewer on ArcGIS online.

Thanks for your help.
Laura.

0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

If you use a sequence of if...else if... (plus an optional else), it's fairly straightforward, and a little easier to wrap your head around than nested IIf statements.

 

var d = $feature.DIAMETER
var breakpoint = 10

if(d > breakpoint){
    return 'Class 1'
} else if(d == breakpoint){
    return 'Class 2'
} else if(d < breakpoint){
    return 'Class 3'
} else {
    return 'Diameter expressions didn't evaluate! :('
}

 

 

The fact that your first attempt did not return either 'True' or 'False' is puzzling. Try including some console statements in your expression to test things.

console($feature.DIAMETER >= 10)

 That can give you a way to see what's being evaluated.

Also, what kind of field is "DIAMETER"? I'd assume it's numeric, but the way the expression behaved has me wondering.

- Josh Carlson
Kendall County GIS

View solution in original post

0 Kudos
3 Replies
jcarlson
MVP Esteemed Contributor

If you use a sequence of if...else if... (plus an optional else), it's fairly straightforward, and a little easier to wrap your head around than nested IIf statements.

 

var d = $feature.DIAMETER
var breakpoint = 10

if(d > breakpoint){
    return 'Class 1'
} else if(d == breakpoint){
    return 'Class 2'
} else if(d < breakpoint){
    return 'Class 3'
} else {
    return 'Diameter expressions didn't evaluate! :('
}

 

 

The fact that your first attempt did not return either 'True' or 'False' is puzzling. Try including some console statements in your expression to test things.

console($feature.DIAMETER >= 10)

 That can give you a way to see what's being evaluated.

Also, what kind of field is "DIAMETER"? I'd assume it's numeric, but the way the expression behaved has me wondering.

- Josh Carlson
Kendall County GIS
0 Kudos
Laura_m_Conner
Regular Contributor

jcarlson,

Thank you, the un-nested if-then did the trick.  Where can I find documentation like that? Also the field  "DIAMETER"? was a double. I do not quite know how check it in the web layer.

Thanks for your help.
Laura.

0 Kudos
jcarlson
MVP Esteemed Contributor

The structure and logic page is very helpful.You can check a field type in the Data tab of the item's page in your Content.

jcarlson_0-1626105731956.png

 

- Josh Carlson
Kendall County GIS
0 Kudos