Select to view content in your preferred language

Question on checking for multiple values in array

139
3
Jump to solution
Tuesday
Ferreira
Emerging Contributor

Hello,

I'm by no means a heavy user of arcade, so please forgive me if this doesn't make sense. I'm open for suggestions if you think I'm able to achieve this any other way.

I'm currently trying to "import" symbology and labeling properties from a hosted feature dataset to another hosted feature dataset and make them visually match each other. The datasets in question are parcels and roads.

My goal is to have the label of parcels located in a given road matching the label color of that road. 

The parcel data, however, does not contain an independent field with only the road name where that parcel is located. Instead, it has a single field that carries the address number and the road name. Therefore, I had to come up with an arcade expression to separate these values into an array. Having separate values would allow me to come up with a custom array of matching values to the road dataset, and ultimately be able to create custom symbology classes for the parcel dataset.

This is what I came up with:

//Retrieves address value
var siteaddress = $feature.SITEADDRESS;

//Separates address value into different arrays considering a space as separator
var siteroad = Split(siteaddress, " ");

// Removes first array from separated address value(Equivalent to Address Number)
var roadname = Slice(siteroad, 1);

// Concatenate results using a space as separator
var concatroad = Concatenate(roadname, " ");

//Capitalizes the beginning of every array value
var properroad = Proper(concatroad, 'everyword');  

//Check if arrays include the value 'Cass Lake Rd'
  if(Includes([properroad], 'Cass Lake Rd')){
    return "Cass Lake Rd";
  }
return properroad // Returns: ["S", "Main", "St"]

 

My symbology classes ended up like the picture below. The only issue I have is that some parcels along Cass Lake Rd have other values besides just the road name. Hence why I was trying to run a check looking to find and replace any arrays that contained all three values ["Cass"], ["Lake"], and ["Rd"]. 

Ferreira_0-1778606063879.png

I'm assuming the Includes function only looks for one single value out of an array, correct? Is there a way to check multiple values from an array? Better yet, is there a more efficient way to achieve this?

 

Any insights would be greatly appreciated. Thanks in advance!

0 Kudos
1 Solution

Accepted Solutions
VenkataKondepati
Frequent Contributor

Hi @Ferreira,

I think you are going in the right direction, but instead of includes, you can use find for better results.
if (Find('Cass Lake Rd', properroad) > -1){

        return 'Cass Lake Rd';


Text functions | ArcGIS Arcade | Esri Developer

This should solve your problem, but I recommend creating a dedicated, normalized road-name field in the parcel layer rather than handling this dynamically in the symbology expression. That will make labeling, joins, symbology, and maintenance much easier.


Regards,
Venkat
Book a meeting with me:Get on a Call
Follow me on: LinkedIn

View solution in original post

0 Kudos
3 Replies
VenkataKondepati
Frequent Contributor

Hi @Ferreira,

I think you are going in the right direction, but instead of includes, you can use find for better results.
if (Find('Cass Lake Rd', properroad) > -1){

        return 'Cass Lake Rd';


Text functions | ArcGIS Arcade | Esri Developer

This should solve your problem, but I recommend creating a dedicated, normalized road-name field in the parcel layer rather than handling this dynamically in the symbology expression. That will make labeling, joins, symbology, and maintenance much easier.


Regards,
Venkat
Book a meeting with me:Get on a Call
Follow me on: LinkedIn
0 Kudos
Ferreira
Emerging Contributor

Ah-ha! That worked beautifully.

I wasn't aware that the Find function would work for this particular case. Thank you very much!

Unfortunately I do not have editing rights to any of these datasets. They're updated and maintained by my local government, so I'm trying to set up something and rely on always having an updated map whenever I open this project and the data owner have made changes to the feature layer.

VenkataKondepati
Frequent Contributor

No problem. Thanks for the confirmation.

Regards,
Venkat
Book a meeting with me:Get on a Call
Follow me on: LinkedIn
0 Kudos