Dear All,
Is it possible, to get the Length of Roads in a polygon layer using Arcade. I tried something below:
var fs = FeatureSetByName($map, 'Roads') //Clip(geometry, envelope) var roadsLength = Clip(fs, $feature) Length(roads, 'kilometers')
How can I achieve this.
Regards,
Krish
Hi krishnavsav ,
See below what you can do. This code is not optimized to enhance readability, however, depending the amount of lines you have in a polygon, this could result in a performance hit, since there will be multiple requests to the server.
// get the lines feature set:
var lines = FeatureSetByName($map,"Tubería Acero");
// select only the lines that intersect with the polygon
var relevantlines = Intersects($feature, lines);
// count the overlapping lines
var cnt = Count(relevantlines);
// set the initial total length to 0
var totlength = 0;
if (cnt > 0) {
// there are overlapping lines, loop through each line
for (var line in relevantlines) {
// intersect the line with the polygon
var lineint = Intersection(line, $feature);
// add the length to the total
totlength += LengthGeodetic(lineint, 'm');
}
}
return totlength;
Thank you for posting this @XanderBakker this is exactly what we were looking for in our Urban Search and Rescue search segment planning tool. You rock!