Using Arcade to classify my data

979
3
Jump to solution
09-14-2021 02:46 AM
Labels (1)
AndrewEastop
New Contributor III

Hello everyone,

I have created a new field called 'Settlement_class'. I want it to have two options (Settlement/Non settlement) based on the data in the Band field beside. 

Bands B G H are settlements and the rest are non settlements. Is Arcade the best way to go about this?

Any help would be very much appreciated 

thanks 

Tags (3)
0 Kudos
2 Solutions

Accepted Solutions
DanPatterson
MVP Esteemed Contributor

A simple python expression would be easy as well?

try replacing fld with your fieldname in ! marks below (  !FieldNameHere! )

fld = 'B'
['Non-Settlement', 'Settlement'][fld in ['B', 'G', 'H']]
'Settlement'

fld = 'C'
['Non-Settlement', 'Settlement'][fld in ['B', 'G', 'H']]
'Non-Settlement'

 


... sort of retired...

View solution in original post

JohannesLindner
MVP Frequent Contributor
var settlement_bands = ["B", "G", "H"]
if(Includes(settlement_bands, $feature.Band)) {
  return "Settlement"
}
return "Non settlement"

 

You can use that expression

  • in the CalculateField tool (switch language to Arcade) to permanently store it in the table
  • in the popup, to show it only there (useful if it changes a lot)
  • in an Attribute Rule, to store it permanently in the table whenever a featire is created and/or updated

Have a great day!
Johannes

View solution in original post

3 Replies
DanPatterson
MVP Esteemed Contributor

A simple python expression would be easy as well?

try replacing fld with your fieldname in ! marks below (  !FieldNameHere! )

fld = 'B'
['Non-Settlement', 'Settlement'][fld in ['B', 'G', 'H']]
'Settlement'

fld = 'C'
['Non-Settlement', 'Settlement'][fld in ['B', 'G', 'H']]
'Non-Settlement'

 


... sort of retired...
JohannesLindner
MVP Frequent Contributor
var settlement_bands = ["B", "G", "H"]
if(Includes(settlement_bands, $feature.Band)) {
  return "Settlement"
}
return "Non settlement"

 

You can use that expression

  • in the CalculateField tool (switch language to Arcade) to permanently store it in the table
  • in the popup, to show it only there (useful if it changes a lot)
  • in an Attribute Rule, to store it permanently in the table whenever a featire is created and/or updated

Have a great day!
Johannes
AndrewEastop
New Contributor III

Thank you Johannes

0 Kudos