Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm still pretty new to arcpy and am still learning. I'm working on a script that has a polyline as its input. I'm able to traverse the polyline and get points at certain intervals. These intervals are represented as segments If I have segment AB, where A and B are points on the polyline, how can I traverse the points on the polyline in between A and B and grab those points to add to a shapefile?

Thanks in advance

share|improve this question
This question is similar to yours,… – artwork21 Mar 5 '13 at 16:53

Here is a script from a class I took that traverses a polyline and gets the XY of each point

infc = 'Polygon.shp'
rows = arcpy.SearchCursor(infc)

# Enter for loop for each feature/row
for row in rows:
    # Create the geometry object
    feat = row.getValue(shapefieldname)

# Print the current multipoint's ID
print "Feature %i:" % row.getValue(desc.OIDFieldName)
partnum = 0

# Step through each part of the feature
for part in feat:
    # Print the part number
    print "Part %i:" % partnum
    # Step through each vertex in the feature
    for pnt in feat.getPart(partnum):
        if pnt:
            # Print x,y coordinates of current point
            print pnt.X, pnt.Y #Here is the point
            #Add the point to your shapefile
            # If pnt is None, this represents an interior ring
            print "Interior Ring:"
    partnum += 1
share|improve this answer

You could write a script as per EmdyP's nice example or, alternatively you have a couple of options if you don't like scripting:

  1. If you have ArcInfo you can use the Feature Vertices To Points tool from the Data Management toolbox.
  2. If you don't have an ArcInfo licence then you can use ET_GeoWizards. You will find a Polyline to point tool in the free conversion tools set.

ET_GeoWizards (and of course the "feature vertices to points" tool) can be used in Model Builder, so if you need to extract the vertices as part of a larger process, you can pull the tool into model builder and export to Python is required.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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