Hello -
I can't see why this expression for a temperature layer won't work. It's addressing a Field ("$feature.TmaxC") listing temperature attributes in 5-degree increments from -50 degrees to 30 degrees.
var Cold = ($feature.TmaxC < 10)
var Freeze = iif(Cold < 5, "Freezing", "Near Freezing")
return Freeze
My goal is to limit what's shown to freezing polygons surrounded by near-freezing polygons, and hide any temperatures greater than 10(or 9.9) degrees. What I THINK it's saying is:
"Cold" is only everything in $feature.TmaxC that's below 10 degrees.
"Freeze" is everything in Cold that's less than 5 degrees (so, 0 on down to -50), and we'll call that "Freezing".
What's left (anywhere it's 5 degrees) is called "Near Freezing".
Now show me the two categories of Freeze.
The result in my map is that the entire planet is one category - freezing.
Thanks for any help!
Solved! Go to Solution.
Proper noob on the Arcade language,
but the When function might be appropriate:
Logical Functions | ArcGIS for Developers
Proper noob on the Arcade language,
but the When function might be appropriate:
Logical Functions | ArcGIS for Developers
Thank you, David! New at this, so the simple idea of "when" never entered my mind.
Learning in baby steps.
Your first line
var Cold = ($feature.TmaxC < 10)
returns a boolean value (true for all temperatures below 10). So when you test that in your second line
var Freeze = iif(Cold < 5, "Freezing", "Near Freezing")
it's actually checking whether true (which evaluates as 1) is less than 5, which is true.
This syntax will give you all your different categories:
return when($feature.TmaxC < 5, "Freezing",
$feature.TmaxC == 5, "Near Freezing",
$feature.TmaxC < 10, "Cold",
"Other"
);
Thanks, Ken. At first I thought you were suggesting combining mine with yours, which seemed redundant, then I figured out your "when" block was all it really needed. Since no "other" is required here (and I like having variables), I finally went with this:
var Temp = $feature.TmaxC
var Cold = when(Temp < 5, "Freezing", Temp < 10 , "Near Freezing","")
return Cold