1

I have a polyline feature class and I need some segments to be generalized. I tried exactly Generalize tool in Advanced Editor toolbar as well as Simplify Line tool, but it isn't what I need.

enter image description here

My goal is to make round segments of rectangular shape, see an example. I need to transform the initial thin line into almost the same but instead of round segments (they're not curves) want to have angles like thick red ones in a picture. Tried to build a script using lengths of distances between vectors from beginning of line with help of arcpy.da.SearchCursor() and arcpy.positionAlongLine(), but nothing useful came to my mind. Any thoughts?

3

2 Answers 2

2

Solution below assumes that you split your line. It is much bigger beast if you'd like to find split points first.

Select segment to modify and run this:

"""
knee maker
"""
import arcpy
import numpy as np
infc="SEGMENTS"
g = arcpy.Geometry()
segment = arcpy.CopyFeatures_management(infc, g)[0]
##  FIND TANGENT AT START
pStart = segment.firstPoint
X1,Y1 = pStart.X,pStart.Y
pMid = segment.positionAlongLine (0.01).firstPoint
XM,YM = pMid.X,pMid.Y
aStart,bStart=np.polyfit([X1,XM],[Y1,YM],1)
##  FIND TANGENT AT THE END
pEnd = segment.lastPoint
X1,Y1 = pEnd.X,pEnd.Y
pMid = segment.positionAlongLine (segment.length-0.01).firstPoint
XM,YM = pMid.X,pMid.Y
aEnd,bEnd=np.polyfit([X1,XM],[Y1,YM],1)
##  FIND INTERSECTION. QUIT IF TANGENTS ARE PARALLEL
if aStart==aEnd:exit()
x,y = np.polyfit([aStart,aEnd],[-bStart,-bEnd],1)
pMid=arcpy.Point(x,-y)
pLine=arcpy.Polyline(arcpy.Array([pStart,pMid,pEnd]))
##  REDRAW LINE
with arcpy.da.UpdateCursor(infc,"Shape@") as cursor:
    for row in cursor:
        row[0]=pLine
        cursor.updateRow(row)
arcpy.RefreshActiveView()

enter image description here

I used filet tool to draw curve connecting 2 straight lines. As expected mid point of modified segment sits slightly below "theoretical" intersection point. So split original somewhere on a straight parts.

2
  • exactly what I thought about! However, the next step is to detect these kinds of round-shaped chunks n a polyline. Aug 24, 2018 at 6:45
  • Post a challenge.
    – FelixIP
    Aug 24, 2018 at 8:40
0

I would think either Generalize or Densify might do the trick.

http://desktop.arcgis.com/en/arcmap/latest/tools/editing-toolbox/densify.htm http://desktop.arcgis.com/en/arcmap/latest/tools/editing-toolbox/generalize.htm

If you're having issues with Generalize, I'd personally set a low offset value to minimize the change to your line.

Densify might give you a little more control, because you can specify a maximum offset, maximum angle, or maximum distance

Also, don't be afraid to run it through the tool more than once to see if you get a better result from a couple of passes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.