Select to view content in your preferred language

Expression to update Point attribute with attributes of intersecting polygon

671
4
Jump to solution
01-09-2024 11:25 AM
JamesBooth
Occasional Contributor

Hello!

Looking for some assistance on what I need to do to make an arcade expression work and apply an attribute rule to a feature class. What I have are two feature classes. One is an address point layer and the other is a postal code polygon layer. The address point file has a field called "POSTAL_CODE". The Postal Code polygon layer have two fields that make up the Postal Code. The two fields are "LDU" and "FSA". I want the "POSTAL_CODE" field in the address point layer to be updated with the "FSA" and the "LDU" values of the intersecting postal code polygon. It should be formatted in the POSTAL_CODE field as "FSA" + " " + "LDU", so that there is a space between the two values. e.g. here is a valid postal code = "L1N 0B7". The code I have so far is seen below. The error I'm getting is on "line 11. Semicolon or new line expected." I'm having trouble troubleshooting this one and could use some advice! Thanks!

var LDUvalue = FeatureSetByName($datastore, "ADDR_Postal_Code_Boundaries", ["LDU"], false);
var FSAvalue = FeatureSetByName($datastore, "ADDR_Postal_Code_Boundaries", ["FSA"], false);
var intersectLayer = Intersects(FSAvalue, $feature);
var cnt = Count(intersectLayer);

var result = Null;

if (cnt > 0) {
var layer = First(intersectLayer);
if (layer != null) {
result = layer.Get("FSA") + " " + layer.Get("LDU");
}
}

return result;

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

When you create the FSAValue layer, you're only including the FSA field and leaving off the LDU field. Give this code a try

var FSAvalue = FeatureSetByName($datastore, "ADDR_Postal_Code_Boundaries", ["FSA", "LDU"], false);
var intersectLayer = Intersects(FSAvalue, $feature);
if (Count(intersectLayer) > 0) {
  var layer = First(intersectLayer);
  if (layer != null) return layer.FSA + " " + layer.LDU;
}
return null;

View solution in original post

4 Replies
KenBuja
MVP Esteemed Contributor

Line 11 should look like this

result = layer.FSA + " " + layer.LDU;
JamesBooth
Occasional Contributor

That now gives me a different error unfortunately. "Error on line 11. Field not found LDU" I know for a fact that my field is called LDU in the ADDR_Postal_Code_Boundaries feature class. So I'm not sure what's happening exactly. But I appreciate your help!

0 Kudos
KenBuja
MVP Esteemed Contributor

When you create the FSAValue layer, you're only including the FSA field and leaving off the LDU field. Give this code a try

var FSAvalue = FeatureSetByName($datastore, "ADDR_Postal_Code_Boundaries", ["FSA", "LDU"], false);
var intersectLayer = Intersects(FSAvalue, $feature);
if (Count(intersectLayer) > 0) {
  var layer = First(intersectLayer);
  if (layer != null) return layer.FSA + " " + layer.LDU;
}
return null;
JamesBooth
Occasional Contributor

Duh! I can see what you mean now! Thank you!

0 Kudos