ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Core.Geometry Namespace / GeometryEngine Class / SimplifyPolyline Method
The polyline to simplify.
The type of simplify to perform.
(Optional) The default value is false. When true, it forces the simplification code to be applied to the geometry even if the geometry comes from a trusted source or has already been simplified. When false, the method will do nothing if called on the same geometry a second time.
Example

In This Topic
    SimplifyPolyline Method (GeometryEngine)
    In This Topic
    Use either planar, nonplanar, or network simplify regardless of polyline M-awareness.
    Syntax
    Public Function SimplifyPolyline( _
       ByVal polyline As Polyline, _
       ByVal simplifyType As SimplifyType, _
       ByVal forceSimplify As Boolean _
    ) As Polyline

    Parameters

    polyline
    The polyline to simplify.
    simplifyType
    The type of simplify to perform.
    forceSimplify
    (Optional) The default value is false. When true, it forces the simplification code to be applied to the geometry even if the geometry comes from a trusted source or has already been simplified. When false, the method will do nothing if called on the same geometry a second time.

    Return Value

    The simplified polyline.
    Exceptions
    ExceptionDescription
    Polyline is null or empty.
    Remarks
    Supported simplifyType are:
    1. Network: Removes zero length segments (zero in 2 dimensions), merges parts at endpoints that only connect to each other, reorients segments that are pointing against the prevailing orientation for a part. Creates new parts for discontiguous segments or segments with different attributes. For a pair of segments in a part that share an endpoint such that one segment has NaN attributes and the other has non-NaN attributes, assign the non-NaN attributes of one to the corresponding NaN slots of the other. Equivalent to IPolyine SimplifyNetwork
    2. Planar: Force planar simplification on to a polyline that is M-Aware. If a polyline is m-aware, planar simplification will not attempt to detect self-intersections, overlaps, etc. Equivalent to IPolyline4 SimplifyEx(planarSimplify=true)
    3. Nonplanar: Removes zero length segments (zero in 2 dimensions), reorients segments that are pointing against the prevailing orientation for a part. Creates new parts for noncontiguous segments or segments with different attributes. For a pair of segments in a part that share an endpoint such that one segment has NaN attributes and the other has non-NaN attributes, assign the non-NaN attributes of one to the corresponding NaN slots of the other. This method is the similar to Network, except parts are not merged where an end point is shared. Equivalent to IPolyline6 SimplifyNonPlanar.
    Example
    Simplify a polyline with intersections, overlaps
    List<Coordinate2D> coords = new List<Coordinate2D>()
    {
      new Coordinate2D(8, 0),
      new Coordinate2D(8, 4),
      new Coordinate2D(6, 4),
      new Coordinate2D(8, 4),
      new Coordinate2D(10, 4),
      new Coordinate2D(8, 4)
    };
    
    SpatialReference sr = SpatialReferences.WGS84;
    
    // build a line that has segments that cross over each other
    Polyline polyline = PolylineBuilderEx.CreatePolyline(coords, sr);
    // polyline.PartCount = 1
    ReadOnlyPartCollection parts = polyline.Parts;
    ReadOnlySegmentCollection segments = parts[0];
    // segments.Count = 5
    
    //  note there is a difference between SimpleAsFeature (doesn't detect intersections and overlaps, determines if it's simple enough for gdb storage)
    //  and SimplifyPolyline  (does detect intersections etc)
    bool isSimple = GeometryEngine.Instance.IsSimpleAsFeature(polyline, false);
    // isSimple = true
    
    // simplify it (with force = false)
    // because it has already been deemed 'simple' (previous IsSimpleAsFeature call) no detection of intersections, overlaps occur
    Polyline simplePolyline = GeometryEngine.Instance.SimplifyPolyline(polyline, SimplifyType.Planar, false);
    // simplePolyline.PartCount = 1
    ReadOnlyPartCollection simpleParts = simplePolyline.Parts;
    ReadOnlySegmentCollection simpleSegments = simpleParts[0];
    // simpleSegments.Count = 5
    
    // simplify it (with force = true)
    // detection of intersections, overlaps occur 
    simplePolyline = GeometryEngine.Instance.SimplifyPolyline(polyline, SimplifyType.Planar, true);
    // simplePolyline.PartCount = 3
    simpleParts = simplePolyline.Parts;
    simpleSegments = simpleParts[0];
    // simpleSegments.Count = 1
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also