In this how-to guide, we see how a polyline can be tweaked by adjusting specific points. If you need to rebuild or smooth a polyline based on a general characteristic, take a look the how-to Lines and polylines.
Find a specific vertex in a polyline
We can use different methods to find specific vertices in a polyline. In this
example, we use a location based search, in which we have an existing point and
find the vertex closest to it: After deconstructing the polyline, we find the
Closest Point
Closest Point (CP)
Inputs Point (P) Point to search from Cloud (C) Cloud of points to search Outputs Closest Point (P) Point in [C] closest to [P] CP Index (i) Index of closest point Distance (D) Distance between [P] and [C](i)
List Item (Item)
Inputs List (L) Base list Index (i) Item index Wrap (W) Wrap index to list bounds Outputs Item (i) Item at {i'}
Remove vertices from a polyline
To remove a vertex from a polyline, we can deconstruct it with either Discontinuity
Discontinuity (Disc)
Inputs Curve (C) Curve to analyze Level (L) Level of discontinuity to test for (1=C1, 2=C2, 3=Cinfinite) Outputs Points (P) Points at discontinuities Parameters (t) Curve parameters at discontinuities
Explode (Explode)
Inputs Curve (C) Curve to explode Recursive (R) Recursive decomposition until all segments are atomic Outputs Segments (S) Exploded segments that make up the base curve Vertices (V) Vertices of the exploded segments
Cull Index (Cull i)
Inputs List (L) List to cull Indices (I) Culling indices Wrap (W) Wrap indices to list range Outputs List (L) Culled list
PolyLine (PLine)
Inputs Vertices (V) Polyline vertex points Closed (C) Close polyline Outputs Polyline (Pl) Resulting polyline
Add vertices to a polyline
To add a vertex to a polyline, we deconstruct it first and create a list with
the new and existing vertices. Then, Sort Along Curve
Sort Along Curve (AlongCrv)
Inputs Points (P) Points to sort Curve (C) Curve to sort along Outputs Points (P) Sorted points Indices (I) Point index map
PolyLine (PLine)
Inputs Vertices (V) Polyline vertex points Closed (C) Close polyline Outputs Polyline (Pl) Resulting polyline
Another possibility, to add new vertices, is using the curve parameters of the existing polyline.
Note that this approach is only possible, when the new vertices are on the
existing polyline. Discontinuity
Discontinuity (Disc)
Inputs Curve (C) Curve to analyze Level (L) Level of discontinuity to test for (1=C1, 2=C2, 3=Cinfinite) Outputs Points (P) Points at discontinuities Parameters (t) Curve parameters at discontinuities
Sort List (Sort)
Inputs Keys (K) List of sortable keys Values A (A) Optional list of values to sort synchronously Outputs Keys (K) Sorted keys Values A (A) Synchronous values in A
Evaluate Curve (Eval)
Inputs Curve (C) Curve to evaluate Parameter (t) Parameter on curve domain to evaluate Outputs Point (P) Point on the curve at {t} Tangent (T) Tangent vector at {t} Angle (A) Angle (in Radians) of incoming vs. outgoing curve at {t}
PolyLine (PLine)
Inputs Vertices (V) Polyline vertex points Closed (C) Close polyline Outputs Polyline (Pl) Resulting polyline
Replace vertices in a polyline
To replace a vertex, we deconstruct the polyline and use Replace Items
Replace Items (Replace)
Inputs List (L) List to modify Item (I) Items to replace with. If no items are supplied, nulls will be inserted. Indices (i) Replacement index for each item Wrap (W) If true, indices will be wrapped Outputs List (L) List with replaced values
PolyLine (PLine)
Inputs Vertices (V) Polyline vertex points Closed (C) Close polyline Outputs Polyline (Pl) Resulting polyline
For advanced, yet specific, modifications, we can also make use of the full set of methods that are described in the how-to Filter lists.