require(["esri/geometry/geometryEngine"], function(geometryEngine) { /* code goes here */ });
Description
(Added at v3.13)
A clientside geometry engine. If more than one geometry is required for any of the methods below, all geometries must have the same spatial reference for the method to work as expected. See the
union
method for a code sample.
Known limitation: This class is only supported using AMDstyle coding syntax.
Samples
Search for
samples that use this class.
Methods
buffer(geometry, distance, unit, unionResults?)  Polygon  Polygon[]  Creates planar (or Euclidean) buffer polygons at a specified distance around the input geometries. 
clip(geometry, envelope)  Geometry  Calculates the clipped geometry from a target geometry by an envelope. 
contains(containerGeometry, insideGeometry)  Boolean  Indicates if one geometry contains another geometry. 
convexHull(geometry, merge?)  Geometry  Geometry[]  Calculates the convex hull of the input geometry. 
crosses(geometry1, geometry2)  Boolean  Indicates if one geometry crosses another geometry. 
cut(geometry, cutter)  Geometry[]  Split the input Polyline or Polygon where it crosses a cutting Polyline. 
densify(geometry, maxSegmentLength, maxSegmentLengthUnit)  Geometry  Densify geometries by plotting points between existing vertices. 
difference(inputGeometry, subtractor)  Geometry  Geometry[]  Creates the difference of two geometries. 
disjoint(geometry1, geometry2)  Boolean  Indicates if one geometry is disjoint (doesn't intersect in any way) with another geometry. 
distance(geometry1, geometry2, distanceUnit)  Number  Calculates the shortest planar distance between two geometries. 
equals(geometry1, geometry2)  Boolean  Indicates if two geometries are equal. 
extendedSpatialReferenceInfo(spatialReference)  Object  Returns an object containing additional information about the input spatial reference. 
flipHorizontal(geometry, flipOrigin?)  Geometry  Flips a geometry on the horizontal axis. 
flipVertical(geometry, flipOrigin?)  Geometry  Flips a geometry on the vertical axis. 
generalize(geometry, maxDeviation, removeDegenerateParts?, maxDeviationUnit?)  Geometry  Performs the generalize operation on the geometries in the cursor. 
geodesicArea(geometry, unit)  Number  Calculates the area of the input geometry. 
geodesicBuffer(geometry, distance, unit, unionResults?)  Polygon  Polygon[]  Creates geodesic buffer polygons at a specified distance around the input geometries. 
geodesicDensify(geometry, maxSegmentLength, maxSegmentLengthUnit?)  Geometry  Returns a geodesically densified version of the input geometry. 
geodesicLength(geometry, unit)  Number  Calculates the length of the input geometry. 
intersect(geometry, intersector)  Geometry  Geometry[]  Creates a new geometry through intersection between two geometries. 
intersects(geometry1, geometry2)  Boolean  Indicates if one geometry intersects another geometry. 
isSimple(geometry)  Boolean  Indicates if the given geometry is topologically simple. 
nearestCoordinate(geometry, inputPoint)  Object  Finds the coordinate of the geometry which is closest to the specified point. 
nearestVertex(geometry, inputPoint)  Object  Finds vertex on the geometry nearest to the specified point. 
nearestVertices(geometry, inputPoint, searchRadius, maxVertexCountToReturn)  Object[]  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. 
offset(geometry, offsetDistance, offsetUnit, joinType, bevelRatio?, flattenError?)  Geometry  Geometry[]  The offset operation creates a geometry that is a constant planar distance from an input polyline or polygon. 
overlaps(geometry1, geometry2)  Boolean  Indicates if one geometry overlaps another geometry. 
planarArea(geometry, unit)  Number  Calculates the area of the input geometry. 
planarLength(geometry, unit)  Number  Calculates the length of the input geometry. 
relate(geometry1, geometry2, relation)  Boolean  Indicates if the given DE9IM relation holds for the two geometries. 
rotate(geometry, angle, rotationOrigin?)  Geometry  Rotates a geometry by a specified angle. 
simplify(geometry)  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. 
symmetricDifference(leftGeometry, rightGeometry)  Geometry  Geometry[]  Creates the symmetric difference of two geometries. 
touches(geometry1, geometry2)  Boolean  Indicates if one geometry touches another geometry. 
union(geometries)  Geometry  All inputs must be of the same type of geometries and share one spatial reference. 
within(innerGeometry, outerGeometry)  Boolean  Indicates if one geometry is within another geometry. 
Method Details
Creates planar (or Euclidean) buffer polygons at a specified distance around the input geometries.
The GeometryEngine has two methods for buffering geometries clientside: 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 Auxiliary Sphere (wkid: 3857). 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 
Required 
The buffer input geometry. The geometry and distance parameters must be specified as either both arrays or both nonarrays. Never specify one as an array and the other a nonarray. 
<Number  Number[] > distance 
Required 
The specified distance(s) for buffering. NOTE: The geometry and distance parameters cannot be mixed. They must either both be specified as arrays, nonarrays, but never both.
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. 
<String  Number > unit 
Required 
Measurement unit for the distance(s). Defaults to the units of the input geometries. Use one of the possible values listed below or any of the numeric codes listed here and here.
Possible Values: meters  feet  kilometers  miles  nauticalmiles  yards 
<Boolean > unionResults 
Optional 
Whether the output geometries should be unioned into a single polygon. 
Calculates the clipped geometry from a target geometry by an envelope.
Parameters:
<Geometry > geometry 
Required 
The geometry to be clipped. 
<Extent > envelope 
Required 
The envelope used to clip. 
Indicates if one geometry contains another geometry.
Parameters:
<Geometry > containerGeometry 
Required 
The geometry that is tested for the "contains" relationship to the other geometry. Think of this geometry as the potential container of the insideGeometry. 
<Geometry > insideGeometry 
Required 
The geometry that is tested for the "within" relationship to the containerGeometry. 
Calculates the convex hull of the input geometry. A convex hull is the smallest convex polygon that encloses a group of objects, such as points. The input geometry can be a point, multipoint, polyline or polygon. The hull is typically a polygon but can also be a polyline or point in degenerate cases.
Indicates if one geometry crosses another geometry.
Parameters:
<Geometry > geometry1 
Required 
The geometry to cross. 
<Geometry > geometry2 
Required 
The geometry being crossed. 
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 leftover 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 
Required 
The geometry to be cut. 
<Polyline > cutter 
Required 
The polyline to cut the geometry. 
Densify geometries by plotting points between existing vertices.
Parameters:
<Geometry > geometry 
Required 
The geometry to be densified. 
<Number > maxSegmentLength 
Required 
The maximum segment length allowed. Must be a positive value. 
<String  Number > maxSegmentLengthUnit 
Required 
Measurement unit for maxSegmentLength. Defaults to the units of the input geometries. Use one of the possible values listed below or any of the numeric codes listed here or here.
Possible Values: meters  feet  kilometers  miles  nauticalmiles  yards 
Creates the difference of two geometries. The resultant geometry is the part of inputGeometry not in the subtractor. The dimension of subtractor has to be equal to or greater than that of inputGeometry.
Parameters:
<Geometry  Geometry[] > inputGeometry 
Required 
The input geometry to subtract from. 
<Geometry > subtractor 
Required 
The geometry being subtracted from inputGeometry. 
Indicates if one geometry is disjoint (doesn't intersect in any way) with another geometry.
Parameters:
<Geometry > geometry1 
Required 
The base geometry that is tested for the "disjoint" relationship to the other geometry. 
<Geometry > geometry2 
Required 
The comparison geometry that is tested for the disjoint relationship to the other geometry. 
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.
Parameters:
<Geometry > geometry1 
Required 
First input geometry. 
<Geometry > geometry2 
Required 
Second input geometry. 
<String  Number > distanceUnit 
Required 
Measurement unit of the return value. Defaults to the units of the input geometries. Use one of the possible values listed below or any of the numeric codes listed here or here.
Possible Values: meters  feet  kilometers  miles  nauticalmiles  yards 
Indicates if two geometries are equal.
Parameters:
<Geometry > geometry1 
Required 
First input geometry. 
<Geometry > geometry2 
Required 
Second input geometry. 
Returns an object containing additional information about the input spatial reference. The returned object includes the following properties:
<Number> tolerance 
The XY tolerance of the spatial reference. 
<Number> unitBaseFactor 
Base factor. 
<Number> unitID 
Unit ID. 
<Number> unitSquareDerivative 
Square derivative. 
<Number> unitType 
Type 
Flips a geometry on the horizontal axis. Can optionally be flipped around a point.
Parameters:
<Geometry > geometry 
Required 
The input geometry. 
<Point > flipOrigin 
Optional 
Point to flip the geometry around. Defaults to the centroid of the geometry. 
Flips a geometry on the vertical axis. Can optionally be flipped around a point.
Parameters:
<Geometry > geometry 
Required 
The input geometry. 
<Point > flipOrigin 
Optional 
Point to flip the geometry around. Defaults to the centroid of the 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 
Required 
The geometry to be generalized. 
<Number > maxDeviation 
Required 
The maximum allowed deviation from the generalized geometry to the original geometry. 
<Boolean > removeDegenerateParts 
Optional 
When true, the degenerate parts of the geometry will be removed from the output (may be undesired for drawing). 
<String  Number > maxDeviationUnit 
Optional 
Measurement unit for maxDeviation. Defaults to the units of the input geometries. Use one of the possible values listed below or any of the numeric codes listed here or here.
Possible Values: meters  feet  kilometers  miles  nauticalmiles  yards 
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 Auxiliary Sphere (wkid: 3857), 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 (wkid: 3857) spatial references.
Parameters:
<Geometry > geometry 
Required 
The input geometry. 
<String  Number > unit 
Required 
Measurement unit of the return value. Defaults to the units of the input geometries. Use one of the possible values listed below or any of the numeric codes listed here.
Possible Values: acres  ares  hectares  squarefeet  squaremeters  squareyards  squarekilometers  squaremiles

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 widely 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 (wkid: 3857) 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 geometries 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 
Required 
The buffer input geometry. The geometry and distance parameters must be specified as either both arrays or both nonarrays. Never specify one as an array and the other a nonarray. 
<Number  Number[] > distance 
Required 
The specified distance(s) for buffering. NOTE: The geometry and distance parameters cannot be mixed. They must either both be specified as arrays, nonarrays, but never both.
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. 
<String  Number > unit 
Required 
Measurement unit for the distance(s). Defaults to the units of the input geometries. Use one of the possible values listed below or any of the numeric codes listed here or here.
Possible Values: meters  feet  kilometers  miles  nauticalmiles  yards 
<Boolean > unionResults 
Optional 
Whether the output geometries should be unioned into a single polygon. 
Returns a geodesically densified version of the input geometry. Use this function to draw the line(s) of the geometry along great circles. (Added at v3.15)
Parameters:
<Polyline  Polygon > geometry 
Required 
A polyline or polygon geometry to densify. 
<Number > maxSegmentLength 
Required 
The maximum segment length allowed. This must be a positive value. 
<Number > maxSegmentLengthUnit 
Optional 
Measurement unit for maxSegmentLength . If a unit is not specified, the units are considered to be the same as the units of the geometry . Use any valid linear unit listed here or here. 
Sample: //lineGeom is a line geometry
var densifiedGeom = geometryEngine.geodesicDensify(lineGeom, 10000);
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 Auxiliary Sphere (wkid: 3857), 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 (wkid: 3857) spatial references.
Parameters:
<Geometry > geometry 
Required 
The input geometry. 
<String  Number > unit 
Required 
Measurement unit of the return value. Defaults to the units of the input geometries. Use one of the possible values listed below or any of the numeric codes listed here or here.
Possible Values: meters  feet  kilometers  miles  nauticalmiles  yards 
Creates a new geometry through intersection between two geometries.
Indicates if one geometry intersects another geometry.
Parameters:
<Geometry > geometry1 
Required 
The geometry that is tested for the intersects relationship to the other geometry. 
<Geometry > geometry2 
Required 
The geometry being intersected. 
Indicates if the given geometry is topologically simple.
Finds the coordinate of the geometry which is closest to the specified point. Returns an object with the following properties:
<Point> coordinate 
The point geometry of the coordinate. Includes x, y, and spatialReference properties. 
<Number> distance 
The distance from the coordinate to the input point 
<Boolean> isRightSide 
When true , the coordinate is to the right of the geometry. 
<Number> vertexIndex 
The index of the coordinate. 
<Boolean> isEmpty 
When true , the result is empty. 
Parameters:
<Geometry > geometry 
Required 
The geometry to consider. 
<Point > inputPoint 
Required 
The point used to search the nearest coordinate in the geometry. 
Finds vertex on the geometry nearest to the specified point. Returns an object with the following properties:
<Point> coordinate 
The point geometry of the vertex. Includes x, y, and spatialReference properties. 
<Number> distance 
The distance from the vertex to the input point 
<Boolean> isRightSide 
When true , the vertex is to the right of the geometry. 
<Number> vertexIndex 
The index of the vertex. 
<Boolean> isEmpty 
When true , the result is empty. 
Parameters:
<Geometry > geometry 
Required 
The geometry to consider. 
<Point > inputPoint 
Required 
The point used to search the nearest vertex in the geometry. 
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. Each object (representing one vertex) has the following properties:
<Point> coordinate 
The point geometry of the vertex. Includes x, y, and spatialReference properties. 
<Number> distance 
The distance from the vertex to the input point 
<Boolean> isRightSide 
When true , the vertex is to the right of the geometry. 
<Number> vertexIndex 
The index of the vertex. 
<Boolean> isEmpty 
When true , the result is empty. 
Parameters:
<Geometry > geometry 
Required 
The geometry to consider. 
<Point > inputPoint 
Required 
The point from which to measure. 
<Number > searchRadius 
Required 
The search radius. 
<Number > maxVertexCountToReturn 
Required 
The maximum number number of vertices to return. 
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 onesided result.
If offsetDistance > 0, then the offset geometry is constructed to the right of the oriented input geometry, 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.
The bevelRatio is multiplied by the offset distance and the result determines how far a mitered offset intersection can be from the input curve before it is beveled.
Parameters:
<Geometry  Geometry[] > geometry 
Required 
The geometries to offset. 
<Number > offsetDistance 
Required 
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. 
<String  Number > offsetUnit 
Required 
Measurement unit for the offset. Defaults to the units of the input geometries. Use one of the possible values listed below or any of the numeric codes listed here or here.
Possible Values: meters  feet  kilometers  miles  nauticalmiles  yards 
<String > joinType 
Required 
The join type.
Possible Values: round  bevel  miter  square 
<Number > bevelRatio 
Optional 
Applicable to 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. 
<Number > flattenError 
Optional 
Applicable to 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. 
Indicates if one geometry overlaps another geometry.
Parameters:
<Geometry > geometry1 
Required 
The base geometry that is tested for overlaps relationship to the other geometry. 
<Geometry > geometry2 
Required 
The comparison geometry that is tested for the overlaps relationship to the other geometry. 
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 Auxiliary Sphere (wkid: 3857), 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 > geometry 
Required 
The input geometry. 
<String  Number > unit 
Required 
Measurement unit of the return value. Defaults to the units of the input geometries. Use one of the possible values listed below or any of the numeric codes listed here.
Possible Values: acres  ares  hectares  squarefeet  squaremeters  squareyards  squarekilometers  squaremiles

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 Auxiliary Sphere (wkid: 3857), 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 
Required 
The input geometry. 
<String  Number > unit 
Required 
Measurement unit of the return value. Defaults to the units of the input geometries. Use one of the possible values listed below or any of the numeric codes listed here or here.
Possible Values: meters  feet  kilometers  miles  nauticalmiles  yards 
Indicates if the given DE9IM relation holds for the two geometries.
Parameters:
<Geometry > geometry1 
Required 
The first geometry for the relation. 
<Geometry > geometry2 
Required 
The second geometry for the relation. 
<String > relation 
Required 
The Dimensionally Extended 9 Intersection Model (DE9IM) 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 DE9IM 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: '*').
Example: Each of the following DE9IM 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 DE9IM model and how string codes are constructed. 
Rotates a geometry by a specified angle. Rotation is around the centroid, or a given rotation point.
Parameters:
<Geometry > geometry 
Required 
The input geometry. 
<Number > angle 
Required 
The rotation angle 
<Point > rotationOrigin 
Optional 
Point to rotate the geometry around. Defaults to the centroid of the 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.
Parameters:
<Geometry > geometry 
Required 
The geometry to be simplified. 
Creates the symmetric difference of two geometries.
The symmetric difference includes the parts which are in either of the sets, but not in both.
Parameters:
<Geometry  Geometry[] > leftGeometry 
Required 
One of the Geometry instances in the XOR operation. 
<Geometry > rightGeometry 
Required 
One of the Geometry instances in the XOR operation. 
Indicates if one geometry touches another geometry.
Parameters:
<Geometry > geometry1 
Required 
The geometry which may be touching another geometry. 
<Geometry > geometry2 
Required 
The geometry to be touched. 
All inputs must be of the same type of geometries and share one spatial reference.
Parameters:
<Geometry[] > geometries 
Required 
The geometries to union. 
Sample: require([
"esri/geometry/Point",
"esri/geometry/geometryEngine",
"esri/SpatialReference"
], function (Point, geometryEngine, SpatialReference){
var pt1 = new Point(118.15, 33.80, new SpatialReference({wkid: 4326}));
var pt2 = new Point(119.15, 32.80, new SpatialReference({wkid: 4326}));
// Using Module to Union
var union = geometryEngine.union([pt1, pt2]);
console.log("geometryEngine.union: %o", union);
});
Indicates if one geometry is within another geometry.
Parameters:
<Geometry > innerGeometry 
Required 
The base geometry that is tested for within relationship to the other geometry. 
<Geometry > outerGeometry 
Required 
The comparison geometry that is tested for the contains relationship to the other geometry. 