# Work with Geometries

A geometry is the spatial component of a feature—it defines the feature's location and shape.

There are four types of geometry in VertiGIS Studio Workflow: point, polyline, polygon, and extent. Every geometry has a `type` property that you can use to access the geometry's type. The `type` property is a string with possible values "point", "polyline", "polygon", and "extent".

A feature does not have to have a geometry, but without a geometry, the feature cannot be represented on a map. To accurately represent a geometry on a map, the geometry's spatial reference should be the same as the map's spatial reference. Every geometry has a `spatialReference` property that you can use to access the geometry's spatial reference.

Each geometry type has additional properties that are specific to that type, for example, points have `x` and `y` properties that you can use to access the point's coordinates. The following table lists the properties for each type of geometry.

Properties of Geometries

 Type of Geometry Property Type Value All geometry types `spatialReference` `type` esri.SpatialReference (3.x, 4.x)* The spatial reference of the geometry The type of geometry: "point", "polyline", "polygon", or "extent" Point `x` `y` The x-coordinate of the point The y-coordinate of the point Polyline `paths` Number[][][] A collection of line segments that make up the polyline Polygon `rings` Number[][][] A collection of rings that make up the polygon Extent `center` `maxX` `maxY` `minX` `minY` esri.Point (3.x, 4.x)* The extent's center point The extent's maximum x-coordinate The extent's maximum y-coordinate The extent's minimum x-coordinate The extent's minimum y-coordinate

* VertiGIS Studio Workflow uses different versions of Esri's ArcGIS API for JavaScript depending on the type of host application. See Underlying Technologies for information.

Esri Geometry 3.x 4.x

## Pass Geometry to a Workflow as an Input

One or more geometries may be retrieved through means outside of the workflow. In this case, the geometries must be passed to a workflow as an input. For more information on the ability of your host application to pass geometries as inputs at run-time, note the Run-Time Capability column in Common methods of hosting workflows that take inputs. For more information on how to host and run a workflow that takes a run-time input, see the following resources:

## Access a Feature’s Geometry

To access the geometry of a particular feature in a feature set, you can either use an expression or an activity.

### Use an Expression to Access a Feature’s Geometry

When you use an expression to access a feature's geometry, the term that you use depends on which activity the feature set came from:

• Query Layer: The Query Layer activity returns a feature set in the `results` output. The Query Layer activity also has a `features` output containing a collection of the features. Both outputs give you access to all the features in the feature set. Using the `features` output is shorter. In either case, the features are indexed numerically starting at zero: `features`, `features`, `features`, and so on.

To access the geometry of a particular feature, use a term similar to one of the following in an expression:

`\$query1.results.features.geometry`
or
`\$query1.features.geometry`

If you try to access the geometry in a feature that does not have a geometry, `\$query1.results.features.geometry` and `\$query1.features.geometry` will be Null.

• Create Feature Set, Get Feature Set From JSON: The Create Feature Set and Get Feature Set From JSON activities return a feature set in the `featureSet` output. The features are indexed numerically starting at zero: `features`, `features`, `features`, and so on.

To access the geometry of a particular feature, use a term similar to the following in an expression:

`\$featureSet1.featureSet.features.geometry`

If you try to access the geometry in a feature that does not have a geometry, `\$featureSet1.featureSet.features.geometry` will be Null.

### Use an Activity to Access a Feature’s Geometry

The Get Feature Geometry activity gets the geometry for a particular feature. To configure the activity:

1. In the Features input, specify the feature using one of the forms described in Use an Expression to Access a Feature or its Components.

For example, if you got the feature set from JSON, set the Features input to an expression similar to: `=\$featureSet1.featureSet.features`

You will be able to access the feature's geometry using a term similar to the following:

`\$getFeatureGeometry1.geometry`

You can get all the geometries from a feature set by using the Get Feature Set Geometries activity.

## Set the Geometry for a Feature

The Set Feature Geometry activity assigns a geometry to a feature. To use this activity, the geometry must already exist in the workflow.

To configure the Set Feature Geometry activity:

1. In the Feature input, specify the feature using one of the forms described in Use an Expression to Access a Feature or its Components.

For example, if you got the feature set from JSON, set the Features input to an expression similar to: `=\$featureSet1.featureSet.features`

2. Set the Geometry input to the geometry that you want to assign to the feature.

For example, if the geometry was output by the Project Geometry activity, set the Geometry input to an expression similar to: `=\$projectGeometry1.geometry`

## Create a Point

You can create a point geometry by using the Create Point activity. To configure the Create Point activity, you specify the point's x- and y- coordinates and its spatial reference. If you leave the Spatial Reference input blank, WKID 4326 is used.

The point is returned in the `point` output. To access the `center` output, use a term similar to the following in an expression:

`\$point1.point`

## Select a Geometry

The Geometry Picker Form Element allows the user to draw one or more geometries on the currently selected map.

The Geometry Picker form element has one output, `value`, which is of type `GeometryRef`. To access the geometry output, use a term similar to the following in an expression:

`\$form1.state.geometryPicker1.value.geometry`

## Buffer a Geometry

Buffering geometries creates a zone of interest around the geometries. This is useful for finding features within a certain distance of the geometries.

VertiGIS Studio Workflow has two activities for buffering geometries: Buffer Geometry and Buffer Geometry (server). Both buffering activities buffer one or more input geometries. The buffer that is output by these activities is itself a geometry, specifically, a polygon.

The Buffer Geometry activity uses Esri's client-side asynchronous geometry engine (3.x 4.x) to perform the buffering, while the Buffer Geometry (server) activity uses Esri's geometry service (3.x 4.x). Because the geometry engine used by the Buffer Geometry activity runs on the client, the Buffer Geometry activity works when the user's device has intermittent connectivity to the network. For the Buffer Geometry (server) activity to work, the user's device must have network connectivity.

The Buffer Geometry (server) activity provides more options than the Buffer Geometry activity. For example, Buffer Geometry (server) allows you to control the spatial references used for the operation.

To configure the buffering activities, you use the Geometry input to specify the geometries to buffer and the Distance input to specify the width of the buffer. If the Distance input's units are different than the units of the input geometries, you must specify Distance's units in the Units input.

When you use one of the buffering activities to buffer multiple geometries, you can specify whether to combine the individual output polygons into a single polygon. To combine the polygons, set the Union input to `true`. If you leave Union blank or set it to `false`, the activities return a separate polygon for each input geometry.

The buffering activities have two outputs:

• `geometry`:

• If you input a single geometry, the `geometry` output is the buffer polygon.
• If you input multiple geometries and Union is `false`, the `geometry` output is the buffer polygon for the first input geometry.
• If you input multiple geometries and Union is `true`, the `geometry` output is the polygon formed by unioning all the individual buffer polygons.

To access the `geometry` output, use a term similar to the following in an expression:

```\$buffer1.geometry ```
• `results`:

• If you input a single geometry, the `results` output is a collection of one buffer polygon.
• If you input multiple geometries and Union is `false`, the `results` output is a collection of buffer polygons, one for each input geometry.
• If you input multiple geometries and Union is `true`, the `results` output is a collection of one polygon, the polygon formed by unioning all the individual buffer polygons.

To access the `results` output, use a term similar to the following in an expression:

```\$buffer1.results ```

Because the `results` output is a collection, you can access individual polygons in the collection using a term similar to this:

`\$buffer1.results`

## Get the Centroid of a Geometry

A centroid is a geometric center point that is calculated from one or more geometries. Centroids are useful for optimizing the distribution of resources relative to the input geometries.

The Get Centroid activity calculates the centroid of one or more input geometries. To configure the Get Centroid activity, you use the Geometry input to specify the geometries whose centroid you want to calculate. If you specify a single geometry, the activity calculates the centroid for that geometry. If you specify multiple geometries, the activity calculates the centroid for the group of geometries.

The Get Centroid activity has one output, `centroid`, which is a point. To access the `centroid` output, use a term similar to the following in an expression:

`\$centroid1.centroid`

## Get the Extent of a Geometry

The extent of a group of geometries is the minimum and maximum coordinates of the smallest bounding rectangle that encloses the geometries. You can use the extent to zoom the map to particular geometries.

The Get Geometry Extent activity calculates the extent of one or more input geometries. To configure the Get Geometry Extent activity, you use the Geometry input to specify the geometries whose extent you want to calculate. If you specify a single geometry, the activity calculates the extent of that geometry. If you specify multiple geometries, the activity calculates the extent of the group of geometries.

The Get Geometry Extent activity has two outputs, `extent` and `center`. The `extent` output is the extent of the input geometries, which is usually a polygon. Points are the exception—the extent of a point is Null.

To access the `extent` output, use a term similar to the following in an expression:

`\$geometryExtent1.extent`

The `center` output is the extent's center point. To access the `center` output, use a term similar to the following in an expression:

`\$geometryExtent1.center`