Measure Features in ArcGIS Online, or Calculate Length

3211
6
Jump to solution
07-15-2015 09:56 AM
JonathanMori1
New Contributor III

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!

1 Solution

Accepted Solutions
PeteCrosier
Occasional Contributor III

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;

View solution in original post

6 Replies
PeteCrosier
Occasional Contributor III

Hi Jonathan, did you figure this out?

0 Kudos
PeteCrosier
Occasional Contributor III

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;

View solution in original post

PeteCrosier
Occasional Contributor III

In the new world you can use:

Length(Geometry($feature), 'meters');

.. much easier!

JonathanMori4
New Contributor

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.

0 Kudos
JeffWard
Regular Contributor II

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.

Jeff Ward
Summit County, Utah
0 Kudos
AnudeepGorantla
New Contributor

WHAT WERE THE UNITS OF THE LENGTH IS IT Meters or Feet?

0 Kudos