# Geometry Functions

The following functions allow you to create and evaluate geometry objects. Please note that if your input has more than one geometry, they must have the same spatial reference.

`$feature`

) as input to any geometry function will yield results only as precise as the view scale. Therefore, results returned from geometry operations in the visualization and labeling profiles may be different at each scale level. Use these functions at your discretion within these contexts.### Units reference

If a function references units, then any of the values described in the table below may be used. Units can either be identified as a number or a string. If the value is a number, it will be based on the standard referenced here. Where appropriate, linear and areal units may be used interchangeably. For example, if calculating an area and `meters`

is specified as the unit, then the unit will be treated as `square-meters`

and vice versa.

Unit value | Alternate values |

*`acres` | `acre` , `ac` |

`feet` | `foot` , `ft` , `square-feet` , `square-foot` , `squarefeet` , `squarefoot` |

*`hectares` | `hectare` , `ha` |

`kilometers` | `kilometer` , `km` , `square-kilometers` , `square-kilometer` , `squarekilometers` , `squarekilometer` |

`miles` | `mile` , `square-miles` , `square-mile` , `squaremiles` , `squaremile` |

`nautical-miles` | `nautical-mile` , `square-nautical-miles` , `square-nautical-mile` , `squarenauticalmiles` , `squarenauticalmile` |

`meters` | `meter` , `m` , `square-meters` , `square-meter` , `squaremeters` , `squaremeter` |

`yards` | `yard` , `yd` , `square-yards` , `square-yard` , `squareyards` , `squareyard` |

* Indicates the unit may only be used for calculating areas.

## Angle

This function has 2 signatures:

### Angle( pointA, pointB ) -> `Number`

Returns the arithmetic angle of a line between two points in degrees (0 - 360). The angle is measured in a counter-clockwise direction relative to east. For example, an angle of 90 degrees points due north.

Only the x-y plane is considered for the measurement. Any z-coordinates are ignored. Point features can be used instead of any or both Point geometries. *If the points are identical, then an angle of 0 degrees is returned.*

See bearing.

Name | Type | Description |
---|---|---|

pointA | Point | Feature | The first point used to calculate the angle. |

pointB | Point | Feature | The second point used to calculate the angle. |

#### Returns: Number

#### Example

###### Returns the angle from a point to the feature, in degrees

```
var pointA = Point({ "x":976259, "y":8066511, "spatialReference": { "wkid": 3857 } });
Angle(pointA,$feature)
```

### Angle( pointA, pointB, pointC ) -> `Number`

Returns the arithmetic angle of a line between three points in degrees (0 - 360). The angle is measured around `pointB`

in a counter-clockwise direction, from `pointA`

to `pointC`

.

Only the x-y plane is considered for the measurement. Any z-coordinates are ignored. Point features can be used instead of either or all Point geometries. *If the points are identical, then an angle of 0 or 180 degrees is returned (depending internal arithmetic).*

See bearing.

Name | Type | Description |
---|---|---|

pointA | Point | Feature | The first point used to calculate the angle. |

pointB | Point | Feature | The second point used to calculate the angle. |

pointC | Point | Feature | The third point used to calculate the angle. |

#### Returns: Number

#### Example

###### Returns the angle between two points around the feature, in degrees

```
var pointA = Point({ "x":976259, "y":8066511, "spatialReference": { "wkid": 3857 } });
var pointC = Point({ "x":308654, "y":9005421, "spatialReference": { "wkid": 3857 } });
Angle(pointA,$feature,pointC)
```

## Area

### Area( geometry, unit? ) -> `Number`

Returns the area of the input geometry or FeatureSet in the given units. This is a planar measurement using Cartesian mathematics.**Be aware that using $feature as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.** Read more here.

Name | Type | Description |
---|---|---|

geometry | Polygon | Feature | FeatureSet | Points[] | The Polygon or FeatureSet for which to calculate the planar area. |

unit | Text | Number | `optional` Measurement unit of the return value. Use one of the string values listed in the Units reference. |

#### Returns: Number

#### Example

###### Returns the area of the feature in square meters

`Area($feature, 'square-meters')`

###### Returns the area of the layer in square kilometers

`Area($layer, 'square-kilometers')`

## AreaGeodetic

### AreaGeodetic( geometry, unit? ) -> `Number`

Returns the geodetic area of the input geometry or FeatureSet in the given units. This is more reliable measurement of area than Area() because it takes into account the Earth's curvature. Support is limited to geometries with a Web Mercator (wkid 3857) or a WGS 84 (wkid 4326) spatial reference.**Be aware that using $feature as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.** Read more here.

Name | Type | Description |
---|---|---|

geometry | Polygon | Feature | FeatureSet | Points[] | The Polygon or FeatureSet for which to calculate the geodetic area. |

unit | Text | Number | `optional` Measurement unit of the return value. Use one of the string values listed in the Units reference. |

#### Returns: Number

#### Example

###### Returns the geodetic area of the feature in square meters

`AreaGeodetic($feature, 'square-meters')`

###### Returns the geodetic area of the layer in square kilometers

`AreaGeodetic($layer, 'square-kilometers')`

## Bearing

This function has 2 signatures:

### Bearing( pointA, pointB ) -> `Number`

Returns the geographic angle of a line between two points in degrees (0 - 360). The bearing is measured in a clockwise direction relative to north. For example, a bearing of 225 degrees represents a southwest orientation.

Only the x-y plane is considered for the measurement. Any z-coordinates are ignored. Point features can be used instead of either or both Point geometries. *If the points are identical, then an angle of 0 is returned.*

See also angle.

Name | Type | Description |
---|---|---|

pointA | Point | Feature | The first point used to calculate the bearing. |

pointB | Point | Feature | The second point used to calculate the bearing. |

#### Returns: Number

#### Example

###### Returns the bearing from a point to the feature, in degrees

```
var pointA = Point({ "x":976259, "y":8066511, "spatialReference": { "wkid": 3857 } });
Bearing(pointA,$feature)
```

### Bearing( pointA, pointB, pointC ) -> `Number`

Returns the geographic angle of a line between three points in degrees (0 - 360). The bearing is measured around `pointB`

in a clockwise direction, from `pointA`

to `pointC`

.

Only the x-y plane is considered for the measurement. Any z-coordinates are ignored. Point features can be used instead of any or all Point geometries. *If the points are identical, then an angle of 0 or 180 degrees is returned (depending internal arithmetic).*

See also angle.

Name | Type | Description |
---|---|---|

pointA | Point | Feature | The first point used to calculate the bearing. |

pointB | Point | Feature | The second point used to calculate the bearing. |

pointC | Point | Feature | The third point used to calculate the bearing. |

#### Returns: Number

#### Example

###### Returns the bearing between two points around the feature, in degrees

```
var pointA = Point({ "x":976259, "y":8066511, "spatialReference": { "wkid": 3857 } });
var pointC = Point({ "x":308654, "y":9005421, "spatialReference": { "wkid": 3857 } });
Bearing(pointA,$feature,pointC)
```

## Buffer

### Buffer( geometry, distance, unit? ) -> `Polygon`

Returns the planar (or Euclidean) buffer at a specified distance around the input geometry. This is a planar measurement using Cartesian mathematics.**Be aware that using $feature as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.** Read more here.

Name | Type | Description |
---|---|---|

geometry | Geometry | Feature | The geometry to buffer. |

distance | Number | The distance to buffer from the geometry. |

unit | Text | Number | `optional` Measurement unit of the buffer `distance` . Use one of the string values listed in the Units reference. |

#### Returns: Polygon

#### Example

###### Returns a polygon representing a 1/2-mile buffer around the input geometry

`Buffer($feature, 0.5, 'miles')`

## BufferGeodetic

### BufferGeodetic( geometry, distance, unit? ) -> `Polygon`

Returns the geodetic buffer at a specified distance around the input geometry. This is a geodesic measurement, which calculates distances on an ellipsoid. Support is limited to geometries with a Web Mercator (wkid 3857) or a WGS 84 (wkid 4326) spatial reference.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

geometry | Geometry | Feature | The geometry to buffer. |

distance | Number | The distance to buffer from the geometry. |

unit | Text | Number | `optional` Measurement unit of the buffer `distance` . Use one of the string values listed in the Units reference. |

#### Returns: Polygon

#### Example

###### Returns a polygon representing a 1/2-mile buffer around the input geometry

`BufferGeodetic($feature, 0.5, 'miles')`

## Centroid

### Centroid( points ) -> `Point`

Returns the centroid of the input geometry.

Name | Type | Description |
---|---|---|

points | Polygon | Feature | Point[] | The polygon or array of points composing a polygon. |

#### Returns: Point

#### Example

###### Returns the centroid of the given polygon

```
Centroid($feature)
```

###### Returns the centroid of the given polygon ring

```
var ringPoints = Geometry($feature).rings[0];
Centroid(ringPoints);
```

## Clip

### Clip( geometry, envelope ) -> `Geometry`

Calculates the clipped geometry from a target geometry by an envelope.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

geometry | Geometry | Feature | The geometry to be clipped. |

envelope | Extent | The envelope used to clip the `geometry` . |

#### Returns: Geometry

#### Example

###### Returns the area of the clipped geometry

```
var envelope = Extent({ ... });
Area(Clip($feature, envelope), 'square-miles');
```

## Contains

This function has 2 signatures:

- Contains( container, insideGeometry ) ->
`Boolean`

- Contains( container, insideFeatures ) ->
`FeatureSet`

### Contains( container, insideGeometry ) -> `Boolean`

Indicates if one geometry contains another geometry. In the graphic below, the red highlight indicates the scenarios where the function will return `true`

.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

container | Geometry | Feature | The geometry that is tested for the 'contains' relationship to `insideGeometry` . Think of this geometry as the potential 'container' of the `insideGeometry` . |

insideGeometry | Geometry | Feature | The geometry that is tested for the 'within' relationship to the `container` . |

#### Returns: Boolean

#### Example

###### Returns true if the feature is contained within the given polygon

```
var container = Polygon({ ... });
Contains(container, $feature);
```

### Contains( container, insideFeatures ) -> `FeatureSet`

Returns features from a FeatureSet that are contained within the input geometry. In the graphic below, the red highlight illustrates the spatial relationships where the function will return features.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

container | Geometry | Feature | The geometry that is tested for the 'contains' relationship to `insideFeatures` . Think of this geometry as the potential 'container' of the `insideFeatures` . |

insideFeatures | FeatureSet | The FeatureSet that is tested for the 'within' relationship to the `container` . |

#### Returns: FeatureSet

#### Example

###### Returns the number of features that are within the given polygon

```
var parcels = FeatureSetByName($map, 'parcels')
var projectArea = $feature;
Count(Contains(projectArea, parcels));
```

## ConvertDirection

### ConvertDirection( input, inputSpec, outputSpec ) -> `Array / Number / Text`

Angles can have several interpretations and can be represented as values or text strings. `ConvertDirection`

can take one input representation and convert it to another. If the conversion cannot be carried out then the script will fail.

Name | Type | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|

input | Array | Number | Text | A raw representation of the bearing. The type of `input` and the values of the `inputSpec` dictate how the input is parsed. |
||||||||||||||||||||||||||||||

inputSpec | Dictionary | Contains information about how to interpret input. See the properties of the inputSpec here.
If the `angleType` and `directionType` are not appropriate for the input, then the conversion will fail. |
||||||||||||||||||||||||||||||

outputSpec | Dictionary | Contains information about how to format the output. See the properties of the outputSpec here. |

#### inputSpec

Name | Type | Description |
---|---|---|

angleType | Text | Describes the input angle unit.Supported Values: `DEGREES` , `DMS` , `RADIANS` , `GONS` , `GRADIANS` |

directionType | Text | Describes the input bearing's meridian and direction. Supported Values: `NORTH` , `SOUTH` , `POLAR` , `QUADRANT` |

#### outputSpec

Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|

angleType | Text | Describes the output angle unit.Supported Values: `DEGREES` , `DMS` , `RADIANS` , `GONS` , `GRADIANS` |
||||||||||||||||||||||||

directionType | Text | Describes the output bearing's meridian and direction. Supported Values: `NORTH` , `SOUTH` , `POLAR` , `QUADRANT` |
||||||||||||||||||||||||

outputType | Text | Controls output type.Supported Values: `value` , `text` If `outputType` is `'text'` , then default padding and delimeters will be used. Optionally, `format` can control order, spacing, padding, and delimeters. If `outputType` is `'value'` , then an array will be produced for `angleType=dms` or `directionType=quadrant` . Otherwise, a number will be returned. |
||||||||||||||||||||||||

format | Text | Controls text formatting. Only used if `outputType` is `text` . Strings of format specifier characters before a decimal point indicate minimum padding (e.g. `DDD -> 000` ). Strings of format characters after a decimal point indicate precision (e.g. `D.DD -> 0.00` ). Full list of supported `format` characters:
`dms` formatting, if the `s` is not used then `m` will round to the nearest minute. Similarly, if `m` is not used then `d` will round. |

#### Returns: Array | Number | Text

#### Example

###### Examples where the `outputType`

is `value`

.

```
ConvertDirection( 30, {directionType:'North', angleType: 'Degrees'}, {directionType:'Quadrant', angleType: 'DMS', outputType: 'value'})
// returns ['N', 30, 0, 0, 'E']
ConvertDirection( 25.99, {directionType:'North', angleType : 'Gradians'}, {directionType:'North', outputType: 'value', angleType : 'Gradians'})
// returns 25.99
ConvertDirection( 1, {directionType:'North', angleType: 'DEGREES'}, {directionType: 'Quadrant', angleType: 'Degrees', outputType: 'value'})
// returns ['N',1,'E']
ConvertDirection( 0.9, {directionType: 'North', angleType: 'degrees'}, {directionType:'North', angleType: 'gradians', outputType: 'value'})
// returns 1.0
ConvertDirection( 180.0, {directionType:'North', angleType: 'degrees'}, {directionType:'North', angleType: 'radians', outputType : 'value'})
// returns PI
```

###### Examples where `outputType`

is `text`

.

```
ConvertDirection( 25.34, {directionType: 'North', angleType: 'DEGREES'}, {directionType:'North', outputType: 'text', format: 'DDDD.D'})
// returns '0025.3'
ConvertDirection( 25.34, {directionType: 'North', angleType: 'DEGREES'}, {directionType:'North', outputType: 'text', format: 'R'})
// returns '0'
ConvertDirection( 25.34, {directionType: 'North', angleType: 'DEGREES'}, {directionType:'North', outputType: 'text', format: '[DD.DD]'})
// returns 'DD.DD'
ConvertDirection( 25.34, {directionType:'North', angleType: 'DEGREES'}, {directionType:'quadrant', outputType: 'text', format: 'P B'})
// returns 'North East'
ConvertDirection( [001,01,59.99], {directionType:'North', angleType: 'DMS'}, {directionType:'North', angleType: 'DMS', outputType: 'text', format: 'dddA mm[B] ssC'})
// returns '001A 02B 00C'
```

## Crosses

This function has 2 signatures:

### Crosses( geometry1, geometry2 ) -> `Boolean`

Indicates if one geometry crosses another geometry. In the graphic below, the red highlight indicates the scenarios where the function will return `true`

.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

geometry1 | Geometry | Feature | The geometry to cross. |

geometry2 | Geometry | Feature | The geometry being crossed. |

#### Returns: Boolean

#### Example

###### Returns true if the feature crosses the given polygon

```
var geom2 = Polygon({ ... });
Crosses($feature, geom2);
```

### Crosses( features, crossingGeometry ) -> `FeatureSet`

Returns features from a FeatureSet that cross the input geometry. In the graphic below, the red highlight illustrates the spatial relationships where the function will return features.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

features | FeatureSet | The features to test the crosses relationship with the input `crossingGeometry` . |

crossingGeometry | Geometry | Feature | The geometry being crossed. |

#### Returns: FeatureSet

#### Example

###### Returns the number of features in the FeatureSet that cross the given polygon

```
var geom2 = Polygon({ ... });
Count( Crosses($layer, geom2) );
```

## Cut

### Cut( geometry, cutter ) -> `Geometry[]`

Splits the input Polyline or Polygon where it crosses a cutting Polyline. For Polylines, all resulting left cuts are grouped together in the first Geometry. Right cuts and coincident cuts are grouped in the second Geometry. Each undefined cut, along with any uncut parts, are output as separate Polylines.

For Polygons, all resulting left cuts are grouped in the first Polygon, all right cuts are grouped in the second Polygon, and each undefined cut, along with any left-over 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.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

geometry | Polyline | Polygon | Feature | The geometry to cut. |

cutter | Polyline | Feature | The Polyline used to cut the `geometry` . |

#### Returns: Geometry[]

#### Example

###### Cuts the feature's geometry with the given polyline

```
var cutter = Polyline({ ... });
Cut($feature, cutter));
```

## Densify

### Densify( inputGeometry, maxSegmentLength, unit? ) -> `Geometry`

Densifies geometries by inserting vertices to create segments no longer than the specified interval. `$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

inputGeometry | Geometry | Feature | The input geometry to be densified. |

maxSegmentLength | Number | The maximum segment length allowed. Must be a positive value. |

unit | Text | Number | `optional` Measurement unit for maxSegmentLength. Defaults to the units of the input geometry. Use one of the string values listed in the Units reference. |

#### Returns: Geometry

#### Example

###### Returns the densified geometry with a maximum segment length of 10 m

```
var maxLength = 10;
Densify($feature, maxLength, 'meters');
```

## DensifyGeodetic

### DensifyGeodetic( inputGeometry, maxSegmentLength, unit? ) -> `Geometry`

Geodesically densifies geometries by inserting vertices to create segments no longer than the specified interval. `$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

inputGeometry | Geometry | Feature | The input geometry to be densified. |

maxSegmentLength | Number | The maximum segment length allowed. Must be a positive value. |

unit | Text | Number | `optional` Measurement unit for maxSegmentLength. Defaults to the units of the input geometry. Use one of the string values listed in the Units reference. |

#### Returns: Geometry

#### Example

###### Returns the densified geometry with a maximum segment length of 10000

```
DensifyGeodetic($feature, 10000, 'meters');
```

## Difference

### Difference( inputGeometry, subtractor ) -> `Geometry`

Performs the topological difference operation for the two geometries. The resultant geometry comes from `inputGeometry`

, not the `subtractor`

. The dimension of `subtractor`

has to be equal to or greater than that of `inputGeometry`

.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

inputGeometry | Geometry | Feature | The input geometry from which to subtract. |

subtractor | Geometry | Feature | The geometry to subtract from `inputGeometry` . |

#### Returns: Geometry

#### Example

###### Subtracts the given polygon area from the feature.

```
var subtractor = Polygon({ ... });
Difference($feature, subtractor);
```

## Disjoint

### Disjoint( geometry1, geometry2 ) -> `Boolean`

Indicates if one geometry is disjoint (doesn't intersect in any way) with another geometry. In the table below, the red highlight indicates that the function would return `true`

with the specified geometries.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

geometry1 | Geometry | Feature | The base geometry that is tested for the 'disjoint' relationship to `geometry2` . |

geometry2 | Geometry | Feature | The comparison geometry that is tested for the 'disjoint' relationship to `geometry1` . |

#### Returns: Boolean

#### Example

###### Returns true if the geometries don't intersect

```
var geom2 = Polygon({ ... });
Disjoint($feature, geom2);
```

## Distance

### Distance( geometry1, geometry2, unit? ) -> `Number`

Returns the planar distance between two geometries in the given units. This is a planar measurement using Cartesian mathematics.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

geometry1 | Geometry | Feature | Point[] | The geometry used to measure the distance from `geometry2` . |

geometry2 | Geometry | Feature | Point[] | The geometry used to measure the distance from `geometry1` . |

unit | Text | Number | `optional` Measurement unit of the return value. Use one of the string values listed in the Units reference. |

#### Returns: Number

#### Example

###### Returns the distance between two geometries in meters

```
var geom2 = Point({ ... });
Distance($feature, geom2, 'meters')
```

## DistanceGeodetic

### DistanceGeodetic( point1, point2, units? ) -> `Number`

Calculates the shortest distance between two points along a great circle. Applies only to points with a Geographic Coordinate System (GCS) or the Web Mercator spatial reference. If the input points have a Projected Coordinate System (other than Web Mercator), you should use the distance method.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

point1 | Point | Feature | The point used to measure the distance from `point2` . This point must have a GCS or Web Mercator spatial reference. |

point2 | Point | Feature | The point used to measure the distance from `point1` . This point must have a GCS or Web Mercator spatial reference. |

units | Text | Number | `optional` Measurement unit of the return value. Use one of the string values listed in the Units reference. |

#### Returns: Number

#### Example

###### Returns the distance from a bus in a stream layer to the central station in kilometers

```
var unionStation = Point({"x": -118.15, "y": 33.80, "spatialReference": { "wkid": 3857 }});
distanceGeodetic($feature, unionStation, 'kilometers');
```

## EnvelopeIntersects

This function has 2 signatures:

- EnvelopeIntersects( geometry1, geometry2 ) ->
`Boolean`

- EnvelopeIntersects( featuresEnvelopes, envelope ) ->
`FeatureSet`

### EnvelopeIntersects( geometry1, geometry2 ) -> `Boolean`

Indicates if the envelope (or extent) of one geometry intersects the envelope of another geometry. In the graphic below, the red highlight indicates the scenarios where the function will return `true`

.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

geometry1 | Geometry | Feature | The geometry that is tested for the intersects relationship to the other geometry. |

geometry2 | Geometry | Feature | The geometry being intersected. |

#### Returns: Boolean

#### Example

###### Returns true if the geometries intersect

```
var geom2 = Polygon({ ... });
EnvelopeIntersects($feature, geom2);
```

### EnvelopeIntersects( featuresEnvelopes, envelope ) -> `FeatureSet`

Returns features from a FeatureSet where the envelopes (or extent) of a set of features intersect the envelope of another geometry. In the graphic below, the red highlight illustrates the spatial relationships where the function will return features.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

featuresEnvelopes | FeatureSet | The FeatureSet that is tested for the intersects relationship to the input `envelope` . |

envelope | Geometry | Feature | The envelope being intersected. |

#### Returns: FeatureSet

#### Example

###### Returns the number of features that intersect the envelope of geom2

```
var geom2 = Polygon({ ... });
Count( EnvelopeIntersects($layer, geom2) );
```

## Equals

### Equals( geometry1, geometry2 ) -> `Boolean`

Indicates if two geometries are equal, or geographically equivalent given the spatial reference and tolerance of the data. The two input geometries don't have to be clones to be considered equal.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

geometry1 | Geometry | Feature | The first input geometry. |

geometry2 | Geometry | Feature | The second input geometry. |

#### Returns: Boolean

#### Example

###### Returns true if the geometries are equal

```
var geom2 = Point({ ... });
Equals($feature, geom2);
```

## Extent

### Extent( json ) -> `Extent`

Constructs an Extent object from a JSON string or an object literal. The JSON schema must follow the ArcGIS REST API format for Envelope geometries. This function may also return the extent of an input Polygon, Point, Polyline or Multipoint.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

json | Dictionary | Geometry | The JSON or Geometry from which to construct the extent geometry object. |

#### Returns: Extent

#### Example

```
// Creates an Extent object
var extentJSON = {
"xmin": -109.55, "ymin": 25.76, "xmax": -86.39, "ymax": 49.94,
"spatialReference": { "wkid": 3857 }
};
Extent(extentJSON);
```

```
// Returns the Extent of the given feature
Extent($feature)
```

## Generalize

### Generalize( inputGeometry, maxDeviation, removeDegenerateParts?, maxDeviationUnit? ) -> `Geometry`

Reduces the number of vertices in the input geometry based on a given deviation value. Point and Multipoint geometries are left unchanged. Envelopes are converted to Polygons and then generalized. `$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

inputGeometry | Geometry | Feature | The input geometry to be generalized. |

maxDeviation | Number | The maximum allowed deviation from the generalized geometry to the original geometry. |

removeDegenerateParts | Boolean | `optional` When `true` the degenerate parts of the geometry will be removed from the output (may be undesired for drawing). |

maxDeviationUnit | Text | Number | `optional` Measurement unit for maxDeviation. Defaults to the units of the input geometry. Use one of the string values listed in the Units reference. |

#### Returns: Geometry

#### Example

###### Returns a generalized version of the input geometry

```
// Removes vertices so segments are no more than 100 meters from the original geometry
Generalize($feature, 100, true, 'meters')
```

## Geometry

### Geometry( feature ) -> `Geometry`

Constructs a Geometry object from a JSON string or an object literal. The JSON schema must follow the ArcGIS REST API format for geometries. This function may also return the Geometry of an input feature.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

feature | Feature | Dictionary | The Feature or JSON from which to construct the geometry object. |

#### Returns: Geometry

#### Example

###### Returns the geometry of the feature

`Geometry($feature)`

###### Constructs a point geometry. This can be done with any geometry type.

```
var pointJSON = {"x": -118.15, "y": 33.80, "spatialReference": { "wkid": 4326 } };
Geometry(pointJSON);
```

## Intersection

### Intersection( geometry1, geometry2 ) -> `Geometry`

Constructs the set-theoretic intersection between two geometries and returns a new geometry.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

geometry1 | Geometry | Feature | The geometry to intersect with `geometry2` . |

geometry2 | Geometry | Feature | The geometry to intersect with `geometry1` . |

#### Returns: Geometry

#### Example

###### Returns the area common to both polygons

```
var geom2 = Polygon({ ... });
Area(Intersection($feature, geom2), 'square-miles');
```

## Intersects

This function has 2 signatures:

- Intersects( geometry1, geometry2 ) ->
`Boolean`

- Intersects( intersectingFeatures, geometry2 ) ->
`FeatureSet`

### Intersects( geometry1, geometry2 ) -> `Boolean`

Indicates if one geometry intersects another geometry. In the graphic below, the red highlight indicates the scenarios where the function will return `true`

.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

geometry1 | Geometry | Feature | The geometry that is tested for the intersects relationship to `geometry2` . |

geometry2 | Geometry | Feature | The geometry being intersected. |

#### Returns: Boolean

#### Example

###### Returns true if the geometries intersect

```
var geom2 = Polygon({ ... });
Intersects($feature, geom2);
```

### Intersects( intersectingFeatures, geometry2 ) -> `FeatureSet`

Returns features from a FeatureSet that intersect another geometry. In the graphic below, the red highlight illustrates the spatial relationships where the function will return features.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

intersectingFeatures | FeatureSet | The FeatureSet that is tested for the intersects relationship to `geometry2` . |

geometry2 | Geometry | Feature | The geometry being intersected. |

#### Returns: FeatureSet

#### Example

###### Returns the number of features that intersect the polygon

```
var geom2 = Polygon({ ... });
Count( Intersects($layer, geom2) );
```

## IsSelfIntersecting

### IsSelfIntersecting( geometry ) -> `Boolean`

Indicates whether the input geometry has rings, paths, or points that intersect or cross other parts of the geometry. For example, a single polyline feature whose paths intersect each other or a polygon with rings that self intersect would return `true`

.

Name | Type | Description |
---|---|---|

geometry | Geometry | Feature | The polygon, polyline, or multipoint geometry to test for the self intersection. |

#### Returns: Boolean

#### Example

###### Returns true if the polyline's paths intersect each other

```
var polyline = Polyline({ ... });
IsSelfIntersecting(polyline);
```

## IsSimple

### IsSimple( geometry ) -> `Boolean`

Indicates if the given geometry is topologically simple. `$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

geometry | Geometry | Feature | The input geometry. |

#### Returns: Boolean

#### Example

###### Returns true if the geometry is topologically simple

```
IsSimple($feature);
```

## Length

### Length( geometry, unit? ) -> `Number`

Returns the length of the input geometry or FeatureSet in the given units. This is a planar measurement using Cartesian mathematics.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

geometry | Geometry | Feature | FeatureSet | Points[] | The geometry or geometries for which to calculate the planar length. In profiles that support accessing data, this can be a FeatureSet. |

unit | Text | Number | `optional` Measurement unit of the return value. Use one of the string values listed in the Units reference. |

#### Returns: Number

#### Example

###### Returns the planar length of the feature in kilometers

`Length($feature, 'kilometers')`

###### Returns the planar length of the layer in meters

`Length($layer, 'meters')`

## Length3D

### Length3D( geometry, unit? ) -> `Number`

**Profiles**: Attribute Rules | Popups | Field Calculation | Tasks

Returns the planar (i.e. Cartesian) length of the input geometry taking height or Z information into account. The geometry provided to this function must be assigned a projected coordinate system. If the spatial reference does not provide a value for Z units, then the result will be returned in meters. Keep in mind that not all clients (such as the 3.x series of the ArcGIS API for JavaScript) support requesting Z values even when the data contains Z information.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

geometry | Geometry | Feature | FeatureSet | Points[] | The geometry or geometries for which to calculate the planar length in 3D space. In profiles that support accessing data, this can be a FeatureSet. |

unit | Text | Number | `optional` Measurement unit of the return value. Use one of the string values listed in the Units reference. |

#### Returns: Number

#### Example

###### Returns the 3D planar length of the feature in the unit of the spatial reference of the context executing the expression.

`Length3D($feature)`

###### Returns the 3D planar length of the feature in feet.

`Length3D($feature, 'feet')`

###### Returns the 3D length of the layer's features in meters

`Length($layer, 'meters')`

## LengthGeodetic

### LengthGeodetic( geometry, unit? ) -> `Number`

Returns the geodetic length of the input geometry or FeatureSet in the given units. This is more reliable measurement of length than Length() because it takes into account the Earth's curvature. Support is limited to geometries with a Web Mercator (wkid 3857) or a WGS 84 (wkid 4326) spatial reference.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

geometry | Geometry | Feature | FeatureSet | Points[] | The geometry for which to calculate the geodetic length. |

unit | Text | Number | `optional` Measurement unit of the return value. Use one of the string values listed in the Units reference. |

#### Returns: Number

#### Example

###### Returns the geodetic length of the feature in kilometers

`LengthGeodetic($feature, 'kilometers')`

###### Returns the geodetic length of the layer in meters

`LengthGeodetic($layer, 'meters')`

## MultiPartToSinglePart

### MultiPartToSinglePart( geometry ) -> `Geometry[]`

Converts a multi-part geometry into separate geometries.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

geometry | Geometry | Feature | The multi-part geometry to break into single parts. |

#### Returns: Geometry[]

#### Example

###### Returns an array of single-part geometries from a multi-part geometry

`var allParts = MultiPartToSinglePart($feature)`

## Multipoint

### Multipoint( json ) -> `Multipoint`

Constructs a Multipoint object from a JSON string or an object literal. The JSON schema must follow the ArcGIS REST API format for multipoint geometries.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

json | Dictionary | The JSON from which to construct the multipoint geometry object. |

#### Returns: Multipoint

#### Example

```
// Creates a Multipoint object
var multipointJSON = {
"points": [[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832]],
"spatialReference" : { "wkid": 3857 }
};
Multipoint(multipointJSON);
```

## Offset

### Offset( inputGeometry, offsetDistance, offsetUnit?, joinType?, bevelRatio?, flattenError? ) -> `Geometry`

Creates a geometry that is a constant planar distance from an input geometry. It is similar to buffering, but produces a one-sided result. `$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

inputGeometry | Geometry | Feature | The geometry to offset. Point geometries are not supported. |

offsetDistance | Number | The planar distance to offset from the input geometry. If `offsetDistance > 0` , then the offset geometry is constructed to the right of the input geometry, if `offsetDistance = 0` , then there is no change in the geometries, otherwise it is constructed to the left. The direction of the paths or rings of the input geometry determines which side of the geometry is considered right, and which side is considered 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 | Text | Number | `optional` Measurement unit for `offsetDistance` . Defaults to the units of the input geometry. Use one of the string values listed in the Units reference. |

joinType | Text | `optional` The join type. Possible values are `round` , `bevel` , `miter` , or `square` . |

bevelRatio | Number | `optional` Applicable 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 | Number | `optional` Applicable 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. |

#### Returns: Geometry

#### Example

###### Returns the offset geometry

```
Offset($feature, 10, 'meters', 'square');
```

## Overlaps

This function has 2 signatures:

- Overlaps( geometry1, geometry2 ) ->
`Boolean`

- Overlaps( overlappingFeatures, geometry2 ) ->
`FeatureSet`

### Overlaps( geometry1, geometry2 ) -> `Boolean`

Indicates if one geometry overlaps another geometry. In the graphic below, the red highlight indicates the scenarios where the function will return `true`

. `$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

geometry1 | Geometry | Feature | The base geometry that is tested for the 'overlaps' relationship with `geometry2` . |

geometry2 | Geometry | Feature | The comparison geometry that is tested for the 'overlaps' relationship with `geometry1` . |

#### Returns: Boolean

#### Example

###### Returns true if the geometries overlap

```
var geom2 = Polygon({ ... });
Overlaps($feature, geom2);
```

### Overlaps( overlappingFeatures, geometry2 ) -> `FeatureSet`

Returns features from a FeatureSet that overlap another geometry. In the graphic below, the red highlight illustrates the spatial relationships where the function will return features.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

overlappingFeatures | FeatureSet | The features that are tested for the 'overlaps' relationship with `geometry2` . |

geometry2 | Geometry | Feature | The comparison geometry that is tested for the 'overlaps' relationship with `overlappingFeatures` . |

#### Returns: FeatureSet

#### Example

###### Returns the number of features that overlap the polygon

```
var geom2 = Polygon({ ... });
Count( Overlaps($layer, geom2) );
```

## Point

### Point( json ) -> `Point`

Constructs a Point object from a JSON string or an object literal. The JSON schema must follow the ArcGIS REST API format for Point geometries.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

json | Dictionary | The JSON from which to construct the point geometry object. |

#### Returns: Point

#### Example

```
// Creates a Point object
var pointJSON = { "x": -118.15, "y": 33.80, "spatialReference": { "wkid": 4326 }};
Point(pointJSON)
```

## Polygon

### Polygon( json ) -> `Polygon`

Constructs a Polygon object from a JSON string or an object literal. The JSON schema must follow the ArcGIS REST API format for Polygon geometries.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

json | Dictionary | The JSON from which to construct the polygon geometry object. |

#### Returns: Polygon

#### Example

```
// Creates a Polygon object
var polygonJSON = {
"rings": [ [[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832], [-97.06138,32.837]],[[-97.06326,32.759],[-97.06298,32.755],[-97.06153,32.749], [-97.06326,32.759]] ],
"spatialReference": { "wkid": 3857 }
};
Polygon(polygonJSON);
```

## Polyline

### Polyline( json ) -> `Polyline`

Constructs a Polyline object from a JSON string or an object literal. The JSON schema must follow the ArcGIS REST API format for Polyline geometries.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

json | Dictionary | The JSON from which to construct the polyline geometry object. |

#### Returns: Polyline

#### Example

```
// Creates a Polyline object
var polylineJSON = {
"paths": [ [[-97.06138,32.837],[-97.06133,32.836],[-97.06124,32.834],[-97.06127,32.832]], [[-97.06326,32.759],[-97.06298,32.755]] ],
"spatialReference": { "wkid": 4326 }
};
Polyline(polylineJSON);
```

## Relate

### Relate( geometry1, geometry2, relation ) -> `Boolean`

Indicates if the given DE-9IM relation is `true`

for the two geometries.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

geometry1 | Geometry | Feature | The first geometry for the relation. |

geometry2 | Geometry | Feature | The second geometry for the relation. |

relation | Text | 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: 0,1,2), a Boolean value (T or F), or a mask character (for ignoring results: '*'). 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. |

#### Returns: Boolean

#### Example

###### Returns true if the relation of the input geometries matches

```
Relate($feature, geometry2, 'TTTFFTFFT')
```

## RingIsClockwise

### RingIsClockwise( points ) -> `Boolean`

Indicates whether the points in a polygon ring are ordered in a clockwise direction.

Name | Type | Description |
---|---|---|

points | Array | An array of points in a polygon ring. |

#### Returns: Boolean

#### Example

```
// $feature is a polygon feature
var polygonRings = Geometry($feature).rings;
IIF(RingIsClockwise(polygonRings[0]), 'correct polygon', 'incorrect direction')
```

## Rotate

### Rotate( inputGeometry, angle, rotationOrigin? ) -> `Geometry`

Rotates a geometry counterclockwise by the specified number of degrees. Rotation is around the centroid, or a given rotation point. `$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

inputGeometry | Geometry | Feature | The geometry to rotate. |

angle | Number | The rotation angle in degrees. |

rotationOrigin | Point | `optional` Point to rotate the geometry around. Defaults to the centroid of the geometry. |

#### Returns: Geometry

#### Example

```
Rotate($feature, 90)
```

## SetGeometry

### SetGeometry( internalFeature, geometry )

Sets or replaces a geometry on a user-defined Feature. Note that features referenced as global variables are immutable; their geometries cannot be changed.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

internalFeature | Feature | A feature whose geometry will be updated. |

geometry | Geometry | The geometry to set on the input feature. |

#### Example

###### Sets a new geometry on the feature

```
var pointFeature = Feature(Point( ... ), 'name', 'buffer centroid');
var mileBuffer = BufferGeodetic(Geometry(pointFeature), 1, 'mile');
SetGeometry(pointFeature, mileBuffer);
```

## Simplify

### Simplify( inputGeometry ) -> `Geometry`

Performs the simplify operation on the geometry. This alters the given geometry to make it topologically legal.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

inputGeometry | Geometry | Feature | The geometry to be simplified. |

#### Returns: Geometry

#### Example

###### Returns the simplified geometry of the feature

```
Simplify($feature);
```

## SymmetricDifference

### SymmetricDifference( leftGeometry, rightGeometry ) -> `Geometry`

Performs the Symmetric difference operation on the two geometries. The symmetric difference includes the parts of both geometries that are not common with each other.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

leftGeometry | Geometry | Feature | The geometry instance to compare to `rightGeometry` in the XOR operation. |

rightGeometry | Geometry | Feature | The geometry instance to compare to `leftGeometry` in the XOR operation. |

#### Returns: Geometry

#### Example

###### Returns a polygon representing areas where both inputs do not overlap

```
var geom2 = Polygon({ ... });
SymmetricDifference($feature, geom2);
```

## Touches

This function has 2 signatures:

### Touches( geometry1, geometry2 ) -> `Boolean`

Indicates if one geometry touches another geometry. In the graphic below, the red highlight indicates the scenarios where the function will return `true`

.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

geometry1 | Geometry | Feature | The geometry to test the 'touches' relationship with `geometry2` . |

geometry2 | Geometry | Feature | The geometry to test the 'touches' relationship with `geometry1` . |

#### Returns: Boolean

#### Example

###### Returns true if the geometries touch

```
var geom2 = Polygon({ ... });
Touches($feature, geom2);
```

### Touches( touchingFeatures, geometry2 ) -> `FeatureSet`

Returns features from a FeatureSet that touch another geometry. In the graphic below, the red highlight illustrates the spatial relationships where the function will return features.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

touchingFeatures | FeatureSet | The features to test the 'touches' relationship with `geometry2` . |

geometry2 | Geometry | Feature | The geometry to test the 'touches' relationship with `touchingFeatures` . |

#### Returns: FeatureSet

#### Example

###### Returns the number of features in the layer that touch the geometry.

```
var geom = Polygon({ ... });
Count( Touches($layer, geom) );
```

## Union

### Union( geometries ) -> `Geometry`

Constructs the set-theoretic union of the geometries in an input array, or list, and returns a single Geometry. All inputs must have the same geometry type and share the same spatial reference.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

geometries | Geometry[] | Feature[] | An array, or list, of geometries to union into a single geometry. This can be any number of geometries. |

#### Returns: Geometry

#### Example

###### Unions geometries passed as an array

```
var geom2 = Polygon({ ... });
Union([ $feature, geom2 ]);
```

###### Unions geometries passed as a list

```
var geom2 = Polygon({ ... });
var geom3 = Polygon({ ... });
var geom4 = Polygon({ ... });
Union(Geometry($feature), geom2, geom3, geom4);
```

## Within

This function has 2 signatures:

- Within( innerGeometry, outerGeometry ) ->
`Boolean`

- Within( innerGeometry, outerGeometries ) ->
`FeatureSet`

### Within( innerGeometry, outerGeometry ) -> `Boolean`

Indicates if one geometry is within another geometry. In the graphic below, the red highlight indicates the scenarios where the function will return `true`

.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

innerGeometry | Geometry | Feature | The base geometry that is tested for the 'within' relationship to `outerGeometry` . |

outerGeometry | Geometry | Feature | The comparison geometry that is tested for the 'contains' relationship to `innerGeometry` . |

#### Returns: Boolean

#### Example

###### Returns true if the feature is within the given polygon

```
var outerGeom = Polygon({ ... });
Within($feature, outerGeom);
```

### Within( innerGeometry, outerGeometries ) -> `FeatureSet`

Returns features from a FeatureSet that are within another geometry. In the graphic below, the red highlight illustrates the spatial relationships where the function will return features.`$feature`

as input to this function will yield results only as precise as the view's scale resolution. Therefore values returned from expressions using this function may change after zooming between scales.

Name | Type | Description |
---|---|---|

innerGeometry | Geometry | Feature | The base geometry that is tested for the 'within' relationship to `outerGeometries` . |

outerGeometries | FeatureSet | The comparison features that are tested for the 'contains' relationship to `innerGeometry` . |

#### Returns: FeatureSet

#### Example

###### Returns the number of features in the layer within the polygon

```
var outerGeom = Polygon({ ... });
Count( Within(outerGeom, $layer) );
```