1. Select an operation
The first step to performing a geometry analysis is to select an operation. Operations are categorized into the following groups based on the functionality they provide:
- Spatial relationships: Determine the relationship between geometries.
- Geometric calculation: Calculate and create new geometries from existing geometries
- Length and area: Measure length, area, or distance
- Projection: Project a geometry to a new spatial reference.
2. Create geometries
After you have selected the operation, the next step is to create one or more geometries with the same spatial reference. Geometry data is typically created through user interaction or by accessing features in a hosted feature layer.
In general, There are two different ways to create geometry data for analysis:
- Create new geometries programmatically. To learn more go to Geometry Objects.
- Access existing features in a hosted feature layer. To learn more go to Data hosting > query features.
Below is an example of creating geometries programmatically using coordinates:
// create a point
const point = Geometry.fromJSON({
type: "point",
x: -3.83565819758263,
y: 40.408142411681396,
spatialReference: SpatialReference.WGS84,
})
// create a polyline
const line = Geometry.fromJSON({
type: "polyline",
paths: [
[
[-3.7611339616121, 40.39446064625446],
[-3.6992634462656, 40.42167509407656],
[-3.65292023890635, 40.39553309352415],
],
],
spatialReference: SpatialReference.WGS84,
3. Perform the analysis
After you have created geometries, you can use them as parameters to one or more geometric operations.
The example below demonstrates how to pass the created geometries to client API operations:
// buffer the input point
const buffer = geometryEngine.geodesicBuffer(point, 1000, "meters")
// Return the geodesic area of the new buffer
const area = geometryEngine.geodesicArea(buffer)
console.log("The area is:" + area)
// Determine if the buffer area and polyline intersect
const intersects = geometryEngine.intersects(buffer, line)
console.log("The geometries intersect: " + intersects)