I have a polyline in ArcMap 10 and I am able to script the length of the line in Python using this bit of code:

#Calculate Radius of Curvature
# Import system modules
import sys, string, os, arcpy, math, shutil

#Set Environment Workspace
arcpy.env.workspace = "C:\data\ColRiver\ColRiver.gdb"

# Create search cursor
rows = arcpy.SearchCursor("c:\data\ColRiver\Colriver.gdb\ColumbiaRiverPolygon")

# Calculate the total length along the flowline
length = 0

shapeName = arcpy.Describe("ColumbiaRiverPolygon").shapeFieldName

for row in rows:
    # Create the geometry object
    feat = row.getValue(shapeName)
    length = length + feat.length

# Print the total length of flowline
print length

Now, I know that to get the radius of curvature for the line I will have to divide the total length by the straight line distance of the start point and end point. I understand that the way to get distance would be:

((x2-x1)^2 + (y2-y1)^2)^0.5

What I am unsure of is how to automate getting the start point and end point coordinates of x1, y1 and x2, y2 in order to get this straight line or euclidean distance. I plan to implement part of the code in a tool/script for ArcMap and don't want to have to type in the coordinates every single time. Any suggestions for a Python newbie?

  • 1
    Note that your intended calculation is not a radius of curvature. It is one measure of tortuosity of the polyline.
    – whuber
    Jan 3, 2012 at 16:55
  • 1
    There is something else strange about this setup: the code computes the total length of all features in a dataset. A set of two or more features has no unique start or end point, which makes the calculation you are attempting undefined. Some high-level description of what this dataset contains and what you are really trying to accomplish may help you obtain replies that are more useful than otherwise.
    – whuber
    Jan 3, 2012 at 16:58
  • Thanks for the feedback @whuber. I see what you mean about the first part of the code computing the total length of all the features. It is accurate for my current needs because it is only measuring the polyline. All I really want to know is how I can access the start point or origin or beginnning extent of the polyline and the end point or end of the polyline and calculate a straight line distance. Are you saying that a Arc doesn't define a beginning and end to a polyline? Jan 3, 2012 at 20:03
  • 1
    My second point, Nick, is that the layer is an ambiguous representation of a polyline and therefore there does not exist a clear start or end to it. You might need to amalgamate all the features into a single polyline feature first. Even single features can branch, so you would also need to check for branching and correct (or exclude) it somehow. This suggests you really have two questions here: (1) how to compute the start and end of a single unbranching polyline feature and (2) how to create such a feature from a layer consisting of several of its component parts.
    – whuber
    Jan 3, 2012 at 20:08
  • Your input layer is called "ColumbiaRiverPolygon" this would suggest you are processing a Polygon dataset and not a Polyline dataset. Thus length is the perimeter and not the centreline.
    – Hornbydd
    Feb 25, 2014 at 10:08

1 Answer 1


To get the start point and end point of a line - you can use the arcpy.FeatureVerticesToPoints_management tool - and specify "START" or "END" - this will create a new feature class for you - which you can then query using a search cusror and find the coordiantes with SHAPE.extent.XMin and YMin for each point. (note XMax and YMax should be the same for a point).

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.