All of my road segments have beginning milepost and ending milepost data. What's the best way to split all of my segments into .25mi pieces and repopulate the new beginning and ending milepost data?
Hi Anthony Von Moos ,
There are a couple of tools out there that will split your line using different methods inside and outside editing sessions, but I don't think it will update your bmp and emp values. See the support page on this topic:
You can script this using the segmentAlongLine function in arcpy. Below an example of the logic:
import arcpy
# set you split distance
split_dist = 2.5
# create a simple line
fpnt = arcpy.Point(0, 0)
tpnt = arcpy.Point(10.5, 0)
sr = arcpy.SpatialReference(102100)
line = arcpy.Polyline(arcpy.Array([fpnt, tpnt]), sr)
# split the line
dist = 0
endprev = 0
cnt = 0
while dist <= line.length:
cnt += 1
bmp = endprev
linep = line.segmentAlongLine(dist, dist + split_dist, False)
emp = dist + linep.length
print("line {}".format(cnt))
print(" - bmp {}".format(bmp))
print(" - emp {}".format(emp))
endprev = emp
dist += split_dist
This will print:
line 1
- bmp 0
- emp 2.5
line 2
- bmp 2.5
- emp 5.0
line 3
- bmp 5.0
- emp 7.5
line 4
- bmp 7.5
- emp 10.0
line 5
- bmp 10.0
- emp 10.5