ArcGIS Toolbox – Shorten Polylines by Percentage or Distance with ArcPy

Share Button

Updated – 4/10/2015
Can now shorten the polylines from both sides, this keeps the middle part of the polyline

Previous Updates
Fixed compatibility with Python 3 for ArcGIS Pro
Output polylines now retain original vertices, whereas before the features were simplified into straight lines

(If you’re using Firefox, then right click and Save Link As)
Download the Shorten Polylines Toolbox – works with ArcGIS 10.2+
View the Source Code

(any donations go towards hosting costs)

Only use the following download if you have ArcGIS 10.1 or earlier. This version will not retain the original line shape.
Download the Shorten Polylines Toolbox
View the Source Code

The Shorten Polylines tool takes an input Polyline feature class and shortens each polyline feature based on a specified distance or percentage value. The value can either be fixed or field based.

You can now shorten the lines based on either the beginning, end, or both sides as shown in the screenshot below. If BOTH is chosen, then the middle portion of the polyline is kept. Also, if BOTH is chosen the distance or percentage value is divided by two.

The output Polyline feature class containing the shortened polylines will have a field called LineOID which states the OID of the original polyline it was created from. This allows any attribute information to be joined back to the new polylines. It will also contain a field called Value, which states the value that was used to create the line.

If a field is being used to assign the value, any features with null values will be skipped. If the polylines are being shortened using a PERCENTAGE, the value must be in decimal format and between 0 and 1.0. All features with values outside this range will be skipped. If the polylines are being shortened using a DISTANCE, the value must be positive. All features with negative numbers will be skipped.

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:

Shorten Polylines 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!

11 thoughts on “ArcGIS Toolbox – Shorten Polylines by Percentage or Distance with ArcPy

  1. shaohu zhang
    June 23, 2014 at 3:57 pm

    Hi, I am trying using this toolbox. Can you tell me how to use this toolbox in arcgis?

    1. Ian
      June 23, 2014 at 9:54 pm

      Hi Shaohu, what exactly are you having problems with? Adding it to ArcMap? If so, you need to right click in the whitespace of ArcToolbox and go to Add Toolbox and then add the toolbox you downloaded from this page. Here is a video for a different set of tools, but it will show you how to add them:

      Let me know if this didn’t answer your question.

  2. Steve Lewis
    November 21, 2014 at 6:22 pm

    Great toolbox.
    I have polylines, each with several vertexes and twists and turns. I need to shorten those lines by a percentage while leaving the rest of the complexity of the line. This tool currently simplifies the line into a straight line.

    1. Ian
      November 22, 2014 at 3:31 pm

      Hi Steve, thanks! I can understand why you’d want to keep the original complexity of the line instead of just simplifying the feature into a straight line. I made a few modifications to the script, and it now does what you’re asking. However, the toolbox now requires 10.2+ because of ArcPy capabilities not present in lesser versions. I’ve changed the script and download links above. Thanks for the suggestion!

  3. Amber
    December 5, 2014 at 8:27 am

    Hi Ian,

    Thank you for putting together this tool! Is there any way you can post the old source code for 10.1? I don’t have 10.2.

    1. Ian
      December 8, 2014 at 8:22 pm

      Hi Amber, I’ve sent you an email.

  4. Theresa
    February 26, 2015 at 1:00 pm

    Hi Ian,
    I also don’t have version 10.2, I have 10.1. Could you please send me your script also?

    1. Ian
      February 27, 2015 at 5:18 pm

      Hi Theresa, I’ve added the ArcGIS 10.1 or earlier download to the top of this page. This version is really only good for perfectly straight lines, as it does not retain the shape of any vertices besides the first and last.

  5. Sam
    April 8, 2015 at 3:35 am

    Hi Ian,

    This tool is great, exactly what I was after. Would I be possible for the new polyline to be shortened from both ends?

    Currently I am using a percentage, but the reduction only happens on one end of the line. Ideally I want the reduction to happen across both ends.


    1. Ian
      April 10, 2015 at 8:58 pm

      Hi Sam, thanks for the comment! I’ve now added this functionality. You can now shorten the polylines from the beginning, end, or both. If you choose both, it shortens both ends and keeps the middle part of the polyline. Hope this works for you.

  6. Char
    March 22, 2016 at 9:56 am

    Hey Sam,

    I was wondering how you could use this tool in an Arcpy script. I am receiving the error:
    AttributeError: ‘module’ object has no attribute ‘ShortenPolylines_ShortenPolylines’


Leave a Reply

Your email address will not be published.