Monday, 26 October 2015

arcgis 10.0 - Creating multiple parallel lines using ArcPy?



I'm using the following code to create multiple parallel lines


import arcpy, math

offset = 3
offset_original = offset
features=[]

arcpy.env.overwriteOutput = True

infc="Export_Output_4_SmoothLine"
talhao = "Export_Output_5"

spatialRef = arcpy.Describe(infc).spatialReference

def CopyParallel(plyP,sLength):
part=plyP.getPart(0)
lArray=arcpy.Array();rArray=arcpy.Array()

for ptX in part:
dL=plyP.measureOnLine(ptX)
ptX0=plyP.positionAlongLine (dL-0.01).firstPoint
ptX1=plyP.positionAlongLine (dL+0.01).firstPoint
dX=float(ptX1.X)-float(ptX0.X)
dY=float(ptX1.Y)-float(ptX0.Y)
lenV=math.hypot(dX,dY)
sX=(-dY*sLength/lenV);sY=dX*sLength/lenV
leftP=arcpy.Point(ptX.X+sX,ptX.Y+sY)
lArray.add(leftP)

rightP=arcpy.Point(ptX.X-sX, ptX.Y-sY)
rArray.add(rightP)
array = arcpy.Array([rArray, lArray])
section=arcpy.Polyline(array, spatialRef)
return section


with arcpy.da.UpdateCursor(infc,["SHAPE@"]) as cursor:
for shp in cursor:
i=0

while i <= 100:
print str(i)
if (i > 0):
offset = offset + offset_original
twoLines=CopyParallel(shp[0],offset)
temp=twoLines
features.append(twoLines)
i=i+1

arcpy.CopyFeatures_management(features, "test")


It happens that after a while he starts to create lines in this way


enter image description here


How do I get these intersections or not create them in the script?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...