Select to view content in your preferred language

ARCADE featureSets question

1358
2
07-03-2023 10:48 AM
clt_cabq
Occasional Contributor III

I have a map that contains three items = a feature layer of properties, a feature layer of other locations, and a table related to the latter that represents a 1:M relationship. In playing with the FeatureSet functions I can get this statement to return a featureset of records from the table, and has 115,882 records in it:

var RelRecs = FeatureSetById($datastore, "1")

But the following statements both return empty record sets:

var RelRecs = FeatureSetById($map, "18908250d82-layer-4")
var RelRecs = FeatureSetByName($map, "NuisancePoints FS - Adapt Location Call Details")
 
Aren't these just different ways of accessing the same item and should return the same result? My suspicion is there is something different about the scope of $datastore versus $map that I am not fully understanding.
 
The reason this becomes important is I'd like to tie the table also to my first layer, which contains the same unique parcel ID. The first layer is not part of the same service as the layer/table pair so I thought using the $map parameter would allow me to access the table but it doesn't, obviously.
0 Kudos
2 Replies
ChristopherCounsell
MVP Regular Contributor

Where are you applying the expression?

Are you able to share the full snippet?

A featureset is a lightweight collection of all your features. If you want to ensure that you are correctly calling the featureset from the map, I'd suggest using the profile variables in a map Arcade expression builder. This helps ensure you use the correct layer name. For a large dataset, you should also be only calling the field(s) you will use, to improve performance.

Where you are applying the expression is important, as not all Profiles will support the FeatureSetCollection - a colleciton of feature sets. It's only supported working with $map and $datastore profile variables, e.g. pop-up.

https://developers.arcgis.com/arcade/guide/types/#featuresetcollection

https://developers.arcgis.com/arcade/profiles/popup/

https://developers.arcgis.com/arcade/guide/profiles/

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 $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.

I would recommend:

  1. Sharing the context to where you are applying the expression
  2. Testing the FeatureSet by calling the expression from the Arcade Profile variables. If you can't see the variable, it may not be supported by the Profile.
  3. Run a count(RelRecs) to see that you have returned all the desired features.
  4. Then if it's working, select the fields and work with the data.

Good tutorials/guides:

https://learn.arcgis.com/en/projects/access-attributes-from-another-layer-with-arcade/

https://community.esri.com/t5/arcgis-online-documents/using-featuresetby-functions-in-arcade-to-dril...

 

0 Kudos
clt_cabq
Occasional Contributor III

For context: I am using this method to relate records from a spatial layer and a table, in this instance these are both published together in a feature service (arcgis server, not hosted). As you can see the very first line is the code line that I posted initially and indicates it works (using the count method you suggested. In this situation the FeatureSetbyID function works because these items are part of the same service. This code block essentially gets a value from a shared unique ID and uses that to filter the related table, and then other code below line 5 perform some grouping to summarize data. This code all works as does other code that comes downstream of what is shared; as you mentioned I could probably improve its performance by pulling only the fields necessary.

var RelRecs = FeatureSetById($datastore, "1")
var countRelrecs = Count(RelRecs);
Console(countRelrecs);
var FilQry = "UPCCODE = '" + $feature["UPC"] + "'";
var RelRecs_filter = Filter(RelRecs, FilQry);
var CallsByType = GroupBy(RelRecs_filter,
[
  {name:'Department', expression:'BU_SOURCE'},
  {name:'Type' , expression:'CALLDESCRIPTION'}
],
[
  {name:'Total',expression:'1',statistic:'COUNT'},
  {name:'Points',expression:'POINTVALUE',statistic:'SUM'}

I want to use the $map functions to create a similar filter based on retrieving a matching ID value from a different layer in the map. However, both the code lines return feature set with 0 records, since this is the first line of the code block, nothing that follows is relevant. The lines of code are taken directly from the profile variable so I'd think they should function properly.

clt_cabq_0-1688566702969.png

The question still remains as to why the methods using the $map profile variable return 0 records while the $datastore method returns the entire feature set represented by the table. Is it simply because the table and layer aren't part of the same feature service?

 

 

0 Kudos