Select to view content in your preferred language

Use of Arcade featureSetByAssociation

1021
5
Jump to solution
10-02-2023 06:41 PM
PierreloupDucroix
Occasional Contributor III

Hi,

I'm struggling with the use of featureSetByAssociation in an attribute rule

What I'm trying to do is select the features attached to a pole, then count individual assetGroups. But I can't find how to use the className result of fsByAssociation function.

The documentation says it returns :

className: Text - The class name based on the value of TONETWORKSOURCEID or FROMNETWORKSOURCEID.

First, how do I know if I am querying TO or FROM field ?

Second, how do I know how to format the query ?

Looking here (https://pro.arcgis.com/fr/pro-app/latest/help/data/geodatabases/overview/attribute-rule-dictionary-k...) I see several query formatting (electricdistributionassembly, StructureJunctionObject...)

Looking here (https://www.esri.com/arcgis-blog/products/utility-network/data-management/featuresetbyassocaitions-n...) they tell

`className:` String based on value of (TONETWORKSOURCEID or FROMNETWORKSOURCEID )

Ex : var devicesRows = Filter(allContent, "className = 'Electric Device'")

But when looking at the Assicoation View in ArcGIS Pro, I have 4 or 12 as values for FROM/TONETWORKSOURCEID

Any help is welcome

Note that I am working in a mobile geotatabase

Also, if anyone has info about how to user terminalName  in the same function...

 

0 Kudos
2 Solutions

Accepted Solutions
RobertKrisher
Esri Regular Contributor

If all you want is the attachments, you can just pass in the feature and the association type ("attachment"). You only need to pass in the other information if you want to be more specific about the types of associations returned.

You can find many example arcade expressions in the following github repository from Esri (Esri/arcade-expressions: ArcGIS Arcade expression templates for all supported profiles in the ArcGIS...). There are 16 rules that include examples of using the featureSetByAssociation command and while most of them only pass in the feature and the association type you can find one example that makes use of the class name parameter here (although as I said I think you can use the simpler form of the function): arcade-expressions/popup/has_proposed_features.md at 801d086d4bdc6ad10ebb9c7fde9fdc7b4717a9c6 · Esri...

View solution in original post

0 Kudos
RobertKrisher
Esri Regular Contributor

In a file geodatabase the class name will not be qualified

var assoList = featureSetByAssociation($feature, "attached");
for(var asso in assoList)
console(asso);

produces the correct result in a mobile geodatabase, but doesn't work in a file geodatabase. Here's an example of a result from a mobile geodatabase.

{"geometry":null,"attributes":{"className":"ElectricJunction","globalId":"{0B531F4D-3886-4C8E-B4C0-2D85B8F7A7D1}","isContentVisible":0,"ObjectID":8730,"OID":8730,"percentAlong":0,"side":"","terminal":-1}}

A "Mobile Geodatabase" is a sqllite database that is stored in a single *.geodatabase file. A File Geodatabase is a file-based structure contained in a folder with a .gdb extension.

In a file geodatabase, I was able to get this expression to produce a result when a structure has a junction attached:

var assoList = featureSetByAssociation($feature, "attached");
for(var asso in assoList)
console(asso);

var filterList = Filter(assoList, "className = 'main.ElectricJunction'");
console(count(filterList));

return count(filterList)

RobertKrisher_0-1696371410762.png

 

View solution in original post

5 Replies
MikeMillerGIS
Esri Frequent Contributor

Classname is converted from the SourceID to the SourceName.  In mobile GDB, I am pretty sure it will be main.ElectricDevice for example.

Classname represents either the from or to.  So in a containment and your feature is content, it will be the From, since containment associations are always From(Container), To(Content).  But for Junction Junction, the From/To does not matter.  So if you feature is on the From side, the Classname represents the To.  So, ignore the fact that there is a from/to in the association table, FSbyAssocation returns all associations(filtered by type if passed in) to the feature and the name of the associated item.

 

TerminalName is the name of the terminal, not the code.

 

If you want the codes, you will have to create a query to a FeatureSet on the association table.

0 Kudos
RobertKrisher
Esri Regular Contributor

If all you want is the attachments, you can just pass in the feature and the association type ("attachment"). You only need to pass in the other information if you want to be more specific about the types of associations returned.

You can find many example arcade expressions in the following github repository from Esri (Esri/arcade-expressions: ArcGIS Arcade expression templates for all supported profiles in the ArcGIS...). There are 16 rules that include examples of using the featureSetByAssociation command and while most of them only pass in the feature and the association type you can find one example that makes use of the class name parameter here (although as I said I think you can use the simpler form of the function): arcade-expressions/popup/has_proposed_features.md at 801d086d4bdc6ad10ebb9c7fde9fdc7b4717a9c6 · Esri...

0 Kudos
PierreloupDucroix
Occasional Contributor III

Hi Mike and Robert,

What I want to do is count each AssetGroup's features within my associations :

Ex : for "attached" feature of a pole, I need to count how many streetlights, LV connection points and MV connection points. At first, I understood that the ClassName represented the ASSETGROUP and not the Layer.

I ended up getting the globaIDs from the FSbyAssociation in a list, and filtering a featureSetByName with those GIDs and the proper ASSETGROUPs. Then counting the results.

Robert, in the second link you provided, what are the parameters after the association_type ? They are not provided in the Arcade documentation.

--> var associations = FeatureSetByAssociation(feature, association_type, null, null, ['className'], false);

Mike, anyway it doesn't seem to work in a mobile geodatabase.

Ex without classname :

var assoList = featureSetByAssociation(eqpt, "attached")
console(count(assoList)) --> 3

with className :

var assoList = filter(featureSetByAssociation(eqpt, "attached"), "className = 'main.ElectricDevice'"),
console(count(assoList))

--> No result, no console log

 

 

0 Kudos
RobertKrisher
Esri Regular Contributor

In a file geodatabase the class name will not be qualified

var assoList = featureSetByAssociation($feature, "attached");
for(var asso in assoList)
console(asso);

produces the correct result in a mobile geodatabase, but doesn't work in a file geodatabase. Here's an example of a result from a mobile geodatabase.

{"geometry":null,"attributes":{"className":"ElectricJunction","globalId":"{0B531F4D-3886-4C8E-B4C0-2D85B8F7A7D1}","isContentVisible":0,"ObjectID":8730,"OID":8730,"percentAlong":0,"side":"","terminal":-1}}

A "Mobile Geodatabase" is a sqllite database that is stored in a single *.geodatabase file. A File Geodatabase is a file-based structure contained in a folder with a .gdb extension.

In a file geodatabase, I was able to get this expression to produce a result when a structure has a junction attached:

var assoList = featureSetByAssociation($feature, "attached");
for(var asso in assoList)
console(asso);

var filterList = Filter(assoList, "className = 'main.ElectricJunction'");
console(count(filterList));

return count(filterList)

RobertKrisher_0-1696371410762.png

 

PierreloupDucroix
Occasional Contributor III

Thank you very much for these explanations and examples.

Regards

0 Kudos