I'm new to Arcade and hoping for some advice and examples on where to start...
I have a field with numeric values e.g 1, 3 , 5. In the popup I want to replace these values with their descriptions. The field may contain one or many values for each location. I'm assuming I add the values and description to a dictionary and then split the field by comma, add to an array and return the list? I'm just not sure what that looks like! Any help gratefully received.
Solved! Go to Solution.
You assume right.
// define your decode dictionary
var decode_dict = {
"1": "a",
"3": "c",
"5": "e"
}
// get an array of your coded values
// here, I'm removing spaces from the field and then split by comma
var coded_values = Split(Replace($feature.Field, " ", ""), ",", -1, true)
// create an empty array and append the decoded values
var decoded_values = []
for(var i in coded_values) {
Push(decoded_values, decode_dict[coded_values[i]])
}
// convert the array to string (here, I concatenate with comma) and return
return Concatenate(decoded_values, ", ")
The ArcGIS Developer page for Arcade is a good place to start:
Getting Started | ArcGIS Arcade | ArcGIS Developer
I find the function reference especially important, this is a page that I have bookmarked:
Function Reference | ArcGIS Arcade | ArcGIS Developer
If you want to play around, you can do so in the Arcade Playground:
Playground | ArcGIS Arcade | ArcGIS Developer
If you're looking for examples, there is a Github with Arcade expressions for diffferent profiles:
You assume right.
// define your decode dictionary
var decode_dict = {
"1": "a",
"3": "c",
"5": "e"
}
// get an array of your coded values
// here, I'm removing spaces from the field and then split by comma
var coded_values = Split(Replace($feature.Field, " ", ""), ",", -1, true)
// create an empty array and append the decoded values
var decoded_values = []
for(var i in coded_values) {
Push(decoded_values, decode_dict[coded_values[i]])
}
// convert the array to string (here, I concatenate with comma) and return
return Concatenate(decoded_values, ", ")
The ArcGIS Developer page for Arcade is a good place to start:
Getting Started | ArcGIS Arcade | ArcGIS Developer
I find the function reference especially important, this is a page that I have bookmarked:
Function Reference | ArcGIS Arcade | ArcGIS Developer
If you want to play around, you can do so in the Arcade Playground:
Playground | ArcGIS Arcade | ArcGIS Developer
If you're looking for examples, there is a Github with Arcade expressions for diffferent profiles:
That's great. Thanks for your help Johannes.