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
beta

Densifies 2D geometries by length, deviation and/or angle in a 2D plane. In the result geometry, there are no segments longer than the given maxlength, and it will not contain curves. The piecewise approximation of curves is closer than the given deviation to the original curve, and the angle between tangent segments does not exceed given value.

When the maxAngleInDegrees is not zero, vertices are introduced at points on the curve where the included angle between tangents at those point is maxAngleInDegrees. The new vertices are connected with line segments.

If maxSegmentLength is zero, the operation only applies to curves and geometries that do not have curves will be passed through unchanged. The operation always starts from the highest point on segment, thus guaranteeing that geometries that equal segments are densified exactly the same.

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

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

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){Geometry}

Performs the densify operation on the geometry.

Parameters
Specification
geometry Geometry

The geometry to be densified.

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 spatial reference unit of geometry.

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. 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
Geometry Returns the densified geometry that does not contain any curves.
Example
// Returns a densified geometry
const densified = densifyOperator.execute(polyline, 100);

executeMany

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

Performs the Densify operation on the geometry set.

Parameters
Specification
geometries Geometry[]

The set of geometries to be densified.

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
Geometry[] 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.