ArcGIS Pro 3.1 API Reference Guide
ArcGIS.Core.Geometry Namespace / GeometryEngine Class / GeodeticDensifyByLength Method
The geometry to be densified. Cannot be null and its spatial reference cannot be null.
The maximum segment length allowed. If maxSegmentLength is less than or equal to zero, the value of 50 km is used.
The linear unit of maxSegmentLength.
The type of curve that connects the vertices of the densified geometry.
Example

In This Topic
    GeodeticDensifyByLength Method (GeometryEngine)
    In This Topic
    Creates geodetic segments connecting existing vertices and densifies the segments.
    Syntax
    Public Function GeodeticDensifyByLength( _
       ByVal geometry As Geometry, _
       ByVal maxSegmentLength As Double, _
       ByVal lengthUnit As LinearUnit, _
       ByVal curveType As GeodeticCurveType _
    ) As Geometry

    Parameters

    geometry
    The geometry to be densified. Cannot be null and its spatial reference cannot be null.
    maxSegmentLength
    The maximum segment length allowed. If maxSegmentLength is less than or equal to zero, the value of 50 km is used.
    lengthUnit
    The linear unit of maxSegmentLength.
    curveType
    The type of curve that connects the vertices of the densified geometry.

    Return Value

    The densified geometry.
    Exceptions
    ExceptionDescription
    Geometry is null or empty. Or geometry's spatial reference is null.
    The method is not implemented for GeometryBag or Multipatch.
    The geomtry is of an incorrect type. (i.e. a point or multipoint).
    Geometry does not have a spatial reference.
    Spatial reference of geometryis an image coordinate system.
    Remarks
    The image below shows the results of applying the GeodeticDensify method to a polyline with curveType = Geodesic. The densified polyline represents a flight path between stops in Honolulu and Los Angeles. The original polyline is modified by adding additional segments that identify the shortest ground distance between these locations.

    GeometryEngine Geodesic Densify

    Example
    GeodeticDensifyByLength - polygon
    List<Coordinate2D> coords = new List<Coordinate2D>()
    {
      new Coordinate2D(-80, 0),
      new Coordinate2D(-20, 60),
      new Coordinate2D(40, 20),
      new Coordinate2D(0, -20),
      new Coordinate2D(-80, 0)
    };
    
    SpatialReference sr = SpatialReferences.WGS84;
    
    // create a polygon
    Polygon polygon = PolygonBuilderEx.CreatePolygon(coords, sr);
    
    // get the geodesic lengths of the polygon segments
    ReadOnlySegmentCollection segments = polygon.Parts[0];
    List<Double> geoLengths = new List<Double>(segments.Count);
    foreach (Segment s in segments)
    {
      Polyline line = PolylineBuilderEx.CreatePolyline(s, sr);
      double geoLen = GeometryEngine.Instance.GeodesicLength(line);
      geoLengths.Add(geoLen);
    }
    
    // find the max length
    geoLengths.Sort();
    double maxLen = geoLengths[geoLengths.Count - 1];
    
    // densify the polygon (in meters)
    Polygon densifiedPoly = GeometryEngine.Instance.GeodeticDensifyByLength(polygon, maxLen, LinearUnit.Meters, GeodeticCurveType.Geodesic) as Polygon;
    
    // densify the polygon (in km)
    double maxSegmentLength = maxLen / 10000;
    densifiedPoly = GeometryEngine.Instance.GeodeticDensifyByLength(polygon, maxSegmentLength, LinearUnit.Kilometers, GeodeticCurveType.Geodesic) as Polygon;
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.0 or higher.
    See Also