Data Types

Arcade has a full type system. Each type is described below.

Any

Represents any type described below. Some Arcade functions, such as Array, accept values of any type. A function may also return a value of any type depending on its inputs. In these cases, you may see function parameters and return types documented as Any.

Array

An object representing a list of elements. Arrays are declared using square brackets.

Use dark colors for code blocksCopy
       
1
2
3
4
5
6
7
var a = [];
// an empty array with no elements;

Count(a); // returns 0

a = [5,2,19];
Count(a); // returns 3

A single array can contain elements of various types, but they cannot have missing elements.

Use dark colors for code blocksCopy
        
1
2
3
4
5
6
7
8
var z = [1,2,3];
var k = [1,2,"hello"];

return k[1];  // returns 2

z[0] = 23;  // z = [23,2,3]
z[3] = 24;  // Allowed as next sequential item
z[1000] = 23 // Not allowed

Arrays are zero-indexed, meaning the first element in the array is marked with an index of 0.

Use dark colors for code blocksCopy
    
1
2
3
4
var a = [10, 20, 30];

return a[0];
// returns 10;

You may iterate through the elements of an array using a for loop.

Use dark colors for code blocksCopy
   
1
2
3
for (var index in myArray){
  // executes for each element in the array
}

Note that the variable index represents the index of the array, not the value at that position.

Use dark colors for code blocksCopy
       
1
2
3
4
5
6
7
var myArray = [10,20,30,40,50,60,70];
var total = 0;
for(var index in myArray){
  total += myArray[index];
}
// total = 280
return total;

The following snippet sums the values of the array positions (or indexes):

Use dark colors for code blocksCopy
       
1
2
3
4
5
6
7
var myArray = [10,20,30,40,50,60,70];
var total = 0;
for(var index in myArray){
  total += index;
}
// total = 21
return total;

Attachment

Defines information about attachments returned from feature service queries. These are fetched using the Attachments() function.

PropertyTypeDescription
idnumberThe ID of the attachment.
nametextThe file name of the attachment, including the file extension.
contentTypetextThe content type of the attachment. The following are supported types: bmp, ecw, emf, eps, ps, gif, img, jp2, jpc, j2k, jpf, jpg, jpeg, jpe, png, psd, raw, sid, tif, tiff, wmf, wps, avi, mpg, mpe, mpeg, mov, wmv, aif, mid, rmi, mp2, mp3, mp4, pma, mpv2, qt, ra, ram, wav, wma, doc, docx, dot, xls, xlsx, xlt, pdf, ppt, pptx, txt, zip, 7z, gz, gtar, tar, tgz, vrml, gml, json, xml, mdb, geodatabase.
sizenumberThe size of the attachment in bytes.
exifInfoArrayAn array containing the Exif metadata of the attachment.

Boolean

Boolean values evaluate to either true or false.

Use dark colors for code blocksCopy
   
1
2
3
var x = true;  // true
var y = false;  // false
var z = x && z;  // false

Date

Dates represent a moment in time. Dates are created with the Date() function and are stored as a Unix Epoch.

Use dark colors for code blocksCopy
     
1
2
3
4
5
// Date only
var x = Date(2007,11,1);  // December 1, 2007

// Date with time
var n = Date(2008,11,1,12,55); // December 1, 2008 at 12:55 p.m.

Use the date functions to work with date objects, including getting its properties and calculating new dates.

Dictionary

A collection of key/value pairs. The keys of the dictionary are case insensitive. Dictionaries may be created with the Dictionary function.

Use dark colors for code blocksCopy
 
1
var d = Dictionary("field1", 1, "field2", 2);

You can also define dictionaries with curly brackets.

Use dark colors for code blocksCopy
     
1
2
3
4
5
var d = {
  field1: 1,
  field2: 2,
  "full name": "Fred Barker"
};

Dot notation

Dictionary properties can be of any type, including Dictionary. Properties can be accessed with dot notation. Dot notation allows you to access property values by typing the name of the dictionary, followed by a dot, and followed by the name of the dictionary property.

Use dark colors for code blocksCopy
 
1
return d.field1 + d.field2;  // returns 3

Dot notation is not supported if the property name contains spaces or non-Latin characters outside the Unicode BMP. In these scenarios you need square bracket notation.

Square bracket notation

Square bracket notation allows you to access dictionary properties by wrapping the property name as a text value inside of square brackets.

Use dark colors for code blocksCopy
 
1
return d["field1"] + d["field2"];  // returns 3

Square bracket notation allows you to access unconventional property names.

Use dark colors for code blocksCopy
  
1
2
d["full name"];
// returns "Fred Barker"

You can also use square brackets to reference dictionary keys using variable names.

Use dark colors for code blocksCopy
   
1
2
3
var y = 2000;
d["Population_" + y];
// returns population in the year 2000

Auto-keys

You may access dictionary properties using auto-keys. Auto-keys assign dictionary key values to Arcade variables with names matching the dictionary's keys.

Use dark colors for code blocksCopy
  
1
2
var { field1, field2 } = d;
return field1 + field2;  // returns 3

Feature

Features represent geometries with a dictionary of attributes.

PropertyTypeDescription
attributesDictionaryA dictionary containing the attributes of the feature.
geometryGeometryThe geometry representing the location of the feature. This is optional.

You may access feature attributes using dot or square bracket notation.

Use dark colors for code blocksCopy
  
1
2
var d = Feature(myGeometry, "field1", 1, "field2", 2);
return d.field1 + d["field2"];  // returns 3

Many profiles contain a $feature profile variable, which represents an input feature to the expression.

Use dark colors for code blocksCopy
 
1
var population = $feature.Population;

You can reference values from joined tables using the square bracket syntax: $feature["joinKey.fieldName"]

Use dark colors for code blocksCopy
       
1
2
3
4
5
6
7
// returns % change in votes from 2012 to 2016
Round(
  (
    ($feature["COUNTY_ID.VOTED_DEM_2016"] - $feature["COUNTY_ID.VOTED_DEM_2012"])
    / $feature["COUNTY_ID.VOTED_DEM_2012"]
  ) * 100,
2 );

A feature's geometry cannot be accessed with dot notation. You must use the Geometry function to access a feature's geometry.

Use dark colors for code blocksCopy
    
1
2
3
4
var geom = Geometry($feature);
if( TypeOf(geom) == "Polygon" ){
  return firstVertex = geom.rings[0][0];  // The first vertex of the polygon
}

FeatureSet

A FeatureSet represents a connection to a layer in memory or in a server. FeatureSets are lazy, iterable, and chain-able. They allow you to access features from tables and layers within a map, feature service, or database using a FeatureSet function.

FeatureSets are typically provided to Arcade scripts via a profile variable, such as $layer, or as part of a FeatureSetCollection like $map or $datastore.

Use dark colors for code blocksCopy
       
1
2
3
4
5
6
7
// Returns the highest population among all features in the layer
// $layer is a FeatureSet
var maxValue = Max($layer, "Population");
// $feature is a Feature
var value = $feature.Population;

return maxValue - value;

See the FeatureSet guide guide to learn about creating and working with FeatureSets.

FeatureSetCollection

A FeatureSetCollection represents a collection of FeatureSets. This data type is only used when working with the $map and $datastore profile variables available in some profiles, like Popup. For example, the $map profile variable represents a collection of layers (i.e. FeatureSets) in the map of the $feature used in the execution of the Arcade expression. The $datastore represents a collection of layers in the same feature service as the $feature used in the execution of the Arcade expression.

Use dark colors for code blocksCopy
  
1
2
// publicLandFeatures represents the features in a layer named "public lands" in the map
var publicLandFeatures = FeatureSetByName($map, "public lands", ["class"], true);

Geometry

Arcade includes five geometry types:

Use dark colors for code blocksCopy
    
1
2
3
4
// General geometry creation. Will work out type from arguments.
var geom = Geometry({ x: 100, y: 100, spatialReference: { wkid: 102100 } })

return typeof(geom)  // returns "point"

Geometry is immutable, meaning it is not possible to change after it has been created. Features have a geometry property, which can only be accessed with the Geometry() function.

Use dark colors for code blocksCopy
    
1
2
3
4
// Assigns the feature's geometry to the line variable
var line = Geometry($feature);

LengthGeodetic(line, "meters");  // returns the length of the line in meters

The following tables describe the specification of each geometry type.

Point

A point is a zero-dimensional geometry representing a location with a pair of coordinates. This may be created by providing a Dictionary defined with the properties below to the Point() function or by passing a point feature to the Geometry() function.

PropertyTypeDescription
typetextIndicates the geometry type. This value is always point.
xnumberThe x-coordinate of the point.
ynumberThe y-coordinate of the point.
znumberThe z-coordinate of the point. This may be null.
mnumberThe m value of the point. This may be null.
hasZbooleanIndicates if the geometry has a z-coordinate.
hasMbooleanIndicates if the geometry has an m-value.
spatialReferencedictionaryThe spatial reference of the geometry. This object contains a wkid property that indicates the Well-known ID of the geographic or projected coordinate system that defines the reference for which to draw the geometry.
Use dark colors for code blocksCopy
     
1
2
3
4
5
var pt = Point({
  x: 100,
  y: 100,
  spatialReference: { wkid: 102100 }
});

Multipoint

A multipoint is a zero-dimensional geometry, where multiple points represent one geometry. This may be created by providing a Dictionary defined with the properties below to the Multipoint() function or by passing a multipoint feature to the Geometry() function.

PropertyTypeDescription
typetextIndicates the geometry type. This value is always multipoint.
pointsPoint[] | number[][]An array of points making up the multipoint geometry.
hasZbooleanIndicates if the geometry has z-coordinates.
hasMbooleanIndicates if the geometry has m-values.
spatialReferencedictionaryThe spatial reference of the geometry. This object contains a wkid property that indicates the Well-known ID of the geographic or projected coordinate system that defines the reference for which to draw the geometry.

The points property of a Multipoint may be defined with an array of x,y,z,m coordinates.

Use dark colors for code blocksCopy
          
1
2
3
4
5
6
7
8
9
10
var mp = Multipoint({
  points: [
    [-97.06138,32.837, 100],
    [-97.06133,32.836, 50],
    [-97.06124,32.834, 20],
    [-97.06127,32.832, 0]
  ],
  hasZ: true,
  spatialReference: { wkid: 102100 }
});

Or with an array of Point objects.

Use dark colors for code blocksCopy
          
1
2
3
4
5
6
7
8
9
10
var mp = Multipoint({
  points: [
    Point({ x: -97.06138, y: 32.837, z: 100, hasZ: true, spatialReference: { wkid: 102100 } }),
    Point({ x: -97.06133, y: 32.836, z: 50, hasZ: true, spatialReference: { wkid: 102100 } }),
    Point({ x: -97.06124, y: 32.834, z: 20, hasZ: true, spatialReference: { wkid: 102100 } }),
    Point({ x: -97.06127, y: 32.832, z: 0, hasZ: true, spatialReference: { wkid: 102100 } })
  ],
  hasZ: true,
  spatialReference: { wkid: 102100 }
});

Polyline

A polyline is a one-dimensional geometry containing a list of coordinates representing one or more paths. This may be created by providing a Dictionary defined with the properties below to the Polyline() function or by passing a polyline feature to the Geometry() function.

PropertyTypeDescription
typetextIndicates the geometry type. This value is always polyline.
pathsnumber[][][] | Point[][]A three-dimensional array of numbers representing coordinates or a two-dimensional array of points. When providing an 3-dimensional array of numbers, the inner-most array contains the coordinates of a single point (or vertex). This array must have at least 2 elements that represent x,y coordinates, but it may have up to 4 representing x,y,z,m values. The middle array contains additional points making up a line segment (or path). The outer-most array defines a list of segments to include in the polyline.
hasZbooleanIndicates if the geometry has z-coordinates.
hasMbooleanIndicates if the geometry has m-values.
spatialReferencedictionaryThe spatial reference of the geometry. This object contains a wkid property that indicates the Well-known ID of the geographic or projected coordinate system that defines the reference for which to draw the geometry.

The paths property of a Polyline may be defined with an array of x/y/z/m coordinates.

Use dark colors for code blocksCopy
           
1
2
3
4
5
6
7
8
9
10
11
// polyline with one segment
var line = Polyline({
  paths: [[
    [-97.06138,32.837, 100],  // third number is a z-value indicated by the hasZ property
    [-97.06133,32.836, 50],
    [-97.06124,32.834, 20],
    [-97.06127,32.832, 0]
  ]],
  hasZ: true,
  spatialReference: { wkid: 102100 }
});
Use dark colors for code blocksCopy
                  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// polyline with two segments
var line = Polyline({
  paths: [
    [
      [-97.06138,32.837, 100],  // third number is an m-value indicated by the hasM property
      [-97.06133,32.836, 50],
      [-97.06124,32.834, 20],
      [-97.06127,32.832, 0]
    ], [
      [-101.06138,32.837, 100],
      [-101.06133,32.836, 50],
      [-101.06124,32.834, 20],
      [-101.06127,32.832, 0]
    ]
  ],
  hasM: true,
  spatialReference: { wkid: 102100 }
});

Or with an array of Point objects.

Use dark colors for code blocksCopy
           
1
2
3
4
5
6
7
8
9
10
11
// polyline with one segment
var line = Polyline({
  paths: [[
    Point({ x: -97.06138, y: 32.837, z: 100, hasZ: true, spatialReference: { wkid: 102100 } }),
    Point({ x: -97.06133, y: 32.836, z: 50, hasZ: true, spatialReference: { wkid: 102100 } }),
    Point({ x: -97.06124, y: 32.834, z: 20, hasZ: true, spatialReference: { wkid: 102100 } }),
    Point({ x: -97.06127, y: 32.832, z: 0, hasZ: true, spatialReference: { wkid: 102100 } })
  ]],
  hasZ: true,
  spatialReference: { wkid: 102100 }
});
Use dark colors for code blocksCopy
                  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// polyline with two segments
var line = Polyline({
  paths: [
    [
      Point({ x: -97.06138, y: 32.837, z: 100, hasZ: true, spatialReference: { wkid: 102100 } }),
      Point({ x: -97.06133, y: 32.836, z: 50, hasZ: true, spatialReference: { wkid: 102100 } }),
      Point({ x: -97.06124, y: 32.834, z: 20, hasZ: true, spatialReference: { wkid: 102100 } }),
      Point({ x: -97.06127, y: 32.832, z: 0, hasZ: true, spatialReference: { wkid: 102100 } })
    ], [
      Point({ x: -101.06138, y: 32.837, z: 100, hasZ: true, spatialReference: { wkid: 102100 } }),
      Point({ x: -101.06133, y: 32.836, z: 50, hasZ: true, spatialReference: { wkid: 102100 } }),
      Point({ x: -101.06124, y: 32.834, z: 20, hasZ: true, spatialReference: { wkid: 102100 } }),
      Point({ x: -101.06127, y: 32.832, z: 0, hasZ: true, spatialReference: { wkid: 102100 } })
    ]
  ],
  hasZ: true,
  spatialReference: { wkid: 102100 }
});

Polygon

A polygon is a two-dimensional geometry containing a list of coordinates representing one or more rings (or boundaries) in a polygon. This may be created by providing a Dictionary defined with the properties below to the Polygon() function or by passing a polygon feature to the Geometry() function.

PropertyTypeDescription
typetextIndicates the geometry type. This value is always polygon.
ringsnumber[][][] | Point[][]A three-dimensional array of numbers or a two-dimensional array of points. When providing an 3-dimensional array of numbers, the inner-most array contains the coordinates of a single point. This array must have at least 2 elements that represent x,y coordinates, but it may have up to 4 representing x,y,z,m values. The middle array contains additional points making up a ring whose first and last points must match. The outer-most array defines a list of rings to include in the polygon.
hasZbooleanIndicates if the geometry has z-coordinates.
hasMbooleanIndicates if the geometry has m-values.
spatialReferencedictionaryThe spatial reference of the geometry. This object contains a wkid property that indicates the Well-known ID of the geographic or projected coordinate system that defines the reference for which to draw the geometry.

The rings property of a Polygon may be defined with an array of x/y/z/m coordinates.

Use dark colors for code blocksCopy
           
1
2
3
4
5
6
7
8
9
10
11
// polygon with one ring
var shape = Polygon({
  rings: [[
    [-97.06138,32.837, 100],
    [-97.06133,32.836, 50],
    [-97.06124,32.834, 20],
    [-97.06127,32.832, 0]
  ]],
  hasZ: true,
  spatialReference: { wkid: 102100 }
});
Use dark colors for code blocksCopy
                  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// polygon with two rings
var shape = Polygon({
  rings: [
    [
      [-97.06138,32.837, 100],
      [-97.06133,32.836, 50],
      [-97.06124,32.834, 20],
      [-97.06127,32.832, 0]
    ], [
      [-101.06138,32.837, 100],
      [-101.06133,32.836, 50],
      [-101.06124,32.834, 20],
      [-101.06127,32.832, 0]
    ]
  ],
  hasZ: true,
  spatialReference: { wkid: 102100 }
});

Or with an array of Point objects.

Use dark colors for code blocksCopy
           
1
2
3
4
5
6
7
8
9
10
11
// polygon with one ring
var shape = Polygon({
  rings: [[
    Point({ x: -97.06138, y: 32.837, z: 100, hasZ: true, spatialReference: { wkid: 102100 } }),
    Point({ x: -97.06133, y: 32.836, z: 50, hasZ: true, spatialReference: { wkid: 102100 } }),
    Point({ x: -97.06124, y: 32.834, z: 20, hasZ: true, spatialReference: { wkid: 102100 } }),
    Point({ x: -97.06127, y: 32.832, z: 0, hasZ: true, spatialReference: { wkid: 102100 } })
  ]],
  hasZ: true,
  spatialReference: { wkid: 102100 }
});
Use dark colors for code blocksCopy
                  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// polygon with two rings
var shape = Polygon({
  rings: [
    [
      Point({ x: -97.06138, y: 32.837, z: 100, hasZ: true, spatialReference: { wkid: 102100 } }),
      Point({ x: -97.06133, y: 32.836, z: 50, hasZ: true, spatialReference: { wkid: 102100 } }),
      Point({ x: -97.06124, y: 32.834, z: 20, hasZ: true, spatialReference: { wkid: 102100 } }),
      Point({ x: -97.06127, y: 32.832, z: 0, hasZ: true, spatialReference: { wkid: 102100 } })
    ], [
      Point({ x: -101.06138, y: 32.837, z: 100, hasZ: true, spatialReference: { wkid: 102100 } }),
      Point({ x: -101.06133, y: 32.836, z: 50, hasZ: true, spatialReference: { wkid: 102100 } }),
      Point({ x: -101.06124, y: 32.834, z: 20, hasZ: true, spatialReference: { wkid: 102100 } }),
      Point({ x: -101.06127, y: 32.832, z: 0, hasZ: true, spatialReference: { wkid: 102100 } })
    ]
  ],
  hasZ: true,
  spatialReference: { wkid: 102100 }
});

Polygons with holes must be defined with an outer ring whose points are listed in clockwise order. The hole, or inner ring, must define its points in counter-clockwise order.

Extent

An extent is a bounding box describing the minimum and maximum coordinates of a polygon, polyline, multipoint. This may be created by providing a Dictionary defined with the properties below to the Extent() function or by passing an extent feature to the Geometry() function.

PropertyTypeDescription
typetextIndicates the geometry type. This value is always extent.
xMaxnumberThe upper bound, or highest possible x-coordinate of the geometry.
xMinnumberThe lower bound, or lowest possible x-coordinate of the geometry.
yMaxnumberThe upper bound, or highest possible y-coordinate of the geometry.
yMinnumberThe lower bound, or lowest possible y-coordinate of the geometry.
zMaxnumberThe upper bound, or highest possible z-coordinate of the geometry. This value may be null.
zMinnumberThe lower bound, or lowest possible z-coordinate of the geometry. This value may be null.
mMaxnumberThe upper bound, or highest possible m-value of the geometry. This value may be null.
mMinnumberThe lower bound, or lowest possible m-value of the geometry. This value may be null.
hasZbooleanIndicates if the geometry has z-coordinates.
hasMbooleanIndicates if the geometry has m-values.
spatialReferencedictionaryThe spatial reference of the geometry. This object contains a wkid property that indicates the Well-known ID of the geographic or projected coordinate system that defines the reference for which to draw the geometry.
Use dark colors for code blocksCopy
       
1
2
3
4
5
6
7
var envelope = Extent({
  xmin: -109.55,
  ymin: 25.76,
  xmax: -86.39,
  ymax: 49.94,
  spatialReference: { wkid: 102100 }
});

Number

A number represents a count or amount that can be used used in computations and Math functions.

They can be integers.

Use dark colors for code blocksCopy
  
1
2
var x = 10;
var y = 100;

Or floating point values.

Use dark colors for code blocksCopy
  
1
2
var z = 1.2;
var aa = 0.0034;

Arcade provides two number constants:

Use dark colors for code blocksCopy
 
1
var circleArea = PI * Pow($feature.radius, 2);

Numbers are limited in size to double max.

Portal

The Portal type represents an instance of an ArcGIS Portal (e.g. ArcGIS Online or ArcGIS Enterprise portal). This type is created by passing the URL of the portal instance to the Portal() function.

This type only applies to the portal parameter of the FeatureSetByPortalItem() function.

Use dark colors for code blocksCopy
     
1
2
3
4
5
// Represents the ArcGIS Online portal instance
var agol = Portal("https://www.arcgis.com");

// references a layer with its ID from a specified portal instance
var layer = FeatureSetByPortalItem(agol, "7b1fb95ab77f40bf8aa09c8b59045449", 0, ["*"], false);

Text

A text value is a series of characters wrapped in single or double quotes. Any number, date, dictionary, or boolean value may be converted to a text value using the Text() function.

Use dark colors for code blocksCopy
     
1
2
3
4
5
var x = "This is a Text variable";
var z = 'This is also a text variable';

// n = "100"
var n = Text(100);

Several text constants are available for your convenience. These allow you to insert special characters in text without needing to use escape characters. Click the links below to see the documentation for each.

As of version 1.11, you can embed expressions in text using template literals.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.