GeodeticDensifyByLength Method (GeometryEngine)
Creates geodetic segments connecting existing vertices and densifies the segments.
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. If the input geometry is empty, then it is returned unchanged.
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;
Target Platforms: Windows 11, Windows 10
ArcGIS Pro version: 3 or higher.