Is there a way to calculate length, or at least a tool to click and measure an individual feature? This is very important for the project we are working on as sometimes our users have to measure many features fairly quickly. It would take too much time to use the measure tool to manually measure each feature.
We are using FeatureServer Services from an Enterprise Geodatabase on ArcGIS Server 10.2.2.
Thanks!
Solved! Go to Solution.
Very belated answer to my own question as I finally have lengths working! Used this custom attribute expression to display line lengths in a pop-up:
var total_length = 0.0; for (var i in Geometry($feature).paths[0]) { if (i != 0) { var x = Geometry($feature).paths[0].x; var y = Geometry($feature).paths[0].y; var prev_x = Geometry($feature).paths[0][i - 1].x; var prev_y = Geometry($feature).paths[0][i - 1].y; total_length = total_length + (sqrt(pow(x - prev_x, 2) + pow(y - prev_y, 2))); } } return total_length;
Hi Jonathan, did you figure this out?
Very belated answer to my own question as I finally have lengths working! Used this custom attribute expression to display line lengths in a pop-up:
var total_length = 0.0; for (var i in Geometry($feature).paths[0]) { if (i != 0) { var x = Geometry($feature).paths[0].x; var y = Geometry($feature).paths[0].y; var prev_x = Geometry($feature).paths[0][i - 1].x; var prev_y = Geometry($feature).paths[0][i - 1].y; total_length = total_length + (sqrt(pow(x - prev_x, 2) + pow(y - prev_y, 2))); } } return total_length;
In the new world you can use:
Length(Geometry($feature), 'meters');
.. much easier!
Wow, this is great! Thanks!
I am curious if this will work with an enterprise geodatabase editing through ArcMap (maybe set up as a feature service through AGOL), I highly doubt it though as you'd probably have to do the editing through AGOL.
ArcMap has a built in "Calculate Geometry" option that allows you to calculate the length of features. You don't have to use Arcade, you just specify units.
WHAT WERE THE UNITS OF THE LENGTH IS IT Meters or Feet?