Hi all,
I have two layers. The first layer, contains streets as a line feature and in it, I make the attribute rules to extend the dataset. In my second layer, called "Analysepunkte_ExportFeatures" and that contains points that lie on those lines from the first layer. Each of the points contains a measurement value, the road width. Now I want to intersect the layers, and to calculate the mean of these points for each line.
When I am trying to update my attribute table in a test field with the field calculator, I get the error:
ERROR 160912: Failed to evaluate Arcade expression.
If I run everything through without this one attribute rule, then everything works again.
Here is my script of the attribute rule:
var fsSM = FeatureSetByName($datastore, "Analysepunkte_ExportFeatures", ["FB_Breite"]);
var zust = Intersects(fsSM, $feature);
var cnt = Count(zust)
var expr = ''
If (cnt == 0)
{expr = '0'}
else {
expr = Mean(zust)
}
return expr
How can I solve this?
Thanks for your help! 🙂
Solved! Go to Solution.
@DanPatterson Thanks for your input! Your input brought me to the solution.
Now, the script works for me - I've just needed to specify that my output needs to be a number:
var fsSM = FeatureSetByName($datastore, "Analysepunkte_ExportFeatures", ["FB_Breite"]);
var zust = Intersects(fsSM, $feature);
var cnt = Count(zust)
var expr = ''
if (cnt == 0)
{expr = '0'}
else {
expr = Number(Mean(zust, "FB_Breite"))
}
return expr
wouldn't you have to convert expr = Mean(zust) to text to match the output case of when cnt == 0 ?
@DanPatterson Thanks for your input! Your input brought me to the solution.
Now, the script works for me - I've just needed to specify that my output needs to be a number:
var fsSM = FeatureSetByName($datastore, "Analysepunkte_ExportFeatures", ["FB_Breite"]);
var zust = Intersects(fsSM, $feature);
var cnt = Count(zust)
var expr = ''
if (cnt == 0)
{expr = '0'}
else {
expr = Number(Mean(zust, "FB_Breite"))
}
return expr