A set of functions for working with FeatureSets.
Area Area(features, unit?) -> NumberFunction bundle: Data Access
Returns the area of the input FeatureSet in the given units. This is a planar measurement using Cartesian mathematics.
Feature geometries in the visualization and labeling profiles are generalized according to the view's scale resolution to improve drawing performance. Therefore, using a feature's geometry (i.e. $feature
) as input to any geometry function in these contexts will return different results at each scale level. Other profiles, such as popup, provide the full resolution geometry.
Parameters
acres
| hectares
| square-centimeters
| square-decimeters
| square-feet
| square-inches
| square-kilometers
| square-meters
| square-miles
| square-millimeters
| square-us-feet
| square-us-miles
| square-yards
Return value: Number
Additional resources
Example
Returns the area of the layer in square kilometers
Use dark colors for code blocks Copy
1
Area($layer, 'square-kilometers')
AreaGeodetic AreaGeodetic(features, unit?, curveType?) -> Number
Function bundle: Data Access
Returns the geodetic area of the input FeatureSet in the given units. This is more reliable measurement of area than Area()
because it takes into account the Earth's curvature.
Feature geometries in the visualization and labeling profiles are generalized according to the view's scale resolution to improve drawing performance. Therefore, using a feature's geometry (i.e. $feature
) as input to any geometry function in these contexts will return different results at each scale level. Other profiles, such as popup, provide the full resolution geometry.
Parameters
features: FeatureSet - The FeatureSet for which to calculate the geodetic area.
unit (Optional): Text | Number - Measurement unit of the return value. This may be one of the possible values below, or one of the numeric codes listed in the additional resources section below. For the visualization, labeling, and popup profiles, the default unit is the map's spatial reference. In other profiles, like field calculation, the default is based on the spatial reference of the data.
Possible values: acres
| hectares
| square-centimeters
| square-decimeters
| square-feet
| square-inches
| square-kilometers
| square-meters
| square-miles
| square-millimeters
| square-us-feet
| square-us-miles
| square-yards
curveType (Optional): Text - Since 1.31 The type of curve to use for the geodetic area calculation. If no value is provided, the default is Geodesic
.
Possible values:
Geodesic
- Defined by the shortest distance between two points on an ellipsoid.GreatElliptic
- Defined by the intersection of a plane that contains the center of the spheroid and the spheroid surface and passes through two points. This is also known as a great circle when a sphere is used. It is not necessarily the shortest path between two points.Loxodrome
- Defined by the line of constant bearing, or azimuth, between two points. It represents a rhumb-line path on the earth that crosses each meridian at the same acute angle, thus forming a spiral that converges on the north or south pole. The Mercator projection shows loxodromes as straight lines.NormalSection
- Defined by the intersection of a plane that passes through two points on the surface of the spheroid and is perpendicular to the surface at the first point. It is not necessarily the shortest path between two points.ShapePreserving
- The segment shape is preserved in the projection where it is defined. This is often used in situations where maintaining the visual representation of a feature is crucial, like when working with boundaries or coastlines.Return value: Number
Additional resources
Example
Returns the geodetic area of the layer in square kilometers
Use dark colors for code blocks Copy
1
AreaGeodetic($layer, 'square-kilometers')
Attachments Attachments(inputFeature, options?) -> Array<Attachment>
Function bundle: Data Access
Returns a list of attachments associated with the input feature. Each result includes the name of the attachment, the content type, id, and size in bytes. Only applicable to features originating from a feature service.
Parameters
inputFeature: Feature - Attachments associated with this feature will be fetched from the service.
options (Optional): Dictionary - Settings for the request. Dictionary properties:
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
Return value: Array<Attachment>
Example
Returns the number of attachments associated with the feature
Use dark colors for code blocks Copy
1
2
// Returns the number of attachments associated with the feature
Count(Attachments($feature))
Average Average(features, fieldNameOrSQLExpression) -> Number
Function bundle: Data Access
Returns the average value of a given numeric field in a FeatureSet.
Parameters
Return value: Number
Examples
calculates the difference between the feature's population and the average population of all features in the layer
Use dark colors for code blocks Copy
1
$feature.population - Average($layer, 'population')
calculates the average population per square mile of all features in the layer
Use dark colors for code blocks Copy
1
Average($layer, 'population / area')
Contains Contains(containerGeometry, insideFeatures) -> FeatureSet
Function bundle: Data Access
Returns features from a FeatureSet that are contained within the input geometry.
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.
Parameters
insideFeatures
. Think of this geometry as the potential 'container' of the insideFeatures
.containerGeometry
.Return value: FeatureSet
Additional resources
Example
Returns the number of features that are within the given polygon
Use dark colors for code blocks Copy
1
2
3
var parcels = FeatureSetByName($map, 'parcels')
var projectArea = $feature;
Count(Contains(projectArea, parcels));
Count Count(features) -> Number
Function bundle: Data Access
Returns the number of features in a FeatureSet.
Parameter
Return value: Number
Example
Returns the number of features in a layer
Use dark colors for code blocks Copy
Crosses Crosses(features, crossingGeometry) -> FeatureSetFunction bundle: Data Access
Returns features from a FeatureSet that cross the input geometry.
Feature geometries in the visualization and labeling profiles are generalized according to the view's scale resolution to improve drawing performance. Therefore, using a feature's geometry (i.e. $feature
) as input to any geometry function in these contexts will return different results at each scale level. Other profiles, such as popup, provide the full resolution geometry.
Parameters
crossingGeometry
.Return value: FeatureSet
Additional resources
Example
Returns the number of features in the FeatureSet that cross the given polygon
Use dark colors for code blocks Copy
1
2
var geom2 = Polygon({ ... });
Count( Crosses($layer, geom2) );
Distinct Distinct(features, fields) -> FeatureSet
Function bundle: Data Access
Returns a set of distinct, or unique, values from a FeatureSet.
Parameters
features: FeatureSet - A FeatureSet from which to return distinct values.
fields: Text | Dictionary | Array<Text> | Array<Dictionary> - The field(s) and/or expression(s) from which to determine unique values. This parameter can be an array of field names, an array of expressions, or a dictionary or array of dictionary that specify output column names where unique values will be stored. If a dictionary is specified, the folowing specification must be used:
Return value: FeatureSet
Examples
Returns a FeatureSet with a 'Status' column. Each row of the FeatureSet contains a unique status value
Use dark colors for code blocks Copy
1
Distinct($layer, 'Status')
Returns a FeatureSet with a 'Status' and a 'Type' column. Each row of the FeatureSet contains a unique combination of 'Status' and 'Type' values
Use dark colors for code blocks Copy
1
Distinct($layer, ['Status', 'Type'])
Returns FeatureSet with a Density column with rows that may contain values of Low, High, or N/A
Use dark colors for code blocks Copy
1
2
3
4
Distinct($layer, {
name: "Density",
expression: "CASE WHEN PopDensity < 100 THEN 'Low' WHEN PopDensity >= 100 THEN 'High' ELSE 'N/A' END"
})
Returns FeatureSet with a Score and a Type column
Use dark colors for code blocks Copy
1
2
3
4
5
6
7
Distinct($layer, [{
name: 'Score',
expression: 'POPULATION_DENSITY * 0.65 + Status_Code * 0.35'
}, {
name: 'Type',
expression: 'Category'
}])
Domain Domain(features, fieldName, subtype?) -> Dictionary
Function bundle: Data Access
Returns the domain assigned to the given field of the provided featureSet
. If the featureSet
belongs to a class with a subtype, this returns the domain assigned to the subtype.
Parameters
Return value: Dictionary
Returns a dictionary described by the properties below.
codedValue
or range
.esriFieldTypeSmallInteger
, esriFieldTypeInteger
, esriFieldTypeBigInteger
, esriFieldTypeSingle
, esriFieldTypeDouble
, esriFieldTypeString
, esriFieldTypeDate
, esriFieldTypeOID
, esriFieldTypeGeometry
, esriFieldTypeBlob
, esriFieldTypeRaster
, esriFieldTypeGUID
, esriFieldTypeGlobalID
, esriFieldTypeXML
.range
domains. The minimum value of the domain.range
domains. The maximum value of the domain.codedValue
domains. An array of dictionaries describing the valid values for the field. Each dictionary has a code
property, which contains the actual field value, and a name
property containing a user-friendly description of the value (e.g. { code: 1, name: "pavement" }
).Example
The domain assigned to the feature's subtype
Use dark colors for code blocks Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
var fsPole = FeatureSetByName($layer, "Pole", 1);
var d = Domain(fsPole, "poleType")
// the poleType field has a coded value domain called poleTypes
// the value of d will be
// {
// type: "codedValue" ,
// name: "poleTypesThreePhase",
// dataType: "number",
// codedValues: [
// { name: "Unknown", code: 0 },
// { name: "Wood", code: 1 },
// { name: "Steel", code: 2 }
// { name: "Reinforced Steel", code: 3 }
// ]
// }
DomainCode DomainCode(features, fieldName, value, subtype?) -> Number | Text
Function bundle: Data Access
Returns the code of an associated domain description in a FeatureSet.
Parameters
Example
Prints the domain description for the field referenced.
Use dark colors for code blocks Copy
1
DomainCode($layer, 'Enabled', 'True', subtype)
DomainName DomainName(features, fieldName, code?, subtype?) -> Text
Function bundle: Data Access
Returns the descriptive name for a domain code in a FeatureSet.
Parameters
Return value: Text
Example
prints the domain description for the referenced field
Use dark colors for code blocks Copy
1
DomainName($layer, 'fieldName')
EnvelopeIntersects EnvelopeIntersects(features, envelope) -> FeatureSet
Function bundle: Data Access
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 geometries in the visualization and labeling profiles are generalized according to the view's scale resolution to improve drawing performance. Therefore, using a feature's geometry (i.e. $feature
) as input to any geometry function in these contexts will return different results at each scale level. Other profiles, such as popup, provide the full resolution geometry.
Parameters
envelope
.Return value: FeatureSet
Example
Returns the number of features that intersect the envelope of geom2
Use dark colors for code blocks Copy
1
2
var geom2 = Polygon({ ... });
Count( EnvelopeIntersects($layer, geom2) );
Expects Expects(features, field1, [field2, ..., fieldN]?) -> Null
Function bundle: Data Access
Requests additional attributes for the given FeatureSet.
Parameters
*
character. However, this should be avoided to prevent loading an unnecessary amount of data that can negatively impact app performance. This value must be a text literal and cannot be a variable.Return value: Null
Example
Requests the POPULATION field for the features in the cluster
Use dark colors for code blocks Copy
1
2
3
4
5
6
7
// If the layer is clustered based on count,
// only the OBJECTID field is requested by default.
// To display the sum of the POPULATION field
// for all features in the cluster, we must
// explicitly request the POPULATION data.
Expects($aggregatedFeatures, 'POPULATION')
Text(Sum($aggregatedFeatures, 'POPULATION'), '#,###')
FeatureSet
This function has 2 signatures:
Function bundle: Data Access
Creates a new FeatureSet from JSON according to the ArcGIS REST spec. See the snippet below for an example of this.
Parameter
Return value: FeatureSet
Example
Create a FeatureSet from JSON.
Use dark colors for code blocks Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// JSON representation of the feature used in the snippet below
// {
// 'fields': [{
// 'alias': 'RANK',
// 'name': 'RANK',
// 'type': 'esriFieldTypeInteger'
// }, {
// 'alias': 'ELEV_m',
// 'name': 'ELEV_m',
// 'type': 'esriFieldTypeInteger'
// }],
// 'spatialReference': { 'wkid': 4326 },
// 'geometryType': 'esriGeometryPoint',
// 'features': [{
// 'geometry': {
// 'spatialReference': { 'wkid': 4326 },
// 'x': -151.0063,
// 'y': 63.069
// },
// 'attributes': {
// 'RANK': 1,
// 'ELEV_m': 6168
// }
// }]
// };
// The Dictionary representation of the FeatureSet must be a serialized text value
var features = FeatureSet('{"fields":[{"alias":"RANK","name":"RANK","type":"esriFieldTypeInteger"},{"alias":"ELEV_m","name":"ELEV_m","type":"esriFieldTypeInteger"}],"spatialReference":{"wkid":4326},"geometryType":"esriGeometryPoint","features":[{"geometry":{"spatialReference":{"wkid":4326},"x":-151.0063,"y":63.069},"attributes":{"RANK":1,"ELEV_m":6168}}]}')
FeatureSet(definition) -> FeatureSet
Function bundle: Data Access
Creates a new FeatureSet from a Dictionary representing JSON according to the ArcGIS REST spec. See the snippet below for an example of this.
Parameter
Return value: FeatureSet
Example
Create a FeatureSet from dictionary.
Use dark colors for code blocks Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// JSON representation of the feature used in the snippet below
var d = {
fields: [{
alias: 'RANK',
name: 'RANK',
type: 'esriFieldTypeInteger'
}, {
alias: 'ELEV_m',
name: 'ELEV_m',
type: 'esriFieldTypeInteger'
}],
spatialReference: { wkid: 4326 },
geometryType: 'esriGeometryPoint',
features: [{
geometry: {
spatialReference: { wkid: 4326 },
x: -151.0063,
y: 63.069
},
attributes: {
RANK: 1,
ELEV_m: 6168
}
}]
};
var features = FeatureSet(d)
FeatureSetByAssociation FeatureSetByAssociation(inputFeature, associationType, terminalName?) -> FeatureSet
Function bundle: Data Access
Returns all the features associated with the input feature as a FeatureSet. This is specific to Utility Network workflows.
Parameters
connected
| container
| content
| structure
| attached
junctionEdge
| midspan
connected
association types.Return value: FeatureSet
Returns a FeatureSet containing features with the field specification described in the table below.
TONETWORKSOURCEID
or FROMNETWORKSOURCEID
.TOGLOBALID
or FROMGLOBALID
).1
(visible) or 0
(not visible). This value represents the visibility of the associated content and is only applicable for containment associations.midspan
association types. Returns a floating point number from 0-1 indicating the location (as a ratio) of the junction along the edge.junctionEdge
association types. Indicates which side the junction is on.Possible values: from
or to
Examples
Returns all assets that have connectivity associations with the low side terminal of the transformer.
Use dark colors for code blocks Copy
1
FeatureSetByAssociation($feature, 'connected', 'Low');
Returns the number of electric devices associated with the feature
Use dark colors for code blocks Copy
1
2
3
4
var allContent = FeatureSetByAssociation ($feature, "content");
var devicesRows = Filter(allContent, "className = 'Electric Device'");
var devicesCount = Count(devicesRows);
return devicesCount;
FeatureSetById FeatureSetById(featureSetCollection, id, fields?, includeGeometry?) -> FeatureSet
Function bundle: Data Access
Creates a FeatureSet from a Feature Layer based on its layer ID within a map or feature service. Limiting the number of fields in the request and excluding the geometry can improve the performance of the script.
Parameters
$map
or $datastore
global.map
. This layer must be created from a feature service; feature collections are not supported. Please note that this value must be a text literal.['*']
. Limiting the number of fields improves the performance of the script.true
. For performance reasons, you should only request the geometry if necessary, such as for use in geometry functions.Return value: FeatureSet
Example
Returns the number of features in the layer with the id DemoLayerWM_1117 in the given map.
Use dark colors for code blocks Copy
1
2
var features = FeatureSetById($map,'DemoLayerWM_1117', ['*'], true);
Count( features );
FeatureSetByName FeatureSetByName(featureSetCollection, title, fields?, includeGeometry?) -> FeatureSet
Function bundle: Data Access
Creates a FeatureSet from a Feature Layer based on its name within a map or feature service. Keep in mind this name is not necessarily unique. It is therefore more appropriate to create a FeatureSet using FeatureSetById()
. Limiting the number of fields in the FeatureSet and excluding the geometry can improve the performance of the script.
Parameters
$map
or $datastore
global.map
. This layer must be created from a feature service; feature collections are not supported. Please note that this value must be a text literal.['*']
. Limiting the number of fields improves the performance of the script.true
. For performance reasons, you should only request the geometry if necessary, such as for use in geometry functions.Return value: FeatureSet
Example
Returns the number of features in the layer with the title 'Bike routes' in the given map.
Use dark colors for code blocks Copy
1
2
var features = FeatureSetByName($map,'Bike routes', ['*'], true);
Count(features);
FeatureSetByRelationshipClass FeatureSetByRelationshipClass(inputFeature, relationshipClass, fieldNames?, includeGeometry?) -> FeatureSet
Function bundle: Data Access
Returns the related records for a given feature based on the name of a given relationship class.
Parameters
Return value: FeatureSet
Additional resources
Example
Returns the count of pole inspection related records
Use dark colors for code blocks Copy
1
2
3
4
// A calculation rule that returns the count of a pole inspection records.
// When a pole feature is updated the calculation rule reads all its related inspections records from the comments field and returns the total inspection count for that feature.
var fsinspected = FeatureSetByRelationshipClass($feature, âpole_inspectionâ, [âcommentsâ], false);
return Count(fsinspected);
FeatureSetByRelationshipName FeatureSetByRelationshipName(inputFeature, relationshipName, fieldNames?, includeGeometry?) -> FeatureSet
Function bundle: Data Access
Returns the related records for a given feature as a FeatureSet.
Parameters
Return value: FeatureSet
Example
Returns the sum of several fields across all related records
Use dark colors for code blocks Copy
1
2
var results = FeatureSetByRelationshipName($feature, 'Election_Results', ['*'], false)
Sum(results, 'democrat + republican + other')
Filter Filter(features, sqlExpression) -> FeatureSet
Function bundle: Data Access
Creates a new FeatureSet with all the features that pass the SQL92 expression filter.
Parameters
@
character. See the snippet below for an example.Return value: FeatureSet
Examples
Filter features using a SQL92 expression
Use dark colors for code blocks Copy
1
2
// Returns all features with a Population greater than 10,000
var result = Filter($layer, 'POPULATION > 10000');
Filter features using a SQL92 expression with a variable substitute
Use dark colors for code blocks Copy
1
2
3
// Returns all features with a Population greater than the dataset average
var averageValue = Average($layer, 'POPULATION')
var result = Filter($layer, 'POPULATION > @averageValue');
FilterBySubtypeCode FilterBySubtypeCode(features, subtypeCode) -> FeatureSet
Function bundle: Data Access
Creates a new FeatureSet with all the features matching the given subtype code.
Parameters
Return value: FeatureSet
Example
Filter features with the subtype code
Use dark colors for code blocks Copy
1
2
// Returns all features that have the given subtype code
FilterBySubtypeCode($layer, 5)
First First(features) -> Feature
Function bundle: Data Access
Returns the first feature in a FeatureSet. Returns null
if the FeatureSet is empty.
Parameter
Return value: Feature
Example
returns the area of the first feature in the layer.
Use dark colors for code blocks Copy
GdbVersion GdbVersion(features) -> TextFunction bundle: Data Access
Returns the name of the current geodatabase version for branch or versioned data. When the data is not in a multi-user geodatabase, an empty text value will be returned.
Parameter
Return value: Text
Additional resources
Example
Returns the geodatabase version of the given FeatureSet
Use dark colors for code blocks Copy
GetFeatureSet GetFeatureSet(inputFeature, source?) -> FeatureSetFunction bundle: Data Access
Gets the FeatureSet in which the input feature belongs. The returned FeatureSet represents all features from the input feature's parent/root layer or table.
Parameters
inputFeature: Feature - The feature belonging to a parent or root FeatureSet.
source (Optional): Text - Indicates the source FeatureSet to return.
Possible Values:
datasource
: (default) Returns all the features from the input feature's data source without any filters or definition expressions as a FeatureSet.root
: Returns the initial FeatureSet to which the input feature belongs. This may be a filtered subset of all the features in the data source.parent
: Returns the parent FeatureSet of the input feature. This can be a smaller set of features than the original data source or root FeatureSet.Return value: FeatureSet
Examples
Returns a FeatureSet representing all the features in the data source.
Use dark colors for code blocks Copy
1
2
3
4
5
6
7
// Assume the data source for the 'Bike routes' layer has 2,000 features
// and the user creating the map has set a definition expression on the 'Bike routes' layer that filters the layer to 100 features.
var fs1 = FeatureSetByName($map, 'Bike routes', ['*'], true);
var fs2 = top(fs1, 10)
var f = First(fs2)
GetFeatureSet(f)
// returns a FeatureSet representing the data source, which does not include the map filter (2,000 features)
Returns the root FeatureSet of the feature.
Use dark colors for code blocks Copy
1
2
3
4
5
6
7
// Assume the data source for the 'Bike routes' layer has 2,000 features
// and the user creating the map has set a definition expression on the 'Bike routes' layer that filters the layer to 100 features.
var fs1 = FeatureSetByName($map, 'Bike routes', ['*'], true);
var fs2 = top(fs1, 10)
var f = First(fs2)
GetFeatureSet(f, 'root')
// returns the root FeatureSet, which honors the user's filter from the map (a total of 100 features)
Returns the parent FeatureSet of the feature.
Use dark colors for code blocks Copy
1
2
3
4
5
6
7
8
// Assume the data source for the 'Bike routes' layer has 2,000 features
// and the user creating the map has set a definition expression on the 'Bike routes' layer that filters the layer to 100 features.
var fs1 = FeatureSetByName($map, 'Bike routes', ['*'], true);
var fs2 = top(fs1, 10)
var f = First(fs2)
GetFeatureSet(f, 'parent')
// returns the parent FeatureSet, which is the result of the top function
// (a total of 10 features)
Returns the number of features in the data source table within 1 mile of the feature.
Use dark colors for code blocks Copy
1
2
3
var fullFeatureSet = GetFeatureSet($feature);
var featuresOneMile = Intersects(fullFeatureSet, BufferGeodetic($feature, 1, 'miles'))
Count(featuresOneMile)
GetFeatureSetInfo GetFeatureSetInfo(inputFeatureSet) -> Dictionary
Function bundle: Data Access
Returns metadata for the original source database and service (if applicable) of a FeatureSet.
Parameter
Return value: Dictionary
Returns a dictionary described by the properties below.
null
for sde/filegdb/mobile workspaces.null
for sde/filegdb/mobile workspaces.null
for sde/filegdb/mobile workspaces.null
for sde/filegdb/mobile workspaces.null
for sde/filegdb/mobile workspaces.null
for sde/filegdb/mobile workspaces.Examples
Metadata returned from a FeatureSet connected to an underlying feature service
Use dark colors for code blocks Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// $layer originates from a feature service layer in a web map
GetFeatureSetInfo($layer);
// returns the following:
{
"layerId": 7,
"layerName": "My Table",
"itemId": "dda795cf2af44d2bb7af2827963b76e8",
"serviceLayerUrl": "https://utilitynetwork.esri.com/server/rest/services/ClassicNapervilleElectric_Postgres/FeatureServer/100",
"webMapLayerId": 1,
"webMapLayerTitle": "MyTable1",
"className": null,
"objectClassId": null
}
Metadata returned from a FeatureSet originating from a filegdb or mobilegdb
Use dark colors for code blocks Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// $featureset originates from a feature class in a filegdb or mobilegdb
GetFeatureSetInfo($featureset);
// returns the following:
{
"layerId": null,
"layerName": null,
"itemId": null,
"serviceLayerUrl": null,
"webMapLayerId": null,
"webMapLayerTitle": null,
"className": "myTable",
"objectClassId": 7
}
Metadata returned from a FeatureSet connected to an sde workspace (client server direct connection)
Use dark colors for code blocks Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// Client server direct connection (sqlserver/oracle/etc.)
GetFeatureSetInfo($featureset);
// returns the following:
{
"layerId": null,
"layerName": null,
"itemId": null,
"serviceLayerUrl": null,
"webMapLayerId": null,
"webMapLayerTitle": null,
"className": "owner.myTable",
"objectClassId": 7
}
GetUser
This function has 2 signatures:
Function bundle: Data Access
Returns the current user from the workspace. For data from a service, either the Portal user or Server user is returned. For data from a database connection, the database user is returned. When no user is associated with the workspace, such as a file geodatabase, a null
value will be returned.
Parameters
Return value: Dictionary
Returns a dictionary described by the properties below. In an offline workflow, only the username will be returned.
Examples
Returns information about the user "tester".
Use dark colors for code blocks Copy
1
2
GetUser($layer, "tester")
// returns {"id": "12", "username": "tester", "name":"Testy Tester", "email": "tester@example.com", ...}
Returns username for the currently logged in user of the active portal. If no user is associated with the portal, this will return null
.
Use dark colors for code blocks Copy
1
2
3
4
var userInfo = GetUser($layer);
if(HasValue(userInfo, "username")){
return userInfo.username;
}
GetUser(features, extensions?) -> Dictionary
Function bundle: Data Access
Returns the current user from the workspace. For data from a service, either the Portal user or Server user is returned. For data from a database connection, the database user is returned. When no user is associated with the workspace, such as a file geodatabase, a null
value will be returned.
Parameters
userLicenseTypeExtensions
will be returned in the dictionary.Return value: Dictionary
Returns a dictionary described by the properties below. In an offline workflow, only the username will be returned.
extensions
parameter must be set to true
in order for this to be returned.Example
Returns information about the user currently logged in based on the workspace connection from a layer with user extensions.
Use dark colors for code blocks Copy
GroupBy GroupBy(features, groupByFields, statistics) -> FeatureSetFunction bundle: Data Access
Returns statistics as a FeatureSet for a set of grouped or distinct values.
Parameters
features: FeatureSet - A FeatureSet from which to return statistics for unique values returned from a given set of fields and/or expressions.
groupByFields: Text | Array<Text> | Array<Dictionary> - The field(s) and/or expression(s) from which to group statistics by unique values. This parameter can be a single field name, an array of field names, or an array of objects that specify column names paired with an expression (typically the field name) for the output FeatureSet. If an array of objects is specified, the following specification must be followed for each object:
statistics: Dictionary | Array<Dictionary> - The summary statistics to calculate for each group. This parameter can be a dictionary or array of dictionary that specify output statistics to return for each group. The following specification must be used:
Return value: FeatureSet
Examples
Returns the count of each tree type
Use dark colors for code blocks Copy
1
2
3
var treeStats = GroupBy($layer, 'TreeType', { name: 'NumTrees', expression: '1', statistic: 'COUNT' });
// treeStats contains features with columns TreeType and NumTrees
// Each unique tree type will have a count
Returns the count and the average height of each tree type
Use dark colors for code blocks Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
var treeStats = GroupBy($layer,
[ // fields/expressions to group statistics by
{ name: 'Type', expression: 'TreeType'},
{ name: 'Status', expression: 'TreeStatus'}
],
[ // statistics to return for each unique category
{ name: 'Total', expression: '1', statistic: 'COUNT' },
{ name: 'AvgHeight', expression: 'Height', statistic: 'AVG' },
{ name: 'MaxPercentCoverage', expression: 'CoverageRatio * 100', statistic: 'MAX' }
]
);
// treeStats contains features with columns Type, Status, Total, AvgHeight, MaxPercentCoverage
// Each unique tree type (combination of type and status) will have a count, average height, and maximum value of percent coverage
Intersects Intersects(features, inputGeometry) -> FeatureSet
Function bundle: Data Access
Returns features from a FeatureSet that intersect another geometry.
Feature geometries in the visualization and labeling profiles are generalized according to the view's scale resolution to improve drawing performance. Therefore, using a feature's geometry (i.e. $feature
) as input to any geometry function in these contexts will return different results at each scale level. Other profiles, such as popup, provide the full resolution geometry.
Parameters
geometry
.Return value: FeatureSet
Additional resources
Example
Returns the number of features that intersect the polygon
Use dark colors for code blocks Copy
1
2
var geom2 = Polygon({ ... });
Count( Intersects($layer, geom2) );
Length Length(features, unit?) -> Number
Function bundle: Data Access
Returns the length of the input FeatureSet in the given units. This is a planar measurement using Cartesian mathematics.
Feature geometries in the visualization and labeling profiles are generalized according to the view's scale resolution to improve drawing performance. Therefore, using a feature's geometry (i.e. $feature
) as input to any geometry function in these contexts will return different results at each scale level. Other profiles, such as popup, provide the full resolution geometry.
Parameters
centimeters
| decimeters
| inches
| feet
| kilometers
| meters
| miles
| millimeters
| nautical-miles
| us-feet
| us-miles
| yards
Return value: Number
Additional resources
Example
Returns the planar length of the layer in meters
Use dark colors for code blocks Copy
1
Length($layer, 'meters')
Length3D Length3D(features, unit?) -> Number
Function bundle: Data Access
Returns the planar (i.e. Cartesian) length of the input FeatureSet 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 geometries in the visualization and labeling profiles are generalized according to the view's scale resolution to improve drawing performance. Therefore, using a feature's geometry (i.e. $feature
) as input to any geometry function in these contexts will return different results at each scale level. Other profiles, such as popup, provide the full resolution geometry.
Parameters
centimeters
| decimeters
| inches
| feet
| kilometers
| meters
| miles
| millimeters
| nautical-miles
| us-feet
| us-miles
| yards
Return value: Number
Additional resources
Example
Returns the 3D length of the layer's features in meters
Use dark colors for code blocks Copy
1
Length3D($layer, 'meters')
LengthGeodetic LengthGeodetic(features, unit?, curveType?) -> Number
Function bundle: Data Access
Returns the geodetic length of the input FeatureSet in the given units. This is more reliable measurement of length than Length()
because it takes into account the Earth's curvature.
Feature geometries in the visualization and labeling profiles are generalized according to the view's scale resolution to improve drawing performance. Therefore, using a feature's geometry (i.e. $feature
) as input to any geometry function in these contexts will return different results at each scale level. Other profiles, such as popup, provide the full resolution geometry.
Parameters
centimeters
| decimeters
| inches
| feet
| kilometers
| meters
| miles
| millimeters
| nautical-miles
| us-feet
| us-miles
| yards
Geodesic
.Geodesic
- Defined by the shortest distance between two points on an ellipsoid.GreatElliptic
- Defined by the intersection of a plane that contains the center of the spheroid and the spheroid surface and passes through two points. This is also known as a great circle when a sphere is used. It is not necessarily the shortest path between two points.Loxodrome
- Defined by the line of constant bearing, or azimuth, between two points. It represents a rhumb-line path on the earth that crosses each meridian at the same acute angle, thus forming a spiral that converges on the north or south pole. The Mercator projection shows loxodromes as straight lines.NormalSection
- Defined by the intersection of a plane that passes through two points on the surface of the spheroid and is perpendicular to the surface at the first point. It is not necessarily the shortest path between two points.ShapePreserving
- The segment shape is preserved in the projection where it is defined. This is often used in situations where maintaining the visual representation of a feature is crucial, like when working with boundaries or coastlines.Return value: Number
Additional resources
Example
Returns the geodetic length of the layer in meters
Use dark colors for code blocks Copy
1
LengthGeodetic($layer, 'meters')
Max Max(features, fieldNameOrSQLExpression) -> Number
Function bundle: Data Access
Returns the highest value for a given numeric field from a FeatureSet.
Parameters
Return value: Number
Examples
prints the max value of the population field for all features in the layer
Use dark colors for code blocks Copy
1
Max($layer, 'population')
calculates the max population per square mile of all features in the layer
Use dark colors for code blocks Copy
1
Max($layer, 'population / area')
Mean Mean(features, fieldNameOrSQLExpression) -> Number
Function bundle: Data Access
Returns the mean value of a given numeric field in a FeatureSet.
Parameters
Return value: Number
Examples
calculates the difference between the feature's population and the mean population of all features in the layer
Use dark colors for code blocks Copy
1
$feature.population - Mean($layer, 'population')
calculates the mean population per square mile of all features in the layer
Use dark colors for code blocks Copy
1
Mean($layer, 'population / area')
Min Min(features, fieldNameOrSQLExpression) -> Number
Function bundle: Data Access
Returns the lowest value for a given numeric field from a FeatureSet.
Parameters
Return value: Number
Examples
prints the min value of the population field for all features in the layer
Use dark colors for code blocks Copy
1
Min($layer, 'population')
returns the minimum population per square mile of all features in the layer
Use dark colors for code blocks Copy
1
Min($layer, 'population / area')
OrderBy OrderBy(features, sqlExpression) -> FeatureSet
Function bundle: Data Access
Orders a FeatureSet by using a SQL92 OrderBy clause.
Parameters
Return value: FeatureSet
Examples
Order features by population where features with the highest population are listed first
Use dark colors for code blocks Copy
1
OrderBy($layer, 'POPULATION DESC')
Order features by rank in ascending order
Use dark colors for code blocks Copy
1
OrderBy($layer, 'Rank ASC')
Overlaps Overlaps(overlappingFeatures, inputGeometry) -> FeatureSet
Function bundle: Data Access
Returns features from a FeatureSet that overlap another geometry.
Feature geometries in the visualization and labeling profiles are generalized according to the view's scale resolution to improve drawing performance. Therefore, using a feature's geometry (i.e. $feature
) as input to any geometry function in these contexts will return different results at each scale level. Other profiles, such as popup, provide the full resolution geometry.
Parameters
geometry
.overlappingFeatures
.Return value: FeatureSet
Additional resources
Example
Returns the number of features that overlap the polygon
Use dark colors for code blocks Copy
1
2
var geom2 = Polygon({ ... });
Count( Overlaps($layer, geom2) );
Schema Schema(features) -> Dictionary
Function bundle: Data Access
Returns the schema description of the provided FeatureSet.
Parameter
Return value: Dictionary
Returns a dictionary described by the properties below.
""
if not globalId-enabled.esriGeometryNull
for tables with no geometry.esriGeometryPoint
, esriGeometryLine
, esriGeometryPolygon
, esriGeometryNull
name
, alias
, type
, subtype
, domain
, length
, and whether it is editable
and nullable
.Function bundle: Data Access
Returns the sample standard deviation for the values from a given numeric field in a FeatureSet.
Parameters
Return value: Number
Examples
prints the standard deviation of values from the 'population' field
Use dark colors for code blocks Copy
1
Stdev($layer, 'population')
calculates the standard deviation of the population per square mile of all features in the layer
Use dark colors for code blocks Copy
1
Stdev($layer, 'population / area')
Subtypes Subtypes(features) -> Dictionary
Function bundle: Data Access
Returns the subtype coded value Dictionary. Returns null
when subtypes are not enabled on the layer.
Parameter
Return value: Dictionary
Returns a dictionary described by the properties below.
code
property, which contains the actual field value, and a name
property containing a user-friendly description of the value (e.g. { code: 1, name: "pavement" }
)Example
Returns subtypes with coded values from a FeatureSet
Use dark colors for code blocks Copy
1
2
3
4
5
6
7
8
9
10
11
var fsTransformer = FeatureSetByName($layer, "Transformer")
Subtypes(fsTransformer)
// returns the following dictionary
// {
// subtypeField: 'assetGroup',
// subtypes: [
// { name: "Unknown", code: 0 },
// { name: "Single Phase", code: 1 },
// { name: "Two Phase", code: 2 }
// ]
// }
Sum Sum(features, fieldNameOrSQLExpression) -> Number
Function bundle: Data Access
Returns the sum of values returned from a given numeric field in a FeatureSet.
Parameters
Return value: Number
Examples
calculates the population of the current feature as a % of the total population of all features in the layer
Use dark colors for code blocks Copy
1
( $feature.population / Sum($layer, 'population') ) * 100
calculates the total number of votes cast in an election for the entire dataset
Use dark colors for code blocks Copy
1
Sum($layer, 'democrat + republican + other')
Top Top(features, numItems) -> FeatureSet
Function bundle: Data Access
Truncates the FeatureSet and returns the first given number of features.
Parameters
Return value: FeatureSet
Example
Returns the top 5 features with the highest population
Use dark colors for code blocks Copy
1
Top( OrderBy($layer, 'POPULATION DESC'), 5 )
Touches Touches(touchingFeatures, inputGeometry) -> FeatureSet
Function bundle: Data Access
Returns features from a FeatureSet that touch another geometry.
Feature geometries in the visualization and labeling profiles are generalized according to the view's scale resolution to improve drawing performance. Therefore, using a feature's geometry (i.e. $feature
) as input to any geometry function in these contexts will return different results at each scale level. Other profiles, such as popup, provide the full resolution geometry.
Parameters
geometry
.touchingFeatures
.Return value: FeatureSet
Additional resources
Example
Returns the number of features in the layer that touch the geometry.
Use dark colors for code blocks Copy
1
2
var geom = Polygon({ ... });
Count( Touches($layer, geom) );
Variance Variance(features, fieldNameOrSQLExpression) -> Number
Function bundle: Data Access
Returns the variance of the values from a given numeric field in a FeatureSet.
Parameters
Return value: Number
Examples
prints the variance for the population field in the given layer
Use dark colors for code blocks Copy
1
Variance($layer, 'population')
calculates the variance of the population per square mile of all features in the layer
Use dark colors for code blocks Copy
1
Variance($layer, 'population / area')
Within Within(innerGeometry, outerFeatures) -> FeatureSet
Function bundle: Data Access
Returns features from a FeatureSet that contain the innerGeometry
.
Feature geometries in the visualization and labeling profiles are generalized according to the view's scale resolution to improve drawing performance. Therefore, using a feature's geometry (i.e. $feature
) as input to any geometry function in these contexts will return different results at each scale level. Other profiles, such as popup, provide the full resolution geometry.
Parameters
outerFeatures
.innerGeometry
.Return value: FeatureSet
Additional resources
Example
Returns the number of features in the layer within the polygon
Use dark colors for code blocks Copy
1
2
var outerGeom = Polygon({ ... });
Count( Within(outerGeom, $layer) );
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4