-1

I am using ArcGIS Pro.

I am trying to return a string if the attribute of another feature is the same as the current one in Arcade:

    var hazardidpt = FeatureSetByName($datastore, "Hazard Point", ["HazardID"])
    var siteidpt = FeatureSetByName($datastore, "Hazard Point", ["SiteID"])
    var hazardtypept = FeatureSetByName($datastore, "Hazard Point")

   if (($feature["HazardID"] == hazardidpt) && ($feature["SiteID"] == siteidpt ) ){
     return 'test' } 

It doesn't seem to work

5
  • 2
    'Doesn't work' or 'Doesn't seem to work'? What is the expected result? What is the actual result?
    – Berend
    Oct 22 '21 at 9:58
  • It doesn't work. If the hazard ID equals hazard ID in the point feature and site ID are the same, return hazard type field from the point into the polygon
    – lloyd
    Oct 22 '21 at 10:13
  • 1
    You're comparing an attribute value from $feature with a FeatureSet (i.e. a collection of features). How would that work?
    – Berend
    Oct 22 '21 at 10:29
  • @Berend do you know how I might make it work?
    – lloyd
    Oct 22 '21 at 10:38
  • 2
    No, it's not clear from your question how you want it to work and what your data looks like. Please explain what another feature would be. And don't put it in a comment, but edit the question so others don't need to go over the comments to understand what's going on. (BTW I'm not very familiar with Arcade, so I don't think I can help you out. I'm just trying to point out why the question is not answerable right now, and how you could improve it)
    – Berend
    Oct 22 '21 at 10:44
1

@lloyd, it's time for you to read the help file and understand what it is telling you. The function FeatureSetByName() clearly states it returns a FeatureSet.

Read that and you discover that this is a set of Features, keyword being "set" which is a type of collection object. Now you understand that the IF statement you have created makes no sense

If ($feature["HazardID"] == hazardidpt).....

equates to

If a hazard ID value = a collection object then do something

Your collection object could have thousands of rows, so which row are you wanting to test against...

Not the answer you're looking for? Browse other questions tagged or ask your own question.