densifyOperator

AMD: require(["esri/geometry/operators/densifyOperator"], (densifyOperator) => { /* code goes here */ });
ESM: import * as densifyOperator from "@arcgis/core/geometry/operators/densifyOperator.js";
Object: esri/geometry/operators/densifyOperator
Since: ArcGIS Maps SDK for JavaScript 4.31

Densifies 2D geometries by length, deviation and/or angle in a 2D plane. The result geometry contains segments less than or equal to maxSegementLength, and it will not contain curves. The piecewise approximation of curves will be within the specified deviation from the original curve, and the angle between tangent segments does not exceed the specified value.

If maxAngleInDegrees is not zero, vertices are added at points along the curve where the angle between tangent segments reaches this value. These vertices are then connected by straight-line segments.

If maxSegmentLength is zero, only curves are affected and other geometries remain unchanged. The process always starts from the highest point on a segment, so equal segments will be densified in the same way.

When the maxSegmentLength, maxDeviation, and maxAngleInDegrees parameters are all set to 0, curves are replaced with the line segments connecting the curve endpoints.

Suggestion: to limit the number of segments that are produced, if you have an area of interest such as a visible extent, clip the input geometries before densifying.

Densify operator

Property Overview

Name Type Summary Object

Indicates if the operator supports input geometries that contain curves.

densifyOperator

Property Details

supportsCurves

Property
supportsCurves Booleanreadonly

Indicates if the operator supports input geometries that contain curves. This will produce densified output geometries.

Default Value:true

Method Overview

Name Return Type Summary Object

Performs the densify operation on the geometry.

densifyOperator

Performs the Densify operation on the geometry set.

densifyOperator

Method Details

execute

Method
execute(geometry, maxSegmentLength, options){GeometryUnion}

Performs the densify operation on the geometry.

Parameters
Specification
geometry GeometryUnion

The geometry to be densified.

maxSegmentLength Number

The maximum distance between vertices when the input geometry is densified. The number must be greater than or equal to zero.

When the parameter is set to 0, this operation only applies to curves and disables densification by length. Curves are densified to straight segments using the given length. And, curves are split into shorter subcurves such that the length of subcurves is shorter than maxSegmentLength. After that the curves are replaced with straight segments. Unless the unit option is set, the default is the spatial reference unit of geometry.

options Object
optional

Additional options.

Specification
maxAngleInDegrees Number
optional
Default Value: 0

The maximum angle that a new vertex can deviate from the original geometry. The number must be greater than or equal to zero. Applicable only on curves. The default value of 0 disables densification by angle. The value will be capped at 90.

maxDeviation Number
optional
Default Value: 0

The maximum distance a newly placed vertex on a densified polyline can deviate from the original location on the curve. The number must be greater than or equal to zero. Applicable only on curves. The default of passing 0 disables densification by deviation. Unless the unit option is set, the default is the geometry's spatial reference unit.

unit LengthUnit
optional

The length unit of maxSegmentLength and maxDeviation. An error will be thrown if this is set for Geographic Coordinate Systems.

Returns
Type Description
GeometryUnion Returns the densified geometry that does not contain any curves.
Examples
// Returns a densified poyline.
const densified = densifyOperator.execute(polyline, 100);
// Returns a polyline where all curve segments have been densified.
if (polyline.curvePaths) {
  const densified = densifyOperator.execute(polyline, 0, { maxAngleInDegrees: 1 });
}

executeMany

Method
executeMany(geometries, maxSegmentLength, options){GeometryUnion[]}

Performs the Densify operation on the geometry set.

Parameters
Specification
geometries GeometryUnion[]

The set of geometries to be densified. All the geometries must have the same spatial reference.

maxSegmentLength Number

The maximum segment length allowed. The number must be greater than or equal to zero.

When the parameter is set to 0, this operation only applies to curves and disables densification by length. Curves are densinfied to straight segments using the given length. And, curves are split into shorter subcurves such that the length of subcurves is shorter than maxSegmentLength. After that the curves are replaced with straight segments. Unless the unit option is set, the default is the geometries spatial reference unit.

options Object
optional

Additional options.

Specification
maxAngleInDegrees Number
optional
Default Value: 0

The maximum angle allowed. The number must be greater than or equal to zero. Applicable only on curves. The default of passing 0 disables densification by angle. The value will be capped at pi/2.

maxDeviation Number
optional
Default Value: 0

The maximum deviation allowed. The number must be greater than or equal to zero. Applicable only on curves. The default of passing 0 disables densification by deviation.

unit LengthUnit
optional

The length unit of maxSegmentLength and maxDeviation. An error will be thrown if this is set for Geographic Coordinate Systems.

Returns
Type Description
GeometryUnion[] Returns the densified geometries that do not contain any curves.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.