import { extendedSpatialReferenceInfo, clip, cut, contains, crosses } from "@arcgis/core/geometry/geometryEngine.js";const { extendedSpatialReferenceInfo, clip, cut, contains, crosses } = await $arcgis.import("@arcgis/core/geometry/geometryEngine.js");- Since
- ArcGIS Maps SDK for JavaScript 4.0
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:
Functions
| Name | Return Type | Object |
|---|---|---|
extendedSpatialReferenceInfo deprecated | | |
clip deprecated | | |
cut deprecated | | |
contains deprecated | | |
crosses deprecated | | |
distance deprecated | | |
equals deprecated | | |
intersects deprecated | | |
touches deprecated | | |
within deprecated | | |
disjoint deprecated | | |
overlaps deprecated | | |
relate deprecated | | |
isSimple deprecated | | |
simplify deprecated | | |
convexHull deprecated | | |
difference deprecated | | |
symmetricDifference deprecated | | |
intersect deprecated | | |
union deprecated | | |
offset deprecated | | |
buffer deprecated | | |
geodesicBuffer deprecated | | |
nearestCoordinate deprecated | | |
nearestVertex deprecated | | |
nearestVertices deprecated | | |
rotate deprecated | | |
flipHorizontal deprecated | | |
flipVertical deprecated | | |
generalize deprecated | | |
densify deprecated | | |
geodesicDensify deprecated | | |
planarArea deprecated | | |
planarLength deprecated | | |
geodesicArea deprecated | | |
geodesicLength deprecated | | |
intersectLinesToPoints deprecated | Point[] | |
extendedSpatialReferenceInfo
Returns an object containing additional information about the input spatial reference.
- See also
- Signature
-
extendedSpatialReferenceInfo (spatialReference: SpatialReference): ExtendedSpatialReferenceInfo
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| spatialReference | The input spatial reference. | |
- Returns
- ExtendedSpatialReferenceInfo
Resolves to a ExtendedSpatialReferenceInfo object.
clip
Calculates the clipped geometry from a target geometry by an envelope.
- Signature
-
clip (geometry: GeometryUnion, envelope: Extent): GeometryUnion
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry | The geometry to be clipped. | | |
| envelope | The envelope used to clip. | |
- Returns
- GeometryUnion
Clipped geometry.
Example
// returns a new geometry of a polygon clipped by the views extentconst clippedGeometry= geometryEngine.clip(boundaryPolygon, view.extent); cut
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.
- Signature
-
cut (geometry: GeometryUnion, cutter: Polyline): GeometryUnion[]
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry | The geometry to be cut. | | |
| cutter | The polyline to cut the geometry. | |
- Returns
- GeometryUnion[]
Returns an array of geometries created by cutting the input geometry with the cutter.
Example
// returns array of cut geometriesconst geometries = geometryEngine.cut(boundaryPolygon, polyline); contains
Indicates if one geometry contains another geometry.
- Signature
-
contains (containerGeometry: GeometryUnion, insideGeometry: GeometryUnion): boolean
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| containerGeometry | The geometry that is tested for the "contains" relationship to the other geometry.
Think of this geometry as the potential "container" of the | | |
| insideGeometry | The geometry that is tested for the "within" relationship to the | |
- Returns
- boolean
Returns
trueif thecontainerGeometrycontains theinsideGeometry.
Examples
// returns true or false for one geometry containing anotherconst isContained = geometryEngine.contains(boundaryPolygon, point);// returns true or false for one geometry containing anotherconst isContained = geometryEngine.contains(extent, boundaryPolygon); crosses
Indicates if one geometry crosses another geometry.
- Signature
-
crosses (geometry1: GeometryUnion, geometry2: GeometryUnion): boolean
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry1 | The geometry to cross. | | |
| geometry2 | The geometry being crossed. | |
- Returns
- boolean
Returns
trueifgeometry1crossesgeometry2.
Example
// returns true or false if a line crosses a polygon anotherconst isCrossed = geometryEngine.crosses(boundaryPolygon, polyline); distance
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.
- Signature
-
distance (geometry1: GeometryUnion, geometry2: GeometryUnion, distanceUnit?: number | LinearUnit | null | undefined): number
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry1 | First input geometry. | | |
| geometry2 | Second input geometry. | | |
| distanceUnit | number | LinearUnit | null | undefined | Measurement unit of the return value. Defaults to the units of the input geometries. | |
- Returns
- number
Distance between the two input geometries.
Example
// returns numeric distance between two pointsconst totalDistance = geometryEngine.distance(point1, point2, "feet"); equals
Indicates if two geometries are equal.
- Signature
-
equals (geometry1: GeometryUnion, geometry2: GeometryUnion): boolean
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry1 | First input geometry. | | |
| geometry2 | Second input geometry. | |
- Returns
- boolean
Returns
trueif the two input geometries are equal.
Example
// returns true if two given geometries are equalconst isEqual = geometryEngine.equals(line1, line2); intersects
Indicates if one geometry intersects another geometry.
- Signature
-
intersects (geometry1: GeometryUnion, geometry2: GeometryUnion): boolean
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry1 | The geometry that is tested for the intersects relationship to the other geometry. | | |
| geometry2 | The geometry being intersected. | |
- Returns
- boolean
Returns
trueif the input geometries intersect each other.
Example
// returns true if two given geometries intersect each otherconst isIntersecting = geometryEngine.intersects(boundaryPolygon, cityPolygon); touches
Indicates if one geometry touches another geometry.
- Signature
-
touches (geometry1: GeometryUnion, geometry2: GeometryUnion): boolean
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry1 | The geometry to test the "touches" relationship with the other geometry. | | |
| geometry2 | The geometry to be touched. | |
- Returns
- boolean
When
true,geometry1touchesgeometry2.
Example
// returns true if the line vertex touches the edge of the polygonconst isTouching = geometryEngine.touches(polygon, line); within
Indicates if one geometry is within another geometry.
- Signature
-
within (innerGeometry: GeometryUnion, outerGeometry: GeometryUnion): boolean
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| innerGeometry | The base geometry that is tested for the "within" relationship to the other geometry. | | |
| outerGeometry | The comparison geometry that is tested for the "contains" relationship to the other geometry. | |
- Returns
- boolean
Returns
trueifinnerGeometryis withinouterGeometry.
Example
// returns true if a geometry is completely within anotherconst isWithin = geometryEngine.within(polygon, boundaryPolygon); disjoint
Indicates if one geometry is disjoint (doesn't intersect in any way) with another geometry.
- Signature
-
disjoint (geometry1: GeometryUnion, geometry2: GeometryUnion): boolean
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry1 | The base geometry that is tested for the "disjoint" relationship to the other geometry. | | |
| geometry2 | The comparison geometry that is tested for the "disjoint" relationship to the other geometry. | |
- Returns
- boolean
Returns
trueifgeometry1andgeometry2are disjoint (don't intersect in any way).
Example
// returns true if a geometry is not contained in another.// operates the opposite of containsconst isDisjointed = geometryEngine.disjoint(polygon, boundaryPolygon); overlaps
Indicates if one geometry overlaps another geometry.
- Signature
-
overlaps (geometry1: GeometryUnion, geometry2: GeometryUnion): boolean
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry1 | The base geometry that is tested for the "overlaps" relationship with the other geometry. | | |
| geometry2 | The comparison geometry that is tested for the "overlaps" relationship with the other geometry. | |
- Returns
- boolean
Returns
trueif the two geometries overlap.
Example
// returns true if one geometry overlaps another,// but is not contained or disjointedconst isOverlapping = geometryEngine.overlaps(polygon, boundaryPolygon); relate
Indicates if the given DE-9IM relation is true for the two geometries.
- Signature
-
relate (geometry1: GeometryUnion, geometry2: GeometryUnion, relation: string): boolean
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry1 | The first geometry for the relation. | | |
| geometry2 | The second geometry for the relation. | | |
| relation | 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: | |
- Returns
- boolean
Returns
trueif the relation of the input geometries is accurate.
Example
// returns true if the polygon geometry completely// contains the polyline based on the DE-9IM stringconst isRelated = geometryEngine.relate(polygon, polyline, "TTTFFTFFT"); isSimple
Indicates if the given geometry is non-OGC topologically simple. No polygon rings self-intersect. Polylines paths that self-intersect are considered simple.
- Signature
-
isSimple (geometry: GeometryUnion): boolean
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry | The input geometry. | |
- Returns
- boolean
Returns
trueif the geometry is topologically simple.
Example
// returns true if given geometry is simpleconst simple = geometryEngine.isSimple(polyline); simplify
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.
- Signature
-
simplify (geometry: GeometryUnion): GeometryUnion
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry | The geometry to be simplified. | |
- Returns
- GeometryUnion
The simplified geometry.
Example
// Topologically simplifies a geometryconst simplified = geometryEngine.simplify(polyline);console.log(geometryEngine.isSimple(simplified)); // true convexHull
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.
- Signature
-
convexHull (geometries: GeometryUnion | GeometryUnion[], merge: boolean): GeometryUnion | GeometryUnion[]
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometries | 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 | = false - Indicates whether to merge the output into a single geometry (usually a polygon). | |
- Returns
- 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).
Examples
// returns the convex hull of a multipoint as a single polygonconst hull = geometryEngine.convexHull(multipoint);// returns the convex hull of an array of points as a single polygonconst [ hull ] = geometryEngine.convexHull([ pointA, pointB, pointC ], true);// returns the convex hull for each input line geometry as three polygonsconst hulls = geometryEngine.convexHull([ lineA, lineB, lineC ]);// returns the convex hull for all input line geometries as a single polygonconst [ hull ] = geometryEngine.convexHull([ lineA, lineB, lineC ], true);// returns the convex hull for all input geometries as a single polygonconst [ hull ] = geometryEngine.convexHull([ point, line, polygon ], true); difference
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.
- Signature
-
difference (inputGeometry: GeometryUnion | GeometryUnion[], subtractor: GeometryUnion): GeometryUnion | GeometryUnion[]
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| inputGeometry | The input geometry to subtract from. | | |
| subtractor | The geometry being subtracted from inputGeometry. | |
- Returns
- GeometryUnion | GeometryUnion[]
Returns the geometry of inputGeometry minus the subtractor geometry.
Example
// Creates a new geometry based on the// difference of the twoconst geometry = geometryEngine.difference(boundaryPolygon, buffers); symmetricDifference
Creates the symmetric difference of two geometries. The symmetric difference includes the parts that are in either of the sets, but not in both.
- Signature
-
symmetricDifference (leftGeometry: GeometryUnion | GeometryUnion[], rightGeometry: GeometryUnion): GeometryUnion | GeometryUnion[]
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| leftGeometry | One of the Geometry instances in the XOR operation. | | |
| rightGeometry | One of the Geometry instances in the XOR operation. | |
- Returns
- GeometryUnion | GeometryUnion[]
The symmetric differences of the two geometries.
Example
// Creates a new geometry based on the// symmetric difference of the twoconst geometry = geometryEngine.symmetricDifference(boundaryPolygon, buffers); intersect
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.
- See also
- Signature
-
intersect (geometry1: GeometryUnion | GeometryUnion[], geometry2: GeometryUnion): GeometryUnion | GeometryUnion[]
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry1 | The input geometry or array of geometries. | | |
| geometry2 | The geometry to intersect with geometry1. | |
- Returns
- GeometryUnion | GeometryUnion[]
The intersections of the geometries.
Example
// Creates a new geometry from the intersection// of the two geometriesconst intersecting = geometryEngine.intersect(boundaryPolygon, buffers); union
All inputs must be of the same type of geometries and share one spatial reference.
- Signature
-
union (geometries: GeometryUnion[]): GeometryUnion
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometries | An array of Geometries to union. | |
- Returns
- GeometryUnion
The union of the geometries.
Example
// pt1 and pt2 are Point geometries to union togetherconst union = geometryEngine.union([pt1, pt2]); offset
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.
- Signature
-
offset (geometry: GeometryUnion | GeometryUnion[], offsetDistance: number, offsetUnit?: number | LinearUnit, joinType?: any, bevelRatio?: number, flattenError?: number): GeometryUnion | GeometryUnion[]
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry | The geometries to offset. | | |
| offsetDistance | 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 | Measurement unit of the offset distance. Defaults to the units of the input geometries. | | |
| joinType | The join type. | | |
| bevelRatio | Applicable when | | |
| flattenError | Applicable when | |
- Returns
- GeometryUnion | GeometryUnion[]
The offset geometries.
Example
// Creates a new geometry offset from the provided geometryconst offset = geometryEngine.offset(boundaryPolygon, 500, "meters", "round"); buffer
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 buffer().
- See also
- Signature
-
buffer (geometry: GeometryUnion | GeometryUnion[], distance: number, unit?: number | LinearUnit, toUnionResults?: boolean): Polygon | Polygon[]
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry | The buffer input geometry.
The | | |
| distance | The specified distance(s) for buffering. The | | |
| unit | Measurement unit of the distance(s). Defaults to the units of the input geometries. | | |
| toUnionResults | = false - Determines whether the output geometries should be unioned into a single polygon. | |
Example
// Buffer point by 1000 feetconst ptBuff = geometryEngine.buffer(point, 1000, "feet"); geodesicBuffer
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 buffer().
- Signature
-
geodesicBuffer (geometry: GeometryUnion | GeometryUnion[], distance: number | number[], unit?: number | LinearUnit, toUnionResults?: boolean): Polygon | Polygon[]
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry | The buffer input geometry.
The | | |
| distance | The specified distance(s) for buffering. The | | |
| unit | Measurement unit of the distance(s). Defaults to the units of the input geometries. | | |
| toUnionResults | = false - Determines whether the output geometries should be unioned into a single polygon. | |
Example
// point is a Point geometryconst ptBuff = geometryEngine.geodesicBuffer(point, 1000, "kilometers"); // Buffer point by 1000km nearestCoordinate
Finds the coordinate of the geometry that is closest to the specified point.
- Signature
-
nearestCoordinate (geometry: GeometryUnion, inputPoint: Point): NearestPointResult<Point>
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry | The geometry to consider. | | |
| inputPoint | The point used to search the nearest coordinate in the geometry. | |
- Returns
- NearestPointResult<Point>
Returns an object containing the nearest coordinate.
nearestVertex
Finds the vertex on the geometry nearest to the specified point.
- Signature
-
nearestVertex (geometry: GeometryUnion, inputPoint: Point): NearestPointResult<Point>
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry | The geometry to consider. | | |
| inputPoint | The point used to search the nearest vertex in the geometry. | |
- Returns
- NearestPointResult<Point>
Returns an object containing the nearest vertex.
Example
// Finds the nearest vertex of the polygon to the input pointconst { coordinate, distance} = geometryEngine.nearestVertex(boundaryPolygon, point); nearestVertices
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.
- Signature
-
nearestVertices (geometry: GeometryUnion, inputPoint: Point, searchRadius: number, maxVertexCountToReturn: number): NearestPointResult<Point>[]
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry | The geometry to consider. | | |
| inputPoint | The point from which to measure. | | |
| searchRadius | The distance to search from the inputPoint in the units of the view's spatial reference. | | |
| maxVertexCountToReturn | The maximum number of vertices to return. | |
- Returns
- NearestPointResult<Point>[]
An array of objects containing the nearest vertices within the given
searchRadius.
Example
// Returns an array of the nearest verticesconst nearest = geometryEngine.nearestVertices(boundaryPolygon, point, 500, 2); rotate
Rotates a geometry counterclockwise by the specified number of degrees. Rotation is around the centroid, or a given rotation point.
- Signature
-
rotate (geometry: GeometryUnion, angle: number, rotationOrigin?: Point | null): GeometryUnion
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry | The geometry to rotate. | | |
| angle | The rotation angle in degrees. | | |
| rotationOrigin | Point to rotate the geometry around. Defaults to the centroid of the geometry. | |
- Returns
- GeometryUnion
The rotated geometry.
Example
// Returns a geometry rotated by 45 degreesconst geometry = geometryEngine.rotate(boundaryPolygon, 45); flipHorizontal
Flips a geometry on the horizontal axis. Can optionally be flipped around a point.
- Signature
-
flipHorizontal (geometry: GeometryUnion, flipOrigin?: Point | null | undefined): GeometryUnion
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry | The input geometry to be flipped. | | |
| flipOrigin | Point to flip the geometry around. Defaults to the centroid of the geometry. | |
- Returns
- GeometryUnion
The flipped geometry.
Example
// Returns a geometry flipped horizontallyconst geometry = geometryEngine.flipHorizontal(boundaryPolygon); flipVertical
Flips a geometry on the vertical axis. Can optionally be flipped around a point.
- Signature
-
flipVertical (geometry: GeometryUnion, flipOrigin?: Point | null | undefined): GeometryUnion
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry | The input geometry to be flipped. | | |
| flipOrigin | Point to flip the geometry around. Defaults to the centroid of the geometry. | |
- Returns
- GeometryUnion
The flipped geometry.
Example
// Returns a geometry flipped verticallyconst geometry = geometryEngine.flipVertical(boundaryPolygon); generalize
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.
- Signature
-
generalize (geometry: GeometryUnion, maxDeviation: number, removeDegenerateParts?: boolean, maxDeviationUnit?: number | LinearUnit): GeometryUnion
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry | The input geometry to be generalized. | | |
| maxDeviation | The maximum allowed deviation from the generalized geometry to the original geometry. | | |
| removeDegenerateParts | When | | |
| maxDeviationUnit | Measurement unit for maxDeviation. Defaults to the units of the input geometry. | |
- Returns
- GeometryUnion
The generalized geometry.
Example
// Returns a generalized geometryconst geometry = geometryEngine.generalize(boundaryPolygon, 2.5, true, "miles"); densify
Densify geometries by plotting points between existing vertices.
- See also
- Signature
-
densify (geometry: GeometryUnion, maxSegmentLength: number, maxSegmentLengthUnit?: number | LinearUnit): GeometryUnion
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry | The geometry to be densified. | | |
| maxSegmentLength | The maximum segment length allowed. Must be a positive value. | | |
| maxSegmentLengthUnit | Measurement unit for maxSegmentLength. Defaults to the units of the input geometry. | |
- Returns
- GeometryUnion
The densified geometry.
Example
// Returns a densified geometryconst geometry = geometryEngine.densify(boundaryPolygon, 25); geodesicDensify
Returns a geodetically densified version of the input geometry. Use this function to draw the line(s) of the geometry along great circles.
- Signature
-
geodesicDensify (geometry: Polyline | Polygon, maxSegmentLength: number, maxSegmentLengthUnit?: LinearUnit): GeometryUnion
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry | A polyline or polygon to densify. | | |
| maxSegmentLength | The maximum segment length allowed (in meters if a | | |
| maxSegmentLengthUnit | Measurement unit for | |
- Returns
- GeometryUnion
Returns the densified geometry.
Example
// lineGeom is a line geometryconst densifiedGeom = geometryEngine.geodesicDensify(lineGeom, 10000); planarArea
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.
- Signature
-
planarArea (geometry: Polygon, unit?: number | AreaUnit): number
Parameters
- Returns
- number
The area of the input geometry.
Example
// Returns the numeric area of the given polygonconst area = geometryEngine.planarArea(boundaryPolygon, "square-miles"); planarLength
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.
- Signature
-
planarLength (geometry: GeometryUnion, unit?: number | LinearUnit): number
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry | The input geometry. | | |
| unit | Measurement unit of the return value. Defaults to the units of the input geometries. | |
- Returns
- number
The length of the input geometry.
Example
// Returns the numeric length of the given lineconst length = geometryEngine.planarLength(riverGeometry, "miles"); geodesicArea
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.
- Signature
-
geodesicArea (geometry: Polygon, unit?: number | AreaUnit): number
Parameters
- Returns
- number
Area of the input geometry.
Example
// Returns the numeric geodesic area of the given polygonconst area = geometryEngine.geodesicArea(boundaryPolygon, "square-miles"); geodesicLength
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.
- Signature
-
geodesicLength (geometry: GeometryUnion, unit?: number | LinearUnit): number
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| geometry | The input geometry. | | |
| unit | Measurement unit of the return value. Defaults to the units of the input geometry. | |
- Returns
- number
Length of the input geometry.
Example
// Returns the numeric geodesic length of the given lineconst length = geometryEngine.geodesicLength(riverGeometry, "miles"); intersectLinesToPoints
- Since
- ArcGIS Maps SDK for JavaScript 4.25
Returns an array of points at the intersecting locations of two input polylines. Use intersect() for all other geometry intersect operations.
- See also
- Signature
-
intersectLinesToPoints (line1: Polyline, line2: Polyline): Point[]
Parameters
- Returns
- Point[]
The point intersections of the input polylines.
Example
// Creates an array of points for the intersections of the input linesconst intersections = geometryEngine.intersectLinesToPoints(line1, line2);