I have a polygon layer and a polyline layer for the polyline layer i am able to count the distinct features using the following arcade expression. The distinct values are found by removing the last two numbers of the string
Var textlenght =COUNT(TEXT($feature["label"]))
Var label = textlenght-2
var stringleft = Left($feature["label"], label)
var sql = "label LIKE '%" + stringleft+"%'"
var Filt = filter($layer,sql)
return count(Filt)
For the polygon layer i am able to get the total length of those polyline s in my first layer that intersect it using the following expression
// get the ug Duct feature set:
var sql = "(surface_ty = '" + 2 + "'"+" OR "+"surface_ty = ' " +3+ "'"+" OR "+"surface_ty = ' " +4+ "'"+" OR "+"surface_ty = ' " +5+ "'"+" OR "+"surface_ty = ' " +6+ "'"+" OR "+"surface_ty = ' " +7+ "')"+" AND "+"(status = '" + 1 + "'"+" OR "+"status = ' " +3+ "')"
var lines = filter(FeatureSetByName($map,"LLD_Fibre_Duct_TLI"),sql)
// polylines that intersect with the polygon
var relevantlines = Intersects($feature, lines);
var cnt = Count(relevantlines);
var totlengthUG = 0;
if (cnt > 0) {
for (var line in relevantlines) {
var lineint = Intersection(line, $feature);
totlengthUG += LengthGeodetic(lineint, 'm');
}
}
return round(totlengthUG,2)
my problem is the the polylines are overlapping and each polyline represents a duct in a trench. I want to be able to combine the two functions and divide the total length by the count of distinct polylines in order to get the trench length . I guess i would have to iterate through the feature set of the label field in the polyline and replace the values ,then sum them into an array where i can count the new distinct values i just cant figure out how to get this iteration to work. Xander Bakker perhaps you can help ?