Input:

Polyline Shapefile (all lines are different lengths) and a specified number of points that will be placed on the line (will be same number of points for all lines)

Desired Output:

Point shapefile with a point at each end of the poly line and the remaining points equally spaced spaced along the line. See picture. In this example, I would input Polylines A/B/C/D and specify that I want 6 data points.

.

Using the "Construct Points" tool in Editor is not an option, I need this to be done for approximately 70,000 lines.

I have tried ET Geowizards, Hawth's Tools, and have looked through XTools Pro but have not found any solution. It is imperative that each polyline have the exact same number of points and that a point is created at the start and end of the line.

I imagine I am not using the correct language to find the solution to this, as I figure someone else has needed to do something similar before me.

Polyline Example

up vote 3 down vote accepted

If you're open to using python, and are in fact using ArcGIS 10.x, you can use the following:

>>> import arcpy
>>> points = []
>>> for row in arcpy.da.SearchCursor("YourInputLinesFileHere", ["SHAPE@"]):
...     length = row[0].length
...     for i in range(0,6):
...         point = row[0].positionAlongLine(length/5*i)
...         points.append(point)    
>>> arcpy.CopyFeatures_management(points, 'YourOutputPointsFileHere')

enter image description here

  • That looks to be EXACTLY what I want to do! However, I am not familiar with python without some hand holding unfortunately. I am trying to use the IDLE Python GUI that is installed on my computer to run the script but am unsure what syntax the "YourInputLinesFileHere", "Shape@" and "YourOutputPointsFilesHere" needs for it to run. Thanks for your time! I am getting an error now that says "ImportError: No module named arcpy". – Water_Hammer_85 Oct 20 '14 at 23:16
  • What version of ArcGIS are you using? There was a large shift between 9.3 and 10.0. – phloem Oct 20 '14 at 23:21
  • If you're using 10.0+, open ArcMap. Add your lines. Under Geoprocessing menu, open Python. Enter the script as shown, except change "YourInput..." to the name of your lines layer, change "YourOutput..." to an output location (for example, you can use exactly "in_memory\points" to save the output to an in-memory layer called "points"). Leave "Shape@" as it is - this is the line's geometry. – phloem Oct 20 '14 at 23:26
  • @phloem this will only work with 10.1+ – ianbroad Oct 21 '14 at 1:09
  • Yes, just got it to run and had to use 10.1 to do so! I don't have enough "rep" to give you a +1 but will return and do so when I am able to! – Water_Hammer_85 Oct 21 '14 at 1:18

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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