7

I'm using ArcMap 10.0 and am trying to get the length of a polyline by adding a field to the attributes table and calculating geometry, but that option is grayed out. Someone suggested that it's because my map was in degrees but according to the properties for the data frame, both display and map units are in meters, which means I should be able to get the lengths of these lines, right?

1
  • 1
    Are you trying to do this with a shapefile or geodatabase?
    – Rayner
    Commented Sep 27, 2012 at 14:00

3 Answers 3

10

Your data is probably not projected. This means that inside the shapefile, the vertices of your polyline are stored as decimal degrees. Usually, you would have to use the Project tool to project the dataset into a planar spatial reference system that allows for geometric calculations in non-angular units. However, when calculating line length (but not area), ArcGIS can calculate the geodesic distance, which should result in an even more accurate result.

So instead of using the "Calculate geometry" tool, use Field calculator, select the "Python" parser, and enter the following expression:

!shape.length@meters!
8
  • dmahr: Thank you for the advice. You and David are correct: my data are not projected. I tried !shape.length@meters! and if that is literally what I'm supposed to enter (the new field is called 'length') I get a 'failure during processing, check the geoprocessing results window for details. That brings up a the Calculate Field table where I'm guessing I'm being invited to correct the expression? Or change the expression type? I also tried the Define Projection tool to change the object's spatial reference NAD 1983, but neither calculate geometry or !shape.length@meters! works on that.
    – Steve
    Commented Sep 11, 2012 at 20:17
  • Define projection only changed the metadata, not the actual coordinate values. Try defining the coordinate system back, then using the Project Tool or set the data frame's coordinate system to an appropriate projected coordsys.
    – mkennedy
    Commented Sep 11, 2012 at 20:41
  • @Steve Make sure that when you are using the field calculator, you are using the "Python" parser. Also, ensure the that "length" attribute's type is "double" and not "short" or "long. "
    – dmahr
    Commented Sep 11, 2012 at 21:47
  • @dmahr, It looked more promising, as the error message wasn't immediate. But again there was an error in the geoprocessing which just brought up the calculate field tool. I tried python and python 9.3 with the same result. Just to be sure, the Input Table is the costpath, the field name is length, the expression is !shape.length@meters!, the expression type is phython, and the code block is empty. Thanks!
    – Steve
    Commented Sep 12, 2012 at 15:29
  • What does the error message say?
    – dmahr
    Commented Sep 12, 2012 at 16:25
4

See "Reasons the Field Calculator might be Disabled" in the bottom half of Fundamentals of field calculations.

1
  • Kevin: Thank you for the link. You and dmahr correctly guessed that my data are not projected. That hasn't solved it however.... (see comments to dmahr's post).
    – Steve
    Commented Sep 11, 2012 at 20:01
0

I met the same problem. But I had my data projected, so this was not the problem. If the calculate geometry and field calculator are grayed and the feature classes are in GDB - start Editing in Editor tools, if this doesn´t help try to delete geodatabase lock in Windows explorer and restart ArcGIS a PC for sure.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.