ArcGIS Toolbox – Create Points on Polylines with ArcPy

Share Button

Updated – 9/17/2017
Fixed error dealing with setting spatial reference

Updated – 5/04/2016
All polyline fields are now included in the output Point feature class

Updated – 4/14/2016
Added additional INTERVAL point creation types
Fixed bug when creating points in reversed order

Previous Updates
Added capability to create only start and end points
Added capability to create the points starting at either the beginning, or end of the line
Fixed compatibility with Python 3 for ArcGIS Pro

(If you’re using Firefox, then right click and Save Link As)
Download the Create Points on Lines Toolbox – works with ArcGIS 10.1+
View the Source Code

(any donations go towards hosting costs)

The Create Points on Lines tool creates points on lines at a specified distance, percentage, or interval value. The value can be fixed or field based. There is also an option to add the starting point, end point, or both to the output Point feature class.

NEW FEATURES

All polyline fields are now included in the output Point feature class.

Ability to choose the starting location. For example, if you want a point created 10 feet from the end of the line, change the Starting Location parameter to END.

There are two new point creation types: INTERVAL BY DISTANCE and INTERVAL BY PERCENTAGE.

If DISTANCE is chosen, one point will be created for each line at the specified distance.
If PERCENTAGE is chosen, one point will be created for each line at the specified percentage.
If INTERVAL BY DISTANCE is chosen, points will be created along each line at the specified distance interval. For example, if 5 is entered, then points will be created every 5 feet (or whatever units the coordinate system is in).
If INTERVAL BY PERCENTAGE is chosen, points will be created along each line at the specified percentage interval. For example, if 0.5 is entered, then points will be created at 5%, 10%, 15%, etc, all the way up to 100%.
If START/END POINTS is chosen, one point will be created at each end of the line.

The value used to create the points can be entered as a parameter, or a field can be selected.

The output Point feature class contains a field called LineOID, which is the OID of the line the point was created from. There is also a field called Value, which contains the value that was used to create the point.

Be sure to view the Tool Help within the tool dialog box for detailed instructions. Also, check the Geoprocessing Results for any error messages.

Here’s a screenshot of the parameters:

Create Points on Lines parameters

I hope someone finds this tool useful. Please leave a comment if you have any questions or problems, and be sure to check out the other tools I’ve created!

129 thoughts on “ArcGIS Toolbox – Create Points on Polylines with ArcPy

  1. Thanks so much for this tool, Ian. It was exactly what I was looking for to construct points along a polyline at an interval based on field-values (values needed to be random). Keep up creating these great tools buddy!

      1. GOD be with you Ian, your tool is very useful, i used it to create long contour main canal for irrigation. But sometimes it says ‘out of bound’. Bbesides is there a way to add another field from polylines to created pointsbute table. And do you have any tool that can work as GOAL SEEK in excel. Thanks so much.

        1. Hi Abrham, thanks for the nice comment! I haven’t seen the ‘out of bounds’ error with the tool before. I’d need to see the data to try and troubleshoot it. The output point feature class should contain all the fields from the polyline feature class. Sorry I do not have any tool similar to Excel’s Goal Seek.

  2. Ian, I’ve been looking for a tool to build a single point at exactly 1/3 of a polyline’s length. I have a length field where I calculated 1/3 of the polyline lengths and tried using it to create a point using your tool. What happens is it seemed to just create a point at the end point. Is there something I may not be doing correctly?

    1. Tim, it’s hard to know what’s wrong without seeing a sample of the data. Did you calculate the 1/3 field based on the SHAPE length? What data type is the 1/3 field? If you look at the SHAPE length for a feature, is the 1/3 field correct?

      What coordinate system are you using?

      Also, you might try just using the PERCENTAGE option and for the value put in something like 0.333333333

  3. I have a similar script tool that I created, but it only creates points at specified intervals which is all I really need, but your tool is fantastic thanks! I was wondering about unit conversions. If the spatial reference has a linear unit of meters, but you want to calculate points at 100 foot intervals you have to input 30.48 in the “Distance | Interval | Percentage ” parameter and likewise for the other parameters. One would hope the user would know how to convert, but there is a work around for this. Here is the piece of code for this conversion in my tool:

    dist_units = sys.argv[3].split()
    dist = float(dist_units[0])
    units = dist_units[1]

    desc= arcpy.Describe(feature)
    sr = desc.SpatialReference
    linearUnit=sr.linearUnitName

    if linearUnit == “Foot_US”:
    if units == “Feet”:
    dist = dist
    elif units == “Meters”:
    dist = dist * 3.28084

    if linearUnit == “Meter”:
    if units == “Feet”:
    dist = dist * 0.3048
    elif units == “Meters”:
    dist = dist

    Here the units are specified in the parameters as a “Linear Unit” Type. The parameter is split to determine what units were specified by the user. The conversion could of course work for any unit in the drop down list, but I only have it set to convert meters and feet.

    1. Luke, thanks for the comment! That’s definitely a good idea, and I’m sure users would find it very helpful. In the tool help I do specify that any conversions must be calculated by the user, but in the future I should probably do something similar to what you posted here to make it more user friendly!

    1. Hi Jason-

      Sorry, but there is not. I take advantage of the positionAlongLine() method and it became available after 10.0. If you just need it ran once, I could possibly do it for you. Just send the file to the email listed on the Contact page.

  4. Great tool. I was wondering if it can be used to create multiple points along a line. This would be similar to the Distance tool provided, but code a point for each row from a specified field. Thoughts?

    1. Hi, Vadim! Well, each row would represent a different line section. It sounds like the INTERVAL option based on a field is what you are describing? Could you provide an example, specifically what value would be in the field and what the expected result would be?

  5. Thank you so much for developing this tool! I was hopelessly searching through GIS stack exchange for an answer to this problem when someone referred me to your tool. Thank you again – you’re helping a lot of people!

  6. Is there any way to add a field and populate it with an attribute value it with it?

    It would be super helpful if it would return not only the distance, but include an unique identifier like a defect_ID that i have in a table as well.

    I am new to this and am trying to figure it out and any assistance would be greatly appreciated.

  7. Hi! I tried to use this script in model buildser and got this error message:

    Executing (Create Points on Lines): CreatePointsLines C:\Users\rgustas\Dropbox\Thesis\Data\Test\ModelBuilder_Test\ModelBuilder_Test.gdb\Shoreline_300m_Poly_Landmass_Select_PRH_30 DISTANCE NO # 3000 BOTH C:\Users\rgustas\Dropbox\Thesis\Data\Test\ModelBuilder_Test\ModelBuilder_Test.gdb\Points_Poly_Landmass_Select_PRH_30
    Start Time: Tue Feb 17 15:39:19 2015
    Running script CreatePointsLines…
    Failed script CreatePointsLines…
    SyntaxError: invalid syntax (CreatePointsLines.tbx#CreatePointsLines_CreatePointsLines.py, line 84)
    Failed to execute (Create Points on Lines).
    Failed at Tue Feb 17 15:39:19 2015 (Elapsed Time: 0.45 seconds)

    Any help trouble shooting would be appreciated!

  8. Dear Ian, I think you may be some kind of GIS hero.

    I’m having the same issue as the person you first created the toolbox for. However, so far your tool works in that it creates a point 10km (for my problem) from the start of the line but what I actually want it to do is to create a point every 10km from the start of the line. Inevitably there will be a smaller section left over a the end which is fine I can delete those once i’m done.

    Is there a way to do this using your tool?
    Cheers
    Trisha

    1. Hi Patricia, thanks for the nice comment! If I understand correctly, then it sounds like you just need to use the INTERVAL option instead of DISTANCE. The INTERVAL option will create a point at whatever distance you choose for the total length of the line- not just one point.

  9. Hi Ian,
    This tool is fantastic. Thank you so much for creating it. Just one query.
    For the next part of my work I need to place a point x distance from the end point of the polyline rather than the start point.
    Is it possible to do this with your tool?
    Cheers
    Pete

    1. Hi Pete, a few other people have also asked this, so I’ve just added this capability. There’s now a new parameter called Starting Location where you choose either BEGINNING or END. Thanks for the comment, and I’m glad you found the tool useful.

  10. Thanks very much for this tool. I was using the “construct points” tool in ArcGIS editor to create points at set distances along features in a polyline shapefile (routes in fact). That only allowed me to create points on one feature at a time, which is very time consuming. This tool allowed me to create the points for all features within the polyline simultaneously.

  11. Thank for great tool. I have a small tip: the field LineOID should be INTEGER type, not string. It will be easier to join point class with the original line class.

  12. Thanks so much Ian for this tool, which is exactly I need. Just wonder how to run a command line under python 2.7 using this function:

    CreatePointsLines_CreatePointsLines(Input_Polyline_Feature_Class, Starting_Location, Type, Use_Field_to_Set_Value_, ”, Distance___Interval___Percentage_Value, Add_End_Points_, Output_Point_Feature_Class)

    What should I import to run this module?

    Thanks in advance.

    1. Hello! I’m glad you find it useful. To do this you need to do the following:

      import arcpy
      arcpy.ImportToolbox("C:\\CreatePointsLines.tbx") #change to your path
      arcpy.CreatePointsLines_CreatePointsLines("Input Lines", "BEGINNING", "DISTANCE", "NO", "", 20, "NO", "Output")

      It can be helpful to first type this into the Python window of ArcCatalog, because then you get the auto-complete functionality.

      Hope this helps. Let me know if you have any other questions.

  13. Hi Ian! Is there any way that this can work with a feature class that has MULTIPLE polylines? When I try your tool with a feature class that has multiple polylines, it says that it is successful but nonthing shows up in the attribute table. When I tried it with a feature class that only has one polyline, it works…. but I need the point to be in a feature class with many polylines!

    Thanks!

  14. Hi Ian,

    Fantastic bit of Kit – works seamlessly 😀

    Wondering if there is anyway to add multiple values so as to be able to capture 25,50,75% in one run of the tool ? I can happily run the script over those variables a number of times but looking to reduce inputs ?

    Thanks again for a brilliant tool.

    Leith

    1. Hi Leith, thanks for the comment! It’s possible to use the built in Batch functionality with the tool, but I’m not sure that would help you. The best way I can think of to do what you want is to write a Python script that imports the toolbox. I’ve sent you an email to discuss further.

  15. Hey! This tool might be useful for me, but I do not understand, how to use it. I am doing everything in metrics. How can I place a point 3 kilometers from the start point? If I put the distance to 3, the point will appear somewhat 200 km from the starting point. If the units are feet, then 3 should have been about 0.0009144 kilometers, not 200.. Can you help me figure this out?
    Thanks!

    1. Hi Brita, thanks for the comment!

      The units for the tool are the same as the coordinate system assigned to the polyline feature. So, if the coordinate system uses feet, then the tool uses feet. If it uses feet and you want to use meters, then you need to do the conversion ahead of time.

      So, if you have a 15,000 ft line with a coordinate system that uses feet and you want to place a point at 3 km, then you need to set the distance to 9,842.52 ft which is equal to 3 km.

      If it’s not working correctly, then the first thing to check is the coordinate system. Geographic coordinate systems like WGS84 will not work correctly.

  16. Hey Ian,
    This is an awesome tool. Is there a way to make it work with M values? The M values hold the actual distance for a line that is dealing in xyz and I need to add points down the line that don’t match how far away the spot is from the starting location. Any advice you have would be greatly appreciated.

    Thanks,
    Ben

  17. I love this tool and use it often. Is there any way to modify it so that if I have a field associated with the line (for example, an additional identifying number), it can be transferred/maintained for the points? So, if each line had a TreeID, the output point file would have the usual (FID, Shpae, LineOID, Value) and the TreeID (would be same for all points associated with each original line). Thanks!

    1. Hi, TMoon. Thanks for the comment, and I’m glad the tool is working for you. As far as pulling in the attributes of an additional field, I’ve had this request before and put something together. I’ll send you an email.

  18. Hello Ian,
    First thanks for the really great Toolbox it helped me Big Time!!

    I would have two questions.
    First: Would it be possible to implement a field selector so that the user could define by himself which Field values to use as LineOID? (similar to Gwens answer, or possibly share the code with me,too ) )
    So for example if my line data has an unique identifier in the field “ID” that those values are written to the points (and not the OID values).
    Perhaps an implementation similar to the “Use Field to Set value” dialogue would be possible. If the user wants to define it by himself he can if not the code stays as it is, perhaps even make the option to get both.
    Second: Is there any chance that your tool will be available for QGIS? Im sure the community would greatly appreciate that.

    Again thanks for the great work! By the way its fascinating how “simple” it looks (but surely is not).

    1. Hi Mario, glad it helped you!

      I plan on adding this functionality to the current toolbox, but I haven’t had a chance. I do have an older version that is able to do this, but it doesn’t have all the current features. I will send it to you via email. I don’t have any plans for creating the tool in QGIS, but maybe in the future. I’m sure someone else could, or maybe already has.

      Thanks for the comment!

  19. Hi Ian,
    I’ve been trying to use the tool to create points based on a field, but all of my points are being created at the beginning of the line instead of at the distance specified in the attribute field. I’ve tried specifying a distance instead of using a field, and I still get the same problem with the point being made at the beginning of the line despite the value that was input. The output shows the value that should have been used, so I guess it’s being input correctly, but the actual point creation isn’t at the right location. Do you have any ideas what might be going wrong?

    1. I figured out the answer to my own problem, but thought I’d post it in case someone else has the same issue – I needed to project the coordinate system for the polyline layer I was trying to base the point off of in order to get this to work.
      Thanks Ian, for posting this tool – it’s been really helpful 🙂

      1. Hi Abs, I just saw your comments. Glad you figured it out, and are finding the tool useful. The data needs to be in a projected coordinate system. A geographic coordinate system, such as WGS84 will not work correctly. Thanks for the comments!

      2. Hello Abs, I am facing the same issue. Could you please tell me the exact method you used and the coordinate system that helped you solve the problem.

        For my case I am getting all my points at the end points of the line but I want them to be 100 meters after the end points on the line.

        Thanks in advance

  20. HI Ian, I don’t want to be unthankful, but why can’t I preserve ALL of my attributes from the lines, rather than just being able to choose one? :/
    Best wishes
    🙂

    1. Hi Berrit, thanks for the comment! That’s actually a very good question, and I don’t have a good answer. I thought it through and I have a good way to do what you’re asking. When I get a chance, I’ll add this capability.

  21. Thanks for the tool – I’m using it to show defect points along a pipe that has CCTV.

    I have the same question as above – it would be really great to preserve ALL of the attributes from the line rather than the one (and possibly select one of those fields to become the ID field??).

      1. Thanks so much. This tool has helped me to create an app that provides flexibility previously unseen in regards to looking at asset details. The engineers and asset managers are loving it.

  22. Hi Ian,
    Thanks for making this tool! I always had to convince my employers to install ET Geowizards – now I can skip this step!

    One question. I see you recently added functionality to maintain all input attributes. When I just ran the tool on a polyline called “width_measurement_lines”, I see that all the attributes were maintained, but the attribute names were lost and converted to “width_me_1”, “width_me_2″… etc. Is this a bug that’s easy to fix? I’m using ArcMap 10.1 with a basic license (you posted in stackexchange that it only worked with ArcInfo, but that’s not the case, luckily!).

  23. Ian, this is a super helpful tool!

    Question: Is there a way it can be modified and used to add a points along a line where the line intersects each ring of a Multi Ring Buffer?

  24. Thanks for the tool! Ran into issues with Decimal symbol. My regional settings are set to comma instead of point so when I run the tool I have to change the symbol under Windows settings but otherwise it runs perfectly.

  25. Dear Ian

    Thanks for your great contribution to the improvement of the ARCMAP tools, this tool is exactly what I was looking for but unfortunately it didn’t run for me; this was the error message:

    ******************************************************************************************************************************************
    Executing: CreatePointsLines 1 “INTERVAL BY DISTANCE” BEGINNING NO # 50 NO C:\Users\Administrator\Documents\ArcGIS\Default.gdb\c1_CreatePointsLines
    Start Time: Sat Oct 15 23:47:44 2016
    Running script CreatePointsLines…

    Traceback (most recent call last):
    File “C:\Users\osukkar\Documents\ArcGIS\CreatePointsLines.tbx#CreatePointsLines_CreatePointsLines.py”, line 28, in
    File “c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\management.py”, line 1698, in CreateFeatureclass
    raise e
    ExecuteError: ERROR 000622: Failed to execute (Create Feature Class). Parameters are not valid.
    ERROR 000628: Cannot set input into parameter spatial_reference.

    Failed to execute (CreatePointsLines).
    Failed at Sat Oct 15 23:47:44 2016 (Elapsed Time: 0.00 seconds)
    ********************************************************************************************************************************************

    Please help me to fix this error

    Best Regards

    Omer F. Y. Sukkar

  26. Hi Ian, I have tried to run your tool but I face the same problem as mentioned by Omer on October 15, 2016. I see you have asked him for some more details. Have you found out about that specific problem. I’m running ArcGIS 10.3.1 and Python 2.7.

    Appreciate your feedback, Michel

  27. Hi,lan.Thanks for your tools.Im seeing some error
    Executing: CreatePointsLines 1 “INTERVAL BY DISTANCE” BEGINNING NO # 50 NO C:\Users\Administrator\Documents\ArcGIS\Default.gdb\c1_CreatePointsLines
    Start Time: Sat Oct 15 23:47:44 2016
    Running script CreatePointsLines…

    Traceback (most recent call last):
    File “C:\Users\osukkar\Documents\ArcGIS\CreatePointsLines.tbx#CreatePointsLines_CreatePointsLines.py”, line 28, in
    File “c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\management.py”, line 1752, in CreateFeatureclass
    raise e
    ExecuteError: ERROR 000622: Failed to execute (Create Feature Class). Parameters are not valid.
    ERROR 000628: Cannot set input into parameter spatial_reference.

    Failed to execute (CreatePointsLines).
    Failed at Sat Oct 15 23:47:44 2016 (Elapsed Time: 0.00 seconds)
    ________________________________________________________________
    can you help me for this question?

  28. Thaaankk you so much ian. I have followed your website for a long time. This tool will be used in my project instead of using cursor and selecting way layer for every object and running generate point tools….
    Thank you so much again. God bless you bro

  29. File “d:\program files (x86)\arcgis\desktop10.3\ArcToolbox\Toolboxes\CreatePointsLines.tbx”, line 65, in CreatePointsLines
    +1aLb+NfG1qbm0uBDdaFpU0pMarnzBdSIDhi3yFFPAGSQSV2/adeLleFxmFjUWMr+0bk2tLWXb/g
    ExecuteError:
    Traceback (most recent call last):
    File “d:\program files (x86)\arcgis\desktop10.3\ArcToolbox\Toolboxes\CreatePointsLines.tbx#CreatePointsLines_CreatePointsLines.py”, line 137, in
    File “D:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy\arcpy\management.py”, line 2434, in CopyFeatures
    raise e
    ExecuteError: ERROR 000210: Cannot create output E:\ARCMAP\LAKSHMI\Data_script\test.gdb\temp5.shp
    Failed to execute (CopyFeatures).

    Failed to execute (CreatePointsLines).

  30. If INTERVAL BY DISTANCE is chosen, points will be created along each line at the specified distance interval. For example, if 5 is entered, then points will be created every 5 feet (or whatever units the coordinate system is in).
    Hello dear I want to ask that from where I can take interval of distance in KM?
    Thanks….

  31. Hi
    I think this tool is what i’m looking for but can’t quite fit it to my use case
    My network reference uses nominal start/end field values for each segment which obviously creates a nominal rather than measured length.
    Using ESRI linear referencing it is easy to create dynamic segmentation using the two_fields parameters but I need to export the reference points. Is that possible with this tool? Am I missing something?

    Thanks

  32. Hey Ian, thank you a lot for your tool. I think I found a bug, though.
    If I ask the tool to set ‘End Points = Both’, the Start/End Points will be not set in the right order in the attribute table. So the created point-feature layer starts on the start-vertice of the polyline, then the 2nd feature is at the end vertice of the polyline. Then it proceeds normally. This is of course a problem in further processing. I tried to fix it, but could`nt find a good way, because I don`t understand the arcpy modules well. Any recommendations?

  33. Hi Ian,
    Is there a way to input multiple distances, so that I would generate a point at for example, 5m, 7.5, 9.2m and 10.1m, without having to run the tool every time for each distance needed?

  34. Hi, awesome tool, really helpful. Just one quick question, is there, by any chance, the possibility to add the new, created points in a pre-existent point layer? When I try this the tool erases the previous data. Thanks anyways

  35. Hi Ian,
    I have just loaded your toolbox and I’m trying to use it but the dialog box comes out with a white cross on a red circle besides the “Input Polyline Feature Class” selection box. I can still fill in all the fields but when pressing OK a warning with no text appears and the tool does not run… any idea why this is happening and how to fix it?
    Many thanks,
    Jorge

  36. Hi, this is absolutely amazing!!! I looked around and have not been able to find something where you can pull a distance attribute from the line shapefile to have an individual point spacing for every line. You have saved me a huge amount of work with this!

  37. Hi there,
    Uhh… may seem stupid, but How could (this tool) be installed?

    (Actually, I want to create milepost landmarks along the roads, I am searching a tool that permits me to choose a number of miles as the Start point, as the roads are made from segments. I mean: as the second segment starts at 2.44 miles, I want a landmark at 3 miles, and so on… Is this tool of any use for that?)

    Thank you,
    Cris

  38. I downloaded the tool and imported it in arcgis but everytime I attempt to use it, enter file and parameters, after clicking OK it just closes the tool and does nothing else, then my arghis session becomes frozen, forcing me to close arcgis through the task administrator. Any clue what might be going wrong?

  39. HI, help. Create Left and Right points – function if used with “BOTH” option will create two point per polyline one on the left and one on the right side of the polyline, at a relative distance from the start of the polyline (0 to 1) and with a user defined offset from the polyline on the side selected by the user. The points will carry the attributes of the corresponding polylines. Thanks anyways

  40. Thank you Ian for making and providing this tool. Thank you for a tool that is well thought through, with all the needed options such as adding points at the start / end, and taking distance from either the line beginning or line end. I have applied it for effecting the likelihood of animals finding a gap in a (highway) fence. My “continuous” fences were broken into features, but a Dissolve + MultipartToSinglepart resolved that.

Leave a Reply