require(["esri/geometry/geometryEngine"], (geometryEngine) => { /* code goes here */ });
import * as geometryEngine from "@arcgis/core/geometry/geometryEngine.js";
esri/geometry/geometryEngine
A 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 |
---|---|---|---|
Creates planar (or Euclidean) buffer polygons at a specified distance around the input geometries. | geometryEngine | ||
Calculates the clipped geometry from a target geometry by an envelope. | geometryEngine | ||
Indicates if one geometry contains another geometry. | geometryEngine | ||
Calculates the convex hull of one or more geometries. | geometryEngine | ||
Indicates if one geometry crosses another geometry. | geometryEngine | ||
Splits the input Polyline or Polygon where it crosses a cutting Polyline. | geometryEngine | ||
Densify geometries by plotting points between existing vertices. | geometryEngine | ||
Creates the difference of two geometries. | geometryEngine | ||
Indicates if one geometry is disjoint (doesn't intersect in any way) with another geometry. | geometryEngine | ||
Calculates the shortest planar distance between two geometries. | geometryEngine | ||
Indicates if two geometries are equal. | geometryEngine | ||
Returns an object containing additional information about the input spatial reference. | geometryEngine | ||
Flips a geometry on the horizontal axis. | geometryEngine | ||
Flips a geometry on the vertical axis. | geometryEngine | ||
Performs the generalize operation on the geometries in the cursor. | geometryEngine | ||
Calculates the area of the input geometry. | geometryEngine | ||
Creates geodesic buffer polygons at a specified distance around the input geometries. | geometryEngine | ||
Returns a geodetically densified version of the input geometry. | geometryEngine | ||
Calculates the length of the input geometry. | geometryEngine | ||
Creates new geometries from the intersections between two geometries. | geometryEngine | ||
Returns an array of points at the intersecting locations of two input polylines. | geometryEngine | ||
Indicates if one geometry intersects another geometry. | geometryEngine | ||
Indicates if the given geometry is non-OGC topologically simple. | geometryEngine | ||
Finds the coordinate of the geometry that is closest to the specified point. | geometryEngine | ||
Finds the vertex on the geometry nearest to the specified point. | geometryEngine | ||
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. | geometryEngine | ||
The offset operation creates a geometry that is a constant planar distance from an input polyline or polygon. | geometryEngine | ||
Indicates if one geometry overlaps another geometry. | geometryEngine | ||
Calculates the area of the input geometry. | geometryEngine | ||
Calculates the length of the input geometry. | geometryEngine | ||
Indicates if the given DE-9IM relation is true for the two geometries. | geometryEngine | ||
Rotates a geometry counterclockwise by the specified number of degrees. | geometryEngine | ||
Performs the simplify operation on the geometry, which alters the given geometries to make their definitions topologically legal with respect to their geometry type. | geometryEngine | ||
Creates the symmetric difference of two geometries. | geometryEngine | ||
Indicates if one geometry touches another geometry. | geometryEngine | ||
All inputs must be of the same type of geometries and share one spatial reference. | geometryEngine | ||
Indicates if one geometry is within another geometry. | geometryEngine |
Method Details
-
Deprecated since 4.32. Use bufferOperator instead.
-
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().
Parametersgeometry GeometryUnion|GeometryUnion[]The buffer input geometry. The
geometry
anddistance
parameters must be specified as either both arrays or both non-arrays. Never specify one as an array and the other a non-array.The specified distance(s) for buffering. The
geometry
anddistance
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 thedistance
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 byd1
,g2
byd2
, andg3
andg4
will both be buffered byd3
. 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.unit LinearUnitsoptionalMeasurement unit of the distance(s). Defaults to the units of the input geometries.
unionResults BooleanoptionalDefault Value: falseDetermines whether the output geometries should be unioned into a single polygon.
ReturnsExample// Buffer point by 1000 feet const ptBuff = geometryEngine.buffer(point, 1000, "feet");
-
clip
clip(geometry, envelope){GeometryUnion}
Deprecated since version 4.32. Use clipOperator instead. -
Calculates the clipped geometry from a target geometry by an envelope.
Parametersgeometry GeometryUnionThe geometry to be clipped.
envelope ExtentThe envelope used to clip.
ReturnsType Description GeometryUnion Clipped geometry. - See also
Example// returns a new geometry of a polygon clipped by the views extent const clippedGeometry= geometryEngine.clip(boundaryPolygon, view.extent);
-
contains
contains(containerGeometry, insideGeometry){Boolean}
Deprecated since version 4.32. Use containsOperator instead. -
Indicates if one geometry contains another geometry.
ParameterscontainerGeometry GeometryUnionThe geometry that is tested for the "contains" relationship to the other geometry. Think of this geometry as the potential "container" of the
insideGeometry
.insideGeometry GeometryUnionThe geometry that is tested for the "within" relationship to the
containerGeometry
.ReturnsType Description Boolean Returns true
if thecontainerGeometry
contains theinsideGeometry
.- See also
Examples// returns true or false for one geometry containing another const isContained = geometryEngine.contains(boundaryPolygon, point);
// returns true or false for one geometry containing another const isContained = geometryEngine.contains(extent, boundaryPolygon);
-
convexHull
convexHull(geometry, merge){GeometryUnion |GeometryUnion[]}
Deprecated since version 4.32. Use convexHullOperator instead. -
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.
Parametersgeometry GeometryUnion|GeometryUnion[]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 BooleanoptionalDefault Value: falseIndicates whether to merge the output into a single geometry (usually a polygon).
ReturnsType Description GeometryUnion | GeometryUnion[] Returns 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). - See also
Examples// returns the convex hull of a multipoint as a single polygon const hull = geometryEngine.convexHull(multipoint);
// returns the convex hull of an array of points as a single polygon const [ hull ] = geometryEngine.convexHull([ pointA, pointB, pointC ], true);
// returns the convex hull for each input line geometry as three polygons const hulls = geometryEngine.convexHull([ lineA, lineB, lineC ]);
// returns the convex hull for all input line geometries as a single polygon const [ hull ] = geometryEngine.convexHull([ lineA, lineB, lineC ], true);
// returns the convex hull for all input geometries as a single polygon const [ hull ] = geometryEngine.convexHull([ point, line, polygon ], true);
-
crosses
crosses(geometry1, geometry2){Boolean}
Deprecated since version 4.32. Use crossesOperator instead. -
Indicates if one geometry crosses another geometry.
Parametersgeometry1 GeometryUnionThe geometry to cross.
geometry2 GeometryUnionThe geometry being crossed.
ReturnsType Description Boolean Returns true
ifgeometry1
crossesgeometry2
.- See also
Example// returns true or false if a line crosses a polygon another const isCrossed = geometryEngine.crosses(boundaryPolygon, polyline);
-
cut
cut(geometry, cutter){GeometryUnion[]}
Deprecated since version 4.32. Use cutOperator instead. -
Splits 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.
Parametersgeometry GeometryUnionThe geometry to be cut.
cutter PolylineThe polyline to cut the geometry.
ReturnsType Description GeometryUnion[] Returns an array of geometries created by cutting the input geometry with the cutter. - See also
Example// returns array of cut geometries const geometries = geometryEngine.cut(boundaryPolygon, polyline);
-
densify
densify(geometry, maxSegmentLength, maxSegmentLengthUnit){GeometryUnion}
Deprecated since 4.32. Use densifyOperator instead. -
Densify geometries by plotting points between existing vertices.
Parametersgeometry GeometryUnionThe geometry to be densified.
maxSegmentLength NumberThe maximum segment length allowed. Must be a positive value.
maxSegmentLengthUnit LinearUnits|NumberoptionalMeasurement unit for maxSegmentLength. Defaults to the units of the input geometry.
ReturnsType Description GeometryUnion The densified geometry. Example// Returns a densified geometry const geometry = geometryEngine.densify(boundaryPolygon, 25);
-
difference
difference(inputGeometry, subtractor){GeometryUnion |GeometryUnion[]}
Deprecated since version 4.32. Use differenceOperator instead. -
Creates the difference of two geometries. The resultant geometry is the portion of
inputGeometry
not in thesubtractor
. The dimension of thesubtractor
has to be equal to or greater than that of theinputGeometry
.ParametersinputGeometry GeometryUnion|GeometryUnion[]The input geometry to subtract from.
subtractor GeometryUnionThe geometry being subtracted from inputGeometry.
ReturnsType Description GeometryUnion | GeometryUnion[] Returns the geometry of inputGeometry minus the subtractor geometry. - See also
Example// Creates a new geometry based on the // difference of the two const geometry = geometryEngine.difference(boundaryPolygon, buffers);
-
disjoint
disjoint(geometry1, geometry2){Boolean}
Deprecated since version 4.32. Use disjointOperator instead. -
Indicates if one geometry is disjoint (doesn't intersect in any way) with another geometry.
Parametersgeometry1 GeometryUnionThe base geometry that is tested for the "disjoint" relationship to the other geometry.
geometry2 GeometryUnionThe comparison geometry that is tested for the "disjoint" relationship to the other geometry.
ReturnsType Description Boolean Returns true
ifgeometry1
andgeometry2
are disjoint (don't intersect in any way).- See also
Example// returns true if a geometry is not contained in another. // operates the opposite of contains const isDisjointed = geometryEngine.disjoint(polygon, boundaryPolygon);
-
distance
distance(geometry1, geometry2, distanceUnit){Number}
Deprecated since version 4.32. Use distanceOperator instead. -
Calculates the shortest planar distance between two geometries. Distance is reported in the linear units specified by
distanceUnit
or, ifdistanceUnit
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.
Parametersgeometry1 GeometryUnionFirst input geometry.
geometry2 GeometryUnionSecond input geometry.
distanceUnit LinearUnits|null|undefinedoptionalMeasurement unit of the return value. Defaults to the units of the input geometries.
ReturnsType Description Number Distance between the two input geometries. - See also
Example// returns numeric distance between two points const totalDistance = geometryEngine.distance(point1, point2, "feet");
-
equals
equals(geometry1, geometry2){Boolean}
Deprecated since version 4.32. Use equalsOperator instead. -
Indicates if two geometries are equal.
Parametersgeometry1 GeometryUnionFirst input geometry.
geometry2 GeometryUnionSecond input geometry.
ReturnsType Description Boolean Returns true
if the two input geometries are equal.- See also
Example// returns true if two given geometries are equal const isEqual = geometryEngine.equals(line1, line2);
-
extendedSpatialReferenceInfo
extendedSpatialReferenceInfo(spatialReference){SpatialReferenceInfo}
Deprecated since version 4.32. -
Returns an object containing additional information about the input spatial reference.
ParameterspatialReference SpatialReferenceThe input spatial reference.
ReturnsType Description SpatialReferenceInfo Resolves to a SpatialReferenceInfo object.
-
flipHorizontal
flipHorizontal(geometry, flipOrigin){GeometryUnion}
Deprecated since 4.32. Use Transformation's flipY() method and the affineTransformationOperator instead. -
Flips a geometry on the horizontal axis. Can optionally be flipped around a point.
Parametersgeometry GeometryUnionThe input geometry to be flipped.
optional Point to flip the geometry around. Defaults to the centroid of the geometry.
ReturnsType Description GeometryUnion The flipped geometry. - See also
Example// Returns a geometry flipped horizontally const geometry = geometryEngine.flipHorizontal(boundaryPolygon);
-
flipVertical
flipVertical(geometry, flipOrigin){GeometryUnion}
Deprecated since 4.32. Use Transformation's flipX() method and the affineTransformationOperator instead. -
Flips a geometry on the vertical axis. Can optionally be flipped around a point.
Parametersgeometry GeometryUnionThe input geometry to be flipped.
optional Point to flip the geometry around. Defaults to the centroid of the geometry.
ReturnsType Description GeometryUnion The flipped geometry. - See also
Example// Returns a geometry flipped vertically const geometry = geometryEngine.flipVertical(boundaryPolygon);
-
generalize
generalize(geometry, maxDeviation, removeDegenerateParts, maxDeviationUnit){GeometryUnion}
Deprecated since 4.32. Use generalizeOperator instead. -
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.
Parametersgeometry GeometryUnionThe input geometry to be generalized.
maxDeviation NumberThe maximum allowed deviation from the generalized geometry to the original geometry.
removeDegenerateParts BooleanoptionalWhen
true
the degenerate parts of the geometry will be removed from the output (may be undesired for drawing).maxDeviationUnit LinearUnits|NumberoptionalMeasurement unit for maxDeviation. Defaults to the units of the input geometry.
ReturnsType Description GeometryUnion The generalized geometry. - See also
Example// Returns a generalized geometry const geometry = geometryEngine.generalize(boundaryPolygon, 2.5, true, "miles");
-
geodesicArea
geodesicArea(geometry, unit){Number}
Deprecated since 4.32. Use geodeticAreaOperator instead. -
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.
ParametersReturnsType Description Number Area of the input geometry. - See also
Example// Returns the numeric geodesic area of the given polygon const area = geometryEngine.geodesicArea(boundaryPolygon, "square-miles");
-
Deprecated since 4.32. Use geodesicBufferOperator instead.
-
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().
Parametersgeometry GeometryUnion|GeometryUnion[]The buffer input geometry. The
geometry
anddistance
parameters must be specified as either both arrays or both non-arrays. Never specify one as an array and the other a non-array.The specified distance(s) for buffering. The
geometry
anddistance
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 thedistance
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 byd1
,g2
byd2
, andg3
andg4
will both be buffered byd3
. 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.unit LinearUnits|NumberoptionalMeasurement unit of the distance(s). Defaults to the units of the input geometries.
unionResults BooleanoptionalDefault Value: falseDetermines whether the output geometries should be unioned into a single polygon.
Returns- See also
Example// point is a Point geometry const ptBuff = geometryEngine.geodesicBuffer(point, 1000, "kilometers"); // Buffer point by 1000km
-
geodesicDensify
geodesicDensify(geometry, maxSegmentLength, maxSegmentLengthUnit){GeometryUnion}
Deprecated since 4.32. Use geodeticDensifyOperator instead. -
Returns a geodetically densified version of the input geometry. Use this function to draw the line(s) of the geometry along great circles.
ParametersA polyline or polygon to densify.
maxSegmentLength NumberThe maximum segment length allowed (in meters if a
maxSegmentLengthUnit
is not provided). This must be a positive value.maxSegmentLengthUnit LinearUnitsoptionalMeasurement unit for
maxSegmentLength
. If not provided, the unit will default tometers
.ReturnsType Description GeometryUnion Returns the densified geometry. Example// lineGeom is a line geometry const densifiedGeom = geometryEngine.geodesicDensify(lineGeom, 10000);
-
geodesicLength
geodesicLength(geometry, unit){Number}
Deprecated since 4.32. Use geodeticLengthOperator instead. -
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.
Parametersgeometry GeometryUnionThe input geometry.
unit LinearUnits|NumberoptionalMeasurement unit of the return value. Defaults to the units of the input geometry.
ReturnsType Description Number Length of the input geometry. - See also
Example// Returns the numeric geodesic length of the given line const length = geometryEngine.geodesicLength(riverGeometry, "miles");
-
intersect
intersect(geometry1, geometry2){GeometryUnion |GeometryUnion[]}
Deprecated since version 4.32. Use intersectionOperator instead. -
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
andgeometry2
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.
Parametersgeometry1 GeometryUnion|GeometryUnion[]The input geometry or array of geometries.
geometry2 GeometryUnionThe geometry to intersect with geometry1.
ReturnsType Description GeometryUnion | GeometryUnion[] The intersections of the geometries. Example// Creates a new geometry from the intersection // of the two geometries const intersecting = geometryEngine.intersect(boundaryPolygon, buffers);
-
Since: ArcGIS Maps SDK for JavaScript 4.25geometryEngine since 4.0, intersectLinesToPoints added at 4.25. Deprecated since 4.32. Use intersectionOperator's executeMany() method instead. -
Returns an array of points at the intersecting locations of two input polylines. Use intersect for all other geometry intersect operations.
ParametersReturnsExample// Creates an array of points for the intersections of the input lines const intersections = geometryEngine.intersectLinesToPoints(line1, line2);
-
intersects
intersects(geometry1, geometry2){Boolean}
Deprecated since version 4.32. Use intersectsOperator instead. -
Indicates if one geometry intersects another geometry.
Parametersgeometry1 GeometryUnionThe geometry that is tested for the intersects relationship to the other geometry.
geometry2 GeometryUnionThe geometry being intersected.
ReturnsType Description Boolean Returns true
if the input geometries intersect each other.- See also
Example// returns true if two given geometries intersect each other const isIntersecting = geometryEngine.intersects(boundaryPolygon, cityPolygon);
-
isSimple
isSimple(geometry){Boolean}
Deprecated since version 4.32. Use simplifyOperator's isSimple() method instead. -
Indicates if the given geometry is non-OGC topologically simple. No polygon rings self-intersect. Polylines paths that self-intersect are considered simple.
Parametergeometry GeometryUnionThe input geometry.
ReturnsType Description Boolean Returns true
if the geometry is topologically simple.- See also
Example// returns true if given geometry is simple const simple = geometryEngine.isSimple(polyline);
-
nearestCoordinate
nearestCoordinate(geometry, inputPoint){NearestPointResult}
Deprecated since 4.32. Use proximityOperator's getNearestCoordinate() method instead. -
Finds the coordinate of the geometry that is closest to the specified point.
Parametersgeometry GeometryUnionThe geometry to consider.
inputPoint PointThe point used to search the nearest coordinate in the geometry.
ReturnsType Description NearestPointResult Returns an object containing the nearest coordinate.
-
nearestVertex
nearestVertex(geometry, inputPoint){NearestPointResult}
Deprecated since 4.32. Use proximityOperator's getNearestVertex() method instead. -
Finds the vertex on the geometry nearest to the specified point.
Parametersgeometry GeometryUnionThe geometry to consider.
inputPoint PointThe point used to search the nearest vertex in the geometry.
ReturnsType Description NearestPointResult Returns an object containing the nearest vertex. - See also
Example// Finds the nearest vertex of the polygon to the input point const { coordinate, distance } = geometryEngine.nearestVertex(boundaryPolygon, point);
-
nearestVertices
nearestVertices(geometry, inputPoint, searchRadius, maxVertexCountToReturn){NearestPointResult[]}
Deprecated since 4.32. Use proximityOperator's getNearestVertices() method instead. -
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.
Parametersgeometry GeometryUnionThe geometry to consider.
inputPoint PointThe point from which to measure.
searchRadius NumberThe distance to search from the inputPoint in the units of the view's spatial reference.
maxVertexCountToReturn NumberThe maximum number of vertices to return.
ReturnsType Description NearestPointResult[] An array of objects containing the nearest vertices within the given searchRadius
.Example// Returns an array of the nearest vertices const nearest = geometryEngine.nearestVertices(boundaryPolygon, point, 500, 2);
-
offset
offset(geometry, offsetDistance, offsetUnit, joinType, bevelRatio, flattenError){GeometryUnion |GeometryUnion[]}
Deprecated since 4.32. Use offsetOperator instead. -
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.
Parametersgeometry GeometryUnion|GeometryUnion[]The geometries to offset.
offsetDistance NumberThe 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 LinearUnitsoptionalMeasurement unit of the offset distance. Defaults to the units of the input geometries.
joinType StringoptionalThe join type.
Possible Values:"round"|"bevel"|"miter"|"square"
bevelRatio NumberoptionalApplicable 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 NumberoptionalApplicable 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.ReturnsType Description GeometryUnion | GeometryUnion[] The offset geometries. - See also
Example// Creates a new geometry offset from the provided geometry const offset = geometryEngine.offset(boundaryPolygon, 500, "meters", "round");
-
overlaps
overlaps(geometry1, geometry2){Boolean}
Deprecated since version 4.32. Use overlapsOperator instead. -
Indicates if one geometry overlaps another geometry.
Parametersgeometry1 GeometryUnionThe base geometry that is tested for the "overlaps" relationship with the other geometry.
geometry2 GeometryUnionThe comparison geometry that is tested for the "overlaps" relationship with the other geometry.
ReturnsType Description Boolean Returns true
if the two geometries overlap.- See also
Example// returns true if one geometry overlaps another, // but is not contained or disjointed const isOverlapping = geometryEngine.overlaps(polygon, boundaryPolygon);
-
planarArea
planarArea(geometry, unit){Number}
Deprecated since 4.32. Use areaOperator instead. -
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.
ParametersReturnsType Description Number The area of the input geometry. - See also
Example// Returns the numeric area of the given polygon const area = geometryEngine.planarArea(boundaryPolygon, "square-miles");
-
planarLength
planarLength(geometry, unit){Number}
Deprecated since 4.32. Use lengthOperator instead. -
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.
Parametersgeometry GeometryUnionThe input geometry.
unit LinearUnits|NumberoptionalMeasurement unit of the return value. Defaults to the units of the input geometries.
ReturnsType Description Number The length of the input geometry. - See also
Example// Returns the numeric length of the given line const length = geometryEngine.planarLength(riverGeometry, "miles");
-
relate
relate(geometry1, geometry2, relation){Boolean}
Deprecated since version 4.32. Use relateOperator instead. -
Indicates if the given DE-9IM relation is true for the two geometries.
Parametersgeometry1 GeometryUnionThe first geometry for the relation.
geometry2 GeometryUnionThe second geometry for the relation.
relation StringThe 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
orF
), 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.ReturnsType Description Boolean Returns true
if the relation of the input geometries is accurate.- See also
Example// returns true if the polygon geometry completely // contains the polyline based on the DE-9IM string const isRelated = geometryEngine.relate(polygon, polyline, "TTTFFTFFT");
-
rotate
rotate(geometry, angle, rotationOrigin){GeometryUnion}
Deprecated since 4.32. Use Transformation's rotate() method and the affineTransformationOperator instead. -
Rotates a geometry counterclockwise by the specified number of degrees. Rotation is around the centroid, or a given rotation point.
Parametersgeometry GeometryUnionThe geometry to rotate.
angle NumberThe rotation angle in degrees.
rotationOrigin PointoptionalPoint to rotate the geometry around. Defaults to the centroid of the geometry.
ReturnsType Description GeometryUnion The rotated geometry. - See also
Example// Returns a geometry rotated by 45 degrees const geometry = geometryEngine.rotate(boundaryPolygon, 45);
-
simplify
simplify(geometry){GeometryUnion}
Deprecated since version 4.32. Use simplifyOperator instead. -
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.
Parametergeometry GeometryUnionThe geometry to be simplified.
ReturnsType Description GeometryUnion The simplified geometry. - See also
Example// Topologically simplifies a geometry const simplified = geometryEngine.simplify(polyline); console.log(geometryEngine.isSimple(simplified)); // true
-
symmetricDifference
symmetricDifference(leftGeometry, rightGeometry){GeometryUnion |GeometryUnion[]}
Deprecated since 4.32. Use symmetricDifferenceOperator instead. -
Creates the symmetric difference of two geometries. The symmetric difference includes the parts that are in either of the sets, but not in both.
ParametersleftGeometry GeometryUnion|GeometryUnion[]One of the Geometry instances in the XOR operation.
rightGeometry GeometryUnionOne of the Geometry instances in the XOR operation.
ReturnsType Description GeometryUnion | GeometryUnion[] The symmetric differences of the two geometries. Example// Creates a new geometry based on the // symmetric difference of the two const geometry = geometryEngine.symmetricDifference(boundaryPolygon, buffers);
-
touches
touches(geometry1, geometry2){Boolean}
Deprecated since version 4.32. Use touchesOperator instead. -
Indicates if one geometry touches another geometry.
Parametersgeometry1 GeometryUnionThe geometry to test the "touches" relationship with the other geometry.
geometry2 GeometryUnionThe geometry to be touched.
ReturnsType Description Boolean When true
,geometry1
touchesgeometry2
.- See also
Example// returns true if the line vertex touches the edge of the polygon const isTouching = geometryEngine.touches(polygon, line);
-
union
union(geometries){GeometryUnion}
Deprecated since 4.32. Use unionOperator instead. -
All inputs must be of the same type of geometries and share one spatial reference.
Parametergeometries GeometryUnion[]An array of Geometries to union.
ReturnsType Description GeometryUnion The union of the geometries. - See also
Example// pt1 and pt2 are Point geometries to union together const union = geometryEngine.union([pt1, pt2]);
-
within
within(innerGeometry, outerGeometry){Boolean}
Deprecated since version 4.32. Use withinOperator instead. -
Indicates if one geometry is within another geometry.
ParametersinnerGeometry GeometryUnionThe base geometry that is tested for the "within" relationship to the other geometry.
outerGeometry GeometryUnionThe comparison geometry that is tested for the "contains" relationship to the other geometry.
ReturnsType Description Boolean Returns true
ifinnerGeometry
is withinouterGeometry
.- See also
Example// returns true if a geometry is completely within another const isWithin = geometryEngine.within(polygon, boundaryPolygon);
Type Definitions
-
Deprecated since version 4.32. Use LengthUnit instead.
-
Units for linear measurements. Use one of the string values below or a numerical value from here or here.
Possible Values:"meters" |"feet" |"kilometers" |"miles" |"nautical-miles" |"yards" |Number
-
Deprecated since version 4.32. Use proximityOperator's ProximityResult instead.
-
Object returned from the nearestCoordinate(), nearestVertex(), and nearestVertices() methods.
- Properties
-
coordinate Point
A vertex within the specified distance of the search.
distance NumberThe distance from the
inputPoint
in the units of the view's spatial reference.vertexIndex NumberThe index of the vertex within the geometry's rings or paths.
isEmpty BooleanIndicates if it is an empty geometry.
-
Deprecated since version 4.32.
-
The return object of the extendedSpatialReferenceInfo() method.