Select to view content in your preferred language

Arcade intersects featureSetByName not always returns result

753
4
12-03-2023 06:06 PM
PierreloupDucroix
Occasional Contributor III

Hello,

I have issues when trying to return a field from an intersecting polygon on points features. For some features it returns a result and for some others not. Here is my code :

// Value to copy from the intersected feature
var intersecting_field = "NAME";

// check existing value
var old_concession = $feature.CONCESSI;

if (isEmpty(old_concession) || old_concession == Null) {
// Create feature set to the intersecting class using the GDB Name
var intersecting_featset = FeatureSetByName($datastore, 'main.CONSESSION', [intersecting_field], true);
var intersected_feature = First(Intersects(intersecting_featset, $feature))
//console(intersected_feature.NAME)
// Check to make sure there was an intersected feature, if not, return the original value
if (IsEmpty(intersected_feature) || intersected_feature == null){
return;
}
// If the intersected feature is null, return the original value
if (IsEmpty(intersected_feature.name))
{
return;
}
var result = {
//result is a dictionary
"result": {
"attributes": {
"CONCESSI": intersected_feature[intersecting_field]
}
}
};
return result
}

 

I noted that including the geometry or not in the featureSet does not change the result, but I understand that this is a known bug, resolved in 3.2.

The polygons represent cities, so may have a large geometry.

Tested in ArcGIS Pro 3.1 in a UN mobile geodatabase, in popups and in an attribute rule.

 

[EDIT] I tried to debug, and found that count(intersected_feature) = 1. But even in this case, intersected_feature[intersecting_field] returns nothing...

0 Kudos
4 Replies
jcarlson
MVP Esteemed Contributor

Are you certain the intersecting features actually have values in the field? What about testing the expression against the objectid or globalid, just to see if it's an issue with the expression rather than the features themselves.

- Josh Carlson
Kendall County GIS
0 Kudos
JohannesLindner
MVP Frequent Contributor

This is an expression for a Calculation Attribute Rule with the field parameter left empty (it returns a dictionary). If you want to use this in other ways (eg a popup or an Attribute Rule with a set field), you should return a single value.

Have you tried to return intersected_feature.NAME instead of intersected_feature[intersecting_field]?


Have a great day!
Johannes
0 Kudos
PierreloupDucroix
Occasional Contributor III

Hi,

Indeed, it is an attribute rule that I am now testing in the popup in order to debug.

I reworked the code as follows :

1st field :

 

// Value to copy from the intersected feature
var intersecting_field = "NOM";

// Create feature set to the intersecting class using the GDB Name
var intersecting_featset = FeatureSetByName($datastore, 'main.CONSELEC', [intersecting_field], true);
return(count(Intersects(intersecting_featset, $feature)))

 

2nd field

 

 

// Value to copy from the intersected feature
var intersecting_field = "NOM";

// Create feature set to the intersecting class using the GDB Name
var intersecting_featset = FeatureSetByName($datastore, 'main.CONSELEC', ["*"], true);
var intersected_feature = First(Intersects(intersecting_featset, $feature))
// Check to make sure there was an intersected feature, if not, return the original value
if (IsEmpty(intersected_feature) || intersected_feature == null)
{ 
  return "Nope";
}
return intersected_feature.nom

 

3rd field is similar to 2nd but with return intersected_feature.globalid

But the result is similar.

Here you can view in action :

YswJpvFxGw.gif

There are no overlapping polygons, and the intersecting polygon has a value in the field, but for some reason, sometimes the function finds an intersecting polygon, but just doesn't return anything...

0 Kudos
PierreloupDucroix
Occasional Contributor III

Hello,

I made more tests, and now I am pretty sure that the issue is with the bounding box of the first polygon in the layer.

PierreloupDucroix_0-1712100074448.png

You can see in the previous image, that every point feature located in the second polygon, but intersecting the bounding box of the first polygon does not return the value.

If someone has encountered this or has a workaround...

So far I tried to delete/create spatial index, to copy features in another feature class, to recalculate spatial extent... Only the deletion of the first polygon resolve the issue... But of course I don't want that

 

[EDIT] I reproduced the bug in a simplified version :

PierreloupDucroix_0-1712123265186.png

I will contact the support team to log a bug

0 Kudos