# Getting all the points of polyline

I have some polyline feature objects in Python. Now I want to get all the points of polylines.

For example, if a polyline has start point `[0,0]` end point `[5,5]`. Result: `[1,1];[2,2];[3,3];[4,4];[5,5]`.

I want to find all the integer points on that line including end points. For straight line this is dead simple, but if polyline has Beizer Curve, Circular Arc, Elliptic Arc geometry types, then how can I do it?

I can only use those tools which are available in all license levels of ArcGIS. For example, ArcGIS Basic.

• In general you won't often get nice 'integer' points. It works in your example, but not often in real life. Usually, you just get locations for vertices, so in your case you would get [0,0] and [5,5]. The 'intermediate' points can be 'assumed.' Not sure how to do this in python, but several tools will allow you to create a point file of vertices from a line. Commented May 29, 2012 at 11:57
• Please, do not forget about "What should I do when someone answers my question?" Commented Oct 8, 2021 at 7:41

I know this is old but I was looking for the same as I don't have ArcInfo for the FeatureVerticesToPoints tools. After using Search cursor solution above I went forward to simplify the code and found that using NumPy Arrays in the Data Access Module a simple and very quick script could be produced. I'm using this as a script tool.

Note: The key is the `explode_to_points` parameter in `arcpy.da.FeatureClassToNumPyArray`

Here is link to ArcGIS Repository Location: Feature Class to Points

``````# Feature Class to Points
#
# Paul Smith (2012) [email protected]

# Imports
import arcpy
import numpy

#Inputs from user parameters
InFc  = arcpy.GetParameterAsText(0) # input feature class
OutFc = arcpy.GetParameterAsText(1) # output feature class

# Spatial reference of input feature class
SR = arcpy.Describe(InFc).spatialReference

# Create NumPy array from input feature class
array = arcpy.da.FeatureClassToNumPyArray(InFc,["SHAPE@XY"], spatial_reference=SR, explode_to_points=True)

# Check array and Exit if no features found
if array.size == 0:
arcpy.AddError(InFc + " has no features.")

# Create a new points feature class
else:
arcpy.da.NumPyArrayToFeatureClass(array, OutFc, ['SHAPE@XY'], SR)
``````
• Welcome to GIS.se Paul :) +1 for a well rounded and better than average first contribution, with code to boot. Thanks! Some editing tips: select text, inline or a block, and then `ctrl-k` to apply code formatting (same for `b`old and `i`talic). By convention we tend to avoid chatty bits like "hi", "thanks", "cheers". Those are implied as being always present, and help reinforce the idea this place is different from the usual forums and email. Welcome aboard. Commented Nov 14, 2012 at 5:47
• You need to put a placeholder for the where_clause on this line of the code array = arcpy.da.FeatureClassToNumPyArray(InFc,["SHAPE@XY"], "", spatial_reference=SR, explode_to_points=True) Commented May 23, 2014 at 20:50

The following should work on polylines and polygons:

``````import arcpy

infc = r"D:\Projects\GDBs\slowbutter.gdb\fc"

desc = arcpy.Describe(infc)
shapefieldname = desc.ShapeFieldName

rows = arcpy.SearchCursor(infc)
for row in rows:
# Create the geometry object
feat = row.getValue(shapefieldname)
print "Feature %i: " % row.getValue(desc.OIDFieldName)
partnum = 0
# Step through each part of the feature
for part in feat:
print "Part %i: " % partnum
part_list = []
for pnt in feat.getPart(partnum):
if pnt:
part_list.append([pnt.X, pnt.Y])
else:
# If pnt is None, this represents an interior ring
print "Interior Ring:"
partnum += 1
print part_list
``````

For some UK road data, I get this; a nested list of X,Y pairs for each vertex that makes up the polyline:

``````Feature 7:
Part 0:
[[-0.48053999999996222, 51.482510000000048], [-0.48032999999992398,
51.482609000000082], [-0.48026999999996178, 51.48273800000004],
[-0.48043999999993048, 51.482891000000052], [-0.48065999999994347, 51.482948000000079],
[-0.48123999999995704, 51.483009000000038]]
``````
• I've seen this on ESRI page. But if you look carefully in their description this code only returns the end points, not the points between them
– user
Commented May 29, 2012 at 17:08
• @crucifiedsoul - Yes, this is a variation of that ESRI sample, but it gives the X,Y pair of all the points, not just the end points. That's what you want, correct? Commented May 29, 2012 at 17:56
• I don't get it. The only thing is changing you are replacing `print pnt.X, pnt.Y` with `part_list.append([pnt.X, pnt.Y])`. And you are printing this at the end of the loop. How can your code get all the points of a line but ESRIs code doesn't?
– user
Commented May 30, 2012 at 2:58
• The describe method did not work for me. I had to just specify my shape field - arcpy.da.SearchCursor(fc, ["SHAPE@"]) Commented Oct 20, 2016 at 4:48
• Chad's script worked for me: i.sstatic.net/vhb5Q.png Commented Feb 2, 2022 at 19:35

As I understood you need to increase number of vertices for your polyline features. And also to transform all "Beizer Curve, Circular Arc, Elliptic Arc" segments into several line segments.

For this task in ArcGIS you can use Densify (Editing) tool in ArcToolbox.

Then you can convert your polylines' vertices to point features as suggested Darren Cope and artwork21.

If you prefer to do it in ArcMap take a look at Creating new points along a line help topic.

As Darren Cope has suggested, converting your layer to a point vertices may be done using the Feature Vertices to Points tool.

Here is the python code snippedt:

``````# import system modules
import arcpy
from arcpy import env

# Set environment settings
env.workspace = "C:/data"

# Set local variables
inFeatures = "majorrds.shp"
outFeatureClass = "c:/output/output.gdb/majorrds_midpt"

# Execute FeatureVerticesToPoints
arcpy.FeatureVerticesToPoints_management(inFeatures, outFeatureClass, "MID")
``````