geometryEngineAsync

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

An asynchronous client-side geometry engine for testing, measuring, and analyzing the spatial relationship between two or more 2D geometries. If more than one geometry is required for any of the methods below, all geometries must have the same spatial reference for the methods to work as expected.

Read the following blog series to learn more about GeometryEngine:

Method Overview

Name Return Type Summary Object
Promise<(Polygon|Polygon[])>

Creates planar (or Euclidean) buffer polygons at a specified distance around the input geometries.

geometryEngineAsync
Promise<Geometry>

Calculates the clipped geometry from a target geometry by an envelope.

geometryEngineAsync
Promise<Boolean>

Indicates if one geometry contains another geometry.

geometryEngineAsync
Promise<(Geometry|Geometry[])>

Calculates the convex hull of one or more geometries.

geometryEngineAsync
Promise<Boolean>

Indicates if one geometry crosses another geometry.

geometryEngineAsync
Promise<Geometry[]>

Split the input Polyline or Polygon where it crosses a cutting Polyline.

geometryEngineAsync
Promise<Geometry>

Densify geometries by plotting points between existing vertices.

geometryEngineAsync
Promise<Geometry>

Creates the difference of two geometries.

geometryEngineAsync
Promise<Boolean>

Indicates if one geometry is disjoint (doesn't intersect in any way) with another geometry.

geometryEngineAsync
Promise<Number>

Calculates the shortest planar distance between two geometries.

geometryEngineAsync
Promise<Boolean>

Indicates if two geometries are equal.

geometryEngineAsync

Returns an object containing additional information about the input spatial reference.

geometryEngineAsync
Promise<Geometry>

Flips a geometry on the horizontal axis.

geometryEngineAsync
Promise<Geometry>

Flips a geometry on the vertical axis.

geometryEngineAsync
Promise<Geometry>

Performs the generalize operation on the geometries in the cursor.

geometryEngineAsync
Promise<Number>

Calculates the area of the input geometry.

geometryEngineAsync
Promise<(Polygon|Polygon[])>

Creates geodesic buffer polygons at a specified distance around the input geometries.

geometryEngineAsync
Promise<Geometry>

Returns a geodetically densified version of the input geometry.

geometryEngineAsync
Promise<Number>

Calculates the length of the input geometry.

geometryEngineAsync
Promise<Geometry>

Creates new geometries from the intersections between two geometries.

geometryEngineAsync
Promise<Point[]>

Resolves to an array of points at the intersecting locations of two input polylines.

geometryEngineAsync
Promise<Boolean>

Indicates if one geometry intersects another geometry.

geometryEngineAsync
Promise<Boolean>

Indicates if the given geometry is topologically simple.

geometryEngineAsync

Finds the coordinate of the geometry that is closest to the specified point.

geometryEngineAsync

Finds vertex on the geometry nearest to the specified point.

geometryEngineAsync

Finds all vertices in the given distance from the specified point, sorted from the closest to the furthest and returns them as an array of Objects.

geometryEngineAsync
Promise<(Geometry|Geometry[])>

The offset operation creates a geometry that is a constant planar distance from an input polyline or polygon.

geometryEngineAsync
Promise<Boolean>

Indicates if one geometry overlaps another geometry.

geometryEngineAsync
Promise<Number>

Calculates the area of the input geometry.

geometryEngineAsync
Promise<Number>

Calculates the length of the input geometry.

geometryEngineAsync
Promise<Boolean>

Indicates if the given DE-9IM relation holds for the two geometries.

geometryEngineAsync
Promise<Geometry>

Rotates a geometry counterclockwise by the specified number of degrees.

geometryEngineAsync
Promise<Geometry>

Performs the simplify operation on the geometry, which alters the given geometries to make their definitions topologically legal with respect to their geometry type.

geometryEngineAsync
Promise<(Geometry|Geometry[])>

Creates the symmetric difference of two geometries.

geometryEngineAsync
Promise<Boolean>

Indicates if one geometry touches another geometry.

geometryEngineAsync
Promise<Geometry>

All inputs must be of the same type of geometries and share one spatial reference.

geometryEngineAsync
Promise<Boolean>

Indicates if one geometry is within another geometry.

geometryEngineAsync

Method Details

buffer

Method
buffer(geometry, distance, unit, unionResults){Promise<(Polygon|Polygon[])>}

Creates planar (or Euclidean) buffer polygons at a specified distance around the input geometries.

The GeometryEngine has two methods for buffering geometries client-side: buffer and geodesicBuffer. Use caution when deciding which method to use. As a general rule, use geodesicBuffer if the input geometries have a spatial reference of either WGS84 (wkid: 4326) or Web Mercator. Only use buffer (this method) when attempting to buffer geometries with a projected coordinate system other than Web Mercator. If you need to buffer geometries with a geographic coordinate system other than WGS84 (wkid: 4326), use geometryService.buffer().

Parameters
geometry Geometry|Geometry[]

The buffer input geometry. The geometry and distance parameters must be specified as either both arrays or both non-arrays. Never specify one as an array and the other a non-array.

distance Number|Number[]

The specified distance(s) for buffering. The geometry and distance parameters must be specified as either both arrays or both non-arrays. Never specify one as an array and the other a non-array. When using an array of geometries as input, the length of the geometry array does not have to equal the length of the distance array. For example, if you pass an array of four geometries: [g1, g2, g3, g4] and an array with one distance: [d1], all four geometries will be buffered by the single distance value. If instead you use an array of three distances: [d1, d2, d3], g1 will be buffered by d1, g2 by d2, and g3 and g4 will both be buffered by d3. The value of the geometry array will be matched one to one with those in the distance array until the final value of the distance array is reached, in which case that value will be applied to the remaining geometries.

optional

Measurement unit of the distance(s). Defaults to the units of the input geometries.

unionResults Boolean
optional
Default Value: false

Determines whether the output geometries should be unioned into a single polygon.

Returns
Type Description
Promise<(Polygon|Polygon[])> When resolved, the response is the resulting buffer(s). The result will be an array if an array of geometries is used as input. It will be a single polygon if a single geometry is input into the function.
Example
const pointBuffer = await geometryEngineAsync.buffer(point, 1000, "feet");

clip

Method
clip(geometry, envelope){Promise<Geometry>}

Calculates the clipped geometry from a target geometry by an envelope.

Parameters
geometry Geometry

The geometry to be clipped.

envelope Extent

The envelope used to clip.

Returns
Type Description
Promise<Geometry> When resolved, response is the clipped geometry.
Example
// returns a new geometry of a polygon clipped by the views extent
const clippedGeometry = await geometryEngineAsync.clip(boundaryPolygon, view.extent);

contains

Method
contains(containerGeometry, insideGeometry){Promise<Boolean>}

Indicates if one geometry contains another geometry.

Parameters
containerGeometry Geometry

The geometry that is tested for the "contains" relationship to the other geometry. Think of this geometry as the potential "container" of the insideGeometry.

insideGeometry Geometry

The geometry that is tested for the "within" relationship to the containerGeometry.

Returns
Type Description
Promise<Boolean> Response is true if the containerGeometry contains the insideGeometry.
Example
// returns true or false for one geometry containing another
const isContained = await geometryEngineAsync.contains(extent, boundaryPolygon);

convexHull

Method
convexHull(geometry, merge){Promise<(Geometry|Geometry[])>}

Calculates the convex hull of one or more geometries. A convex hull is the smallest convex polygon that encloses a group of geometries or vertices. The input can be a single geometry (such as a polyline) or an array of any geometry type. The hull is typically a polygon but can also be a polyline or a point in degenerate cases.

Parameters
geometry Geometry|Geometry[]

The input geometry or geometries used to calculate the convex hull. If an array is specified, the input array can include various geometry types. When an array is provided, the output will also be an array.

merge Boolean
optional
Default Value: false

Indicates whether to merge the output into a single geometry (usually a polygon).

Returns
Type Description
Promise<(Geometry|Geometry[])> Resolves to the convex hull of the input geometries. This is usually a polygon, but can also be a polyline (if the input is a set of points or polylines forming a straight line), or a point (in degenerate cases).
Examples
// returns the convex hull of a multipoint as a single polygon
const hull = await geometryEngineAsync.convexHull(multipoint);
// returns the convex hull of an array of points as a single polygon
const [ hull ] = await geometryEngineAsync.convexHull([ pointA, pointB, pointC ], true);
// returns the convex hull for each input line geometry as three polygons
const hulls = await geometryEngineAsync.convexHull([ lineA, lineB, lineC ]);
// returns the convex hull for all input line geometries as a single polygon
const [ hull ] = await geometryEngineAsync.convexHull([ lineA, lineB, lineC ], true);
// returns the convex hull for all input geometries as a single polygon
const [ hull ] = await geometryEngineAsync.convexHull([ point, line, polygon ], true);

crosses

Method
crosses(geometry1, geometry2){Promise<Boolean>}

Indicates if one geometry crosses another geometry.

Parameters
geometry1 Geometry

The geometry to cross.

geometry2 Geometry

The geometry being crossed.

Returns
Type Description
Promise<Boolean> Responds true if geometry1 crosses geometry2.
Example
// returns true or false if a line crosses a polygon
const isCrossed = await geometryEngineAsync.crosses(boundaryPolygon, polyline);

cut

Method
cut(geometry, cutter){Promise<Geometry[]>}

Split the input Polyline or Polygon where it crosses a cutting Polyline. For Polylines, all left cuts are grouped together in the first Geometry. Right cuts and coincident cuts are grouped in the second Geometry and each undefined cut, along with any uncut parts, are output as separate Polylines. For Polygons, all left cuts are grouped in the first Polygon, all right cuts are grouped in the second Polygon, and each undefined cut, along with any left-over parts after cutting, are output as a separate Polygon. If no cuts are returned then the array will be empty. An undefined cut will only be produced if a left cut or right cut was produced and there was a part left over after cutting, or a cut is bounded to the left and right of the cutter.

Parameters
geometry Geometry

The geometry to be cut.

cutter Polyline

The polyline to cut the geometry.

Returns
Type Description
Promise<Geometry[]> When resolved, response is an array of geometries created by cutting the input geometry with the cutter.
Example
// returns array of cut geometries
const geometries = await geometryEngineAsync.cut(boundaryPolygon, polyline);

densify

Method
densify(geometry, maxSegmentLength, maxSegmentLengthUnit){Promise<Geometry>}

Densify geometries by plotting points between existing vertices.

Parameters
geometry Geometry

The geometry to be densified.

maxSegmentLength Number

The maximum segment length allowed. Must be a positive value.

maxSegmentLengthUnit LinearUnits
optional

Measurement unit for maxSegmentLength. Defaults to the units of the input geometry.

Returns
Type Description
Promise<Geometry> When resolved, response is the densified geometry.
Example
// Returns a densified geometry
const geometry = await geometryEngineAsync.densify(boundaryPolygon, 25);

difference

Method
difference(inputGeometry, subtractor){Promise<Geometry>}

Creates the difference of two geometries. The resultant geometry is the portion of inputGeometry not in the subtractor. The dimension of the subtractor has to be equal to or greater than that of the inputGeometry.

Parameters
inputGeometry Geometry|Geometry[]

The input geometry to subtract from.

subtractor Geometry

The geometry being subtracted from inputGeometry.

Returns
Type Description
Promise<Geometry> When resolved, response is the geometry of inputGeometry minus the subtractor geometry.
Example
// Creates a new geometry based on the
// difference of the two
const geometry = await geometryEngineAsync.difference(boundaryPolygon, buffers);

disjoint

Method
disjoint(geometry1, geometry2){Promise<Boolean>}

Indicates if one geometry is disjoint (doesn't intersect in any way) with another geometry.

Parameters
geometry1 Geometry

The base geometry that is tested for the "disjoint" relationship to the other geometry.

geometry2 Geometry

The comparison geometry that is tested for the "disjoint" relationship to the other geometry.

Returns
Type Description
Promise<Boolean> When resolved, response is true if geometry1 and geometry2 are disjoint (don't intersect in any way).
Example
// returns true if a geometry is not contained in another.
// operates the opposite of contains
const isDisjointed = await geometryEngineAsync.disjoint(polygon, boundaryPolygon);

distance

Method
distance(geometry1, geometry2, distanceUnit){Promise<Number>}

Calculates the shortest planar distance between two geometries. Distance is reported in the linear units specified by distanceUnit or, if distanceUnit is null, the units of the spatialReference of input geometry.

To calculate the geodesic distance between two points, first construct a Polyline using the two points of interest as the beginning and ending points of a single path. Then use the polyline as input for the geodesicLength() method.

Parameters
geometry1 Geometry

First input geometry.

geometry2 Geometry

Second input geometry.

distanceUnit LinearUnits
optional

Measurement unit of the return value. Defaults to the units of the input geometries.

Returns
Type Description
Promise<Number> When resolved, response is the distance between the two input geometries.
Example
// returns numeric distance between two points
const totalDistance = await geometryEngineAsync.distance(point1, point2, "feet");

equals

Method
equals(geometry1, geometry2){Promise<Boolean>}

Indicates if two geometries are equal.

Parameters
geometry1 Geometry

First input geometry.

geometry2 Geometry

Second input geometry.

Returns
Type Description
Promise<Boolean> When resolved, responds with true if the two input geometries are equal.
Example
// returns true if two given geometries are equal
const isEqual = await geometryEngineAsync.equals(line1, line2);

extendedSpatialReferenceInfo

Method
extendedSpatialReferenceInfo(spatialReference){Promise<SpatialReferenceInfo>}

Returns an object containing additional information about the input spatial reference.

Parameter
spatialReference SpatialReference

The input spatial reference.

Returns
Type Description
Promise<SpatialReferenceInfo> Resolves to a SpatialReferenceInfo object.

flipHorizontal

Method
flipHorizontal(geometry, flipOrigin){Promise<Geometry>}

Flips a geometry on the horizontal axis. Can optionally be flipped around a point.

Parameters
geometry Geometry

The input geometry to be flipped.

flipOrigin Point
optional

Point to flip the geometry around. Defaults to the centroid of the geometry.

Returns
Type Description
Promise<Geometry> When resolved, response is the flipped geometry.
Example
// Returns a geometry flipped horizontally
const geometry = await geometryEngineAsync.flipHorizontal(boundaryPolygon);

flipVertical

Method
flipVertical(geometry, flipOrigin){Promise<Geometry>}

Flips a geometry on the vertical axis. Can optionally be flipped around a point.

Parameters
geometry Geometry

The input geometry to be flipped.

flipOrigin Point
optional

Point to flip the geometry around. Defaults to the centroid of the geometry.

Returns
Type Description
Promise<Geometry> When resolved, response is the flipped geometry.
Example
// Returns a geometry flipped vertically
const geometry = await geometryEngineAsync.flipVertical(boundaryPolygon);

generalize

Method
generalize(geometry, maxDeviation, removeDegenerateParts, maxDeviationUnit){Promise<Geometry>}

Performs the generalize operation on the geometries in the cursor. Point and Multipoint geometries are left unchanged. Envelope is converted to a Polygon and then generalized.

Parameters
geometry Geometry

The input geometry to be generalized.

maxDeviation Number

The maximum allowed deviation from the generalized geometry to the original geometry.

removeDegenerateParts Boolean
optional

When true the degenerate parts of the geometry will be removed from the output (may be undesired for drawing).

maxDeviationUnit LinearUnits
optional

Measurement unit for maxDeviation. Defaults to the units of the input geometry.

Returns
Type Description
Promise<Geometry> When resolved, response is the generalized geometry.
Example
// Returns a generalized geometry
const geometry = await geometryEngineAsync.generalize(boundaryPolygon, 2.5, true, "miles");

geodesicArea

Method
geodesicArea(geometry, unit){Promise<Number>}

Calculates the area of the input geometry. As opposed to planarArea(), geodesicArea takes into account the curvature of the earth when performing this calculation. Therefore, when using input geometries with a spatial reference of either WGS84 (wkid: 4326) or Web Mercator, it is best practice to calculate areas using geodesicArea(). If the input geometries have a projected coordinate system other than Web Mercator, use planarArea() instead.

This method only works with WGS84 (wkid: 4326) and Web Mercator spatial references.

Parameters
geometry Polygon

The input polygon.

unit AreaUnits
optional

Measurement unit of the return value. Defaults to the units of the input geometries.

Returns
Type Description
Promise<Number> When resolved, response is the area of the input geometry.
Example
// Returns the numeric geodesic area of the given polygon
const area = await geometryEngineAsync.geodesicArea(boundaryPolygon, "square-miles");

geodesicBuffer

Method
geodesicBuffer(geometry, distance, unit, unionResults){Promise<(Polygon|Polygon[])>}

Creates geodesic buffer polygons at a specified distance around the input geometries. When calculating distances, this method takes the curvature of the earth into account, which provides highly accurate results when dealing with very large geometries and/or geometries that spatially vary on a global scale where one projected coordinate system could not accurately plot coordinates and measure distances for all the geometries.

This method only works with WGS84 (wkid: 4326) and Web Mercator spatial references. In general, if your input geometries are assigned one of those two spatial references, you should always use geodesicBuffer() to obtain the most accurate results for those geometries. If needing to buffer points assigned a projected coordinate system other than Web Mercator, use buffer() instead. If the input geometries have a geographic coordinate system other than WGS84 (wkid: 4326), use geometryService.buffer().

Parameters
geometry Geometry|Geometry[]

The buffer input geometry. The geometry and distance parameters must be specified as either both arrays or both non-arrays. Never specify one as an array and the other a non-array.

distance Number|Number[]

The specified distance(s) for buffering. The geometry and distance parameters must be specified as either both arrays or both non-arrays. Never specify one as an array and the other a non-array. When using an array of geometries as input, the length of the geometry array does not have to equal the length of the distance array. For example, if you pass an array of four geometries: [g1, g2, g3, g4] and an array with one distance: [d1], all four geometries will be buffered by the single distance value. If instead you use an array of three distances: [d1, d2, d3], g1 will be buffered by d1, g2 by d2, and g3 and g4 will both be buffered by d3. The value of the geometry array will be matched one to one with those in the distance array until the final value of the distance array is reached, in which case that value will be applied to the remaining geometries.

optional

Measurement unit of the distance(s). Defaults to the units of the input geometries.

unionResults Boolean
optional
Default Value: false

Determines whether the output geometries should merge into a single polygon.

Returns
Type Description
Promise<(Polygon|Polygon[])> When resolved, the response is the resulting buffer(s). The result will be an array if an array of geometries is used as input. It will be a single polygon if a single geometry is input into the function.
Example
const pointButter = await geometryEngineAsync.geodesicBuffer(point, 1000, "kilometers");

geodesicDensify

Method
geodesicDensify(geometry, maxSegmentLength, maxSegmentLengthUnit){Promise<Geometry>}

Returns a geodetically densified version of the input geometry. Use this function to draw the line(s) of the geometry along great circles.

Parameters
geometry Polyline|Polygon

A polyline or polygon to densify.

maxSegmentLength Number

The maximum segment length allowed (in meters if a maxSegmentLengthUnit is not provided). This must be a positive value.

maxSegmentLengthUnit LinearUnits
optional

Measurement unit for maxSegmentLength. If not provided, the unit will default to meters.

Returns
Type Description
Promise<Geometry> Resolves to the densified geometry.
Example
// lineGeom is a line geometry
const densifiedGeom = await geometryEngineAsync.geodesicDensify(lineGeom, 10000);

geodesicLength

Method
geodesicLength(geometry, unit){Promise<Number>}

Calculates the length of the input geometry. As opposed to planarLength(), geodesicLength() takes into account the curvature of the earth when performing this calculation. Therefore, when using input geometries with a spatial reference of either WGS84 (wkid: 4326) or Web Mercator, it is best practice to calculate lengths using geodesicLength(). If the input geometries have a projected coordinate system other than Web Mercator, use planarLength() instead.

This method only works with WGS84 (wkid: 4326) and Web Mercator spatial references.

Parameters
geometry Geometry

The input geometry.

optional

Measurement unit of the return value. Defaults to the units of the input geometry.

Returns
Type Description
Promise<Number> When resolved, response is the length of the input geometry.
Example
// Returns the numeric geodesic length of the given line
const length = await geometryEngineAsync.geodesicLength(riverGeometry, "miles");

intersect

Method
intersect(geometry1, geometry2){Promise<Geometry>}

Creates new geometries from the intersections between two geometries. If the input geometries have different dimensions (i.e. point = 0; polyline = 1; polygon = 2), then the result's dimension will be equal to the lowest dimension of the inputs. The table below describes the expected output for various combinations of geometry types. Note that geometry1 and geometry2 are interchangeable in this operation and will return the same result if flipped.

Geometry1 type Geometry2 type Result geometry type
Polygon Polygon Polygon
Polygon Polyline Polyline
Polygon Point Point
Polyline Polyline Polyline
Polyline Point Point
Point Point Point

Note that two intersecting polylines will not return Point geometries. Rather, this function will return Polyline paths that are equal between the two geometries. See intersectLinesToPoints() to find the point intersections of two polylines.

Parameters
geometry1 Geometry|Geometry[]

The input geometry or array of geometries.

geometry2 Geometry

The geometry to intersect with geometry1.

Returns
Type Description
Promise<Geometry> When resolved, response is the intersections of the input geometries.
Example
// Creates a new geometry from the intersection of the two geometries
const intersecting = await geometryEngineAsync.intersect(boundaryPolygon, buffers);

intersectLinesToPoints

Method
intersectLinesToPoints(line1, line2){Promise<Point[]>}
Since: ArcGIS Maps SDK for JavaScript 4.25 geometryEngineAsync since 4.0, intersectLinesToPoints added at 4.25.

Resolves to an array of points at the intersecting locations of two input polylines. Use intersect for all other geometry intersect operations.

Parameters
line1 Polyline

The first polyline to use in the intersect operation.

line2 Polyline

The second polyline to use in the intersect operation.

Returns
Type Description
Promise<Point[]> The point intersections of the input polylines.
Example
// Creates an array of points for the intersections of the input lines
const intersections = await geometryEngineAsync.intersectLinesToPoints(line1, line2);

intersects

Method
intersects(geometry1, geometry2){Promise<Boolean>}

Indicates if one geometry intersects another geometry.

Parameters
geometry1 Geometry

The geometry that is tested for the intersects relationship to the other geometry.

geometry2 Geometry

The geometry being intersected.

Returns
Type Description
Promise<Boolean> When resolved, response is true if the input geometries intersect each other.
Example
// returns true if two given geometries intersect each other
const isIntersecting = await geometryEngineAsync.intersects(boundaryPolygon, cityPolygon);

isSimple

Method
isSimple(geometry){Promise<Boolean>}

Indicates if the given geometry is topologically simple. In a simplified geometry, no polygon rings or polyline paths will overlap, and no self-intersection will occur.

Parameter
geometry Geometry

The input geometry.

Returns
Type Description
Promise<Boolean> When resolved, response is true if the geometry is topologically simple.
Example
// returns true if given geometry is simple
const simple = await geometryEngineAsync.isSimple(polyline);

nearestCoordinate

Method
nearestCoordinate(geometry, inputPoint){Promise<NearestPointResult>}

Finds the coordinate of the geometry that is closest to the specified point.

Parameters
geometry Geometry

The geometry to consider.

inputPoint Point

The point used to search the nearest coordinate in the geometry.

Returns
Type Description
Promise<NearestPointResult> Resolves to an instance of NearestPointResult, containing the nearest coordinate to the inputPoint.

nearestVertex

Method
nearestVertex(geometry, inputPoint){Promise<NearestPointResult>}

Finds vertex on the geometry nearest to the specified point.

Parameters
geometry Geometry

The geometry to consider.

inputPoint Point

The point used to search the nearest vertex in the geometry.

Returns
Type Description
Promise<NearestPointResult> Resolves to an instance of NearestPointResult, containing the nearest vertex to the inputPoint.
Example
// Finds the nearest vertex of the polygon to the input point
const {
 coordinate,
 distance
} = await geometryEngineAsync.nearestVertex(boundaryPolygon, point);

nearestVertices

Method
nearestVertices(geometry, inputPoint, searchRadius, maxVertexCountToReturn){Promise<NearestPointResult>}

Finds all vertices in the given distance from the specified point, sorted from the closest to the furthest and returns them as an array of Objects.

Parameters
geometry Geometry

The geometry to consider.

inputPoint Point

The point from which to measure.

searchRadius Number

The distance to search from the inputPoint in the units of the view's spatial reference.

maxVertexCountToReturn Number

The maximum number of vertices to return.

Returns
Type Description
Promise<NearestPointResult> Resolves to an array of NearestPointResult, containing the nearest vertices to the inputPoint.
Example
// Returns an array of the nearest vertices
const nearest = await geometryEngineAsync.nearestVertices(boundaryPolygon, point, 500, 2);

offset

Method
offset(geometry, offsetDistance, offsetUnit, joinType, bevelRatio, flattenError){Promise<(Geometry|Geometry[])>}

The offset operation creates a geometry that is a constant planar distance from an input polyline or polygon. It is similar to buffering, but produces a one-sided result.

Parameters
geometry Geometry|Geometry[]

The geometries to offset.

offsetDistance Number

The planar distance to offset from the input geometry. If offsetDistance > 0, then the offset geometry is constructed to the right of the oriented input geometry, if offsetDistance = 0, then there is no change in the geometries, otherwise it is constructed to the left. For a simple polygon, the orientation of outer rings is clockwise and for inner rings it is counter clockwise. So the "right side" of a simple polygon is always its inside.

offsetUnit LinearUnits
optional

Measurement unit of the offset distance. Defaults to the units of the input geometries.

joinType String
optional

The join type.

Possible Values:"round"|"bevel"|"miter"|"square"

bevelRatio Number
optional

Applicable when joinType = 'miter'; bevelRatio is multiplied by the offset distance and the result determines how far a mitered offset intersection can be located before it is beveled.

flattenError Number
optional

Applicable when joinType = 'round'; flattenError determines the maximum distance of the resulting segments compared to the true circular arc. The algorithm never produces more than around 180 vertices for each round join.

Returns
Type Description
Promise<(Geometry|Geometry[])> When resolved, response is the offset geometry or geometries. The result will be an array if an array of geometries is used as input. It will be a single geometry if a single geometry is input into the function.
Example
// Creates a new geometry offset from the provided geometry
const offset = await geometryEngineAsync.offset(boundaryPolygon, 500, "meters", "round");

overlaps

Method
overlaps(geometry1, geometry2){Promise<Boolean>}

Indicates if one geometry overlaps another geometry.

Parameters
geometry1 Geometry

The base geometry that is tested for the "overlaps" relationship with the other geometry.

geometry2 Geometry

The comparison geometry that is tested for the "overlaps" relationship with the other geometry.

Returns
Type Description
Promise<Boolean> When resolved, response is true if the two geometries overlap.
Example
// returns true if one geometry overlaps another,
// but is not contained or disjointed
const isOverlapping = await geometryEngineAsync.overlaps(polygon, boundaryPolygon);

planarArea

Method
planarArea(geometry, unit){Promise<Number>}

Calculates the area of the input geometry. As opposed to geodesicArea(), planarArea() performs this calculation using projected coordinates and does not take into account the earth's curvature. When using input geometries with a spatial reference of either WGS84 (wkid: 4326) or Web Mercator, it is best practice to calculate areas using geodesicArea(). If the input geometries have a projected coordinate system other than Web Mercator, use planarArea() instead.

Parameters
geometry Polygon

The input polygon.

unit AreaUnits
optional

Measurement unit of the return value. Defaults to the units of the input geometries.

Returns
Type Description
Promise<Number> When resolved, response is the area of the input geometry.
Example
// Returns the numeric area of the given polygon
const area = await geometryEngineAsync.planarArea(boundaryPolygon, "square-miles");

planarLength

Method
planarLength(geometry, unit){Promise<Number>}

Calculates the length of the input geometry. As opposed to geodesicLength(), planarLength() uses projected coordinates and does not take into account the curvature of the earth when performing this calculation. When using input geometries with a spatial reference of either WGS84 (wkid: 4326) or Web Mercator, it is best practice to calculate lengths using geodesicLength(). If the input geometries have a projected coordinate system other than Web Mercator, use planarLength() instead.

Parameters
geometry Geometry

The input geometry.

optional

Measurement unit of the return value. Defaults to the units of the input geometries.

Returns
Type Description
Promise<Number> When resolved, response is the length of the input geometry.
Example
// Returns the numeric length of the given line
const length = await geometryEngineAsync.planarLength(riverGeometry, "miles");

relate

Method
relate(geometry1, geometry2, relation){Promise<Boolean>}

Indicates if the given DE-9IM relation holds for the two geometries.

Parameters
geometry1 Geometry

The first geometry for the relation.

geometry2 Geometry

The second geometry for the relation.

relation String

The Dimensionally Extended 9 Intersection Model (DE-9IM) matrix relation (encoded as a string) to test against the relationship of the two geometries. This string contains the test result of each intersection represented in the DE-9IM matrix. Each result is one character of the string and may be represented as either a number (maximum dimension returned: 0,1,2), a Boolean value (T or F), or a mask character (for ignoring results: '*'). For example, each of the following DE-9IM string codes are valid for testing whether a polygon geometry completely contains a line geometry: TTTFFTFFT (Boolean), 'T*****FF*' (ignore irrelevant intersections), or '102FF*FF*' (dimension form). Each returns the same result. See this article and this ArcGIS help page for more information about the DE-9IM model and how string codes are constructed.

Returns
Type Description
Promise<Boolean> When resolved, response is true if the relation of the input geometries holds.
Example
// returns true if the polygon geometry completely
// contains the polyline based on the DE-9IM string
const isRelated = await geometryEngineAsync.relate(polygon, polyline, "TTTFFTFFT");

rotate

Method
rotate(geometry, angle, rotationOrigin){Promise<Geometry>}

Rotates a geometry counterclockwise by the specified number of degrees. Rotation is around the centroid, or a given rotation point.

Parameters
geometry Geometry

The geometry to rotate.

angle Number

The rotation angle in degrees.

rotationOrigin Point
optional

Point to rotate the geometry around. Defaults to the centroid of the geometry.

Returns
Type Description
Promise<Geometry> When resolved, response is the rotated geometry.
Example
// Returns a geometry rotated by 45 degrees
const geometry = await geometryEngineAsync.rotate(boundaryPolygon, 45);

simplify

Method
simplify(geometry){Promise<Geometry>}

Performs the simplify operation on the geometry, which alters the given geometries to make their definitions topologically legal with respect to their geometry type. At the end of a simplify operation, no polygon rings or polyline paths will overlap, and no self-intersection will occur.

Parameter
geometry Geometry

The geometry to be simplified.

Returns
Type Description
Promise<Geometry> When resolved, response is the simplified geometry.
Example
// Topologically simplifies a geometry
const simplified = await geometryEngineAsync.simplify(polyline);
console.log(geometryEngine.isSimple(simplified)); // true

symmetricDifference

Method
symmetricDifference(leftGeometry, rightGeometry){Promise<(Geometry|Geometry[])>}

Creates the symmetric difference of two geometries. The symmetric difference includes the parts that are in either of the sets, but not in both.

Parameters
leftGeometry Geometry|Geometry[]

One of the Geometry instances in the XOR operation.

rightGeometry Geometry

One of the Geometry instances in the XOR operation.

Returns
Type Description
Promise<(Geometry|Geometry[])> When resolved, response is the symmetric differences of the two geometries.
Example
// Creates a new geometry based on the
// symmetric difference of the two
const geometry = await geometryEngineAsync.symmetricDifference(boundaryPolygon, buffers);

touches

Method
touches(geometry1, geometry2){Promise<Boolean>}

Indicates if one geometry touches another geometry.

Parameters
geometry1 Geometry

The geometry to test the "touches" relationship with the other geometry.

geometry2 Geometry

The geometry to be touched.

Returns
Type Description
Promise<Boolean> When resolved, response is true if geometry1 touches geometry2.
Example
// returns true if the line vertex touches the edge of the polygon
const isTouching = await geometryEngineAsync.touches(polygon, line);

union

Method
union(geometries){Promise<Geometry>}

All inputs must be of the same type of geometries and share one spatial reference.

Parameter
geometries Geometry[]

An array of Geometries to union.

Returns
Type Description
Promise<Geometry> When resolved, response is the union of the geometries.
Example
// pt1 and pt2 are point objects to union together
const response = await geometryEngine.union([pt1, pt2]);

within

Method
within(innerGeometry, outerGeometry){Promise<Boolean>}

Indicates if one geometry is within another geometry.

Parameters
innerGeometry Geometry

The base geometry that is tested for the "within" relationship to the other geometry.

outerGeometry Geometry

The comparison geometry that is tested for the "contains" relationship to the other geometry.

Returns
Type Description
Promise<Boolean> When resolved, response is true if innerGeometry is within outerGeometry.
Example
// returns true if a geometry is completely within another
const isWithin = await geometryEngineAsync.within(polygon, boundaryPolygon);

Type Definitions

SpatialReferenceInfo

Type Definition
SpatialReferenceInfo

The return object of the extendedSpatialReferenceInfo() method.

Properties
tolerance Number

The XY tolerance of the spatial reference.

unitBaseFactor Number

Base factor.

unitID Number

Unit ID.

unitSquareDerivative Number

Square derivative.

unitType Number

Unit type.

See also

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