# Split line - equal interval

3605
3
11-29-2012 12:44 PM
MVP Honored Contributor
I'm looking for the easiest way to split multiple lines by an equal distance. Everything I've found online seems to involve an incredibly convoluted hack. This seems like a basic requirement, so I won't be surprised if I'm missing something obvious.

I've got 4000km of line that I want to split into 10m lengths (I don't really care about the last remainder). There are thousands of lines, so please don't suggest doing this one by one. Right now, I'm splitting the 4000km of line by intersecting it with a 7m x 7m grid (~10m diagonally), which guarantees all of my segments are at least less than 10m long. It works, but clearly it's overkill. If you have a clean method of splitting my lines, please let me know.
Tags (3)
1 Solution

Accepted Solutions
by
Esri Regular Contributor
Darren,

Have you tried densifying the line with a vertice every 10m, then run Split Line At Vertices?

Best,
Eric
3 Replies
by
Esri Regular Contributor
Darren,

Have you tried densifying the line with a vertice every 10m, then run Split Line At Vertices?

Best,
Eric
MVP Honored Contributor
Thanks - works great.
Occasional Contributor

I ran across a need to do this and wrote a script. It only transfers the shape field but could be edited to transfer whatever attributes you want. Set the interval variable to however long you want the output lines to be. Note that there will be a fraction at the end of each line that is less than the interval distance.

## splitLinesAtIntervals.py

## inputs ##
interval = 50 ## units of inFC projection
inFC = r'path\to\inFeatureClass'
outFC = r'path\to\outFeatureClass'

## get to work
import arcpy
arcpy.env.overwriteOutput = True

iCur = arcpy.da.InsertCursor(outFC, ['SHAPE@'])

with arcpy.da.SearchCursor(inFC, ['SHAPE@']) as sCur:
for row in sCur:
lineLength = row[0].length
position = 0
lineGeometry = row[0]
## while length left??
while lineLength > position:
## position point along line at interval
splitPoint = lineGeometry.positionAlongLine(interval)
## split line at point
arcpy.SplitLineAtPoint_management(lineGeometry, splitPoint, 'in_memory/split')
## insert the split line into outFC
with arcpy.da.SearchCursor('in_memory/split', ['OID@', 'SHAPE@']) as splitCur:
for i in splitCur:
if i[0] == 1:
## insert row
iCur.insertRow([i[1]])
else:
lineGeometry = i[1]
position += interval

del iCur‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍