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 #try: # 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?