Is it possible to use Arcades Intersects() function to filter dynamic text

964
4
Jump to solution
08-07-2023 07:16 PM
Labels (1)
LindsayRaabe_FPCWA
Occasional Contributor III

I'd like to add some dynamic text to a layout that returns attribute values from a layer, but instead of returning all values, visible values or values from an expression, I would like to try write an arcade expression that only returns values where the source layer intersects with another layer which has a filter applied to it. My example would be returning Lot numbers from a Land Parcel layer for lots that have plantation areas on them, and not the neighbouring lots. 

I've tried using Intersects() and the $map and $datastore profiles to lookup my plantation layer, but my understanding is the dynamic text doesn't recognise the $map profile and the $datastore profile only returns layers in a feature service. 

I've also looked at including a dynamic table, but I can't format that to read as text, and also can't remove duplicate values. 

Lindsay Raabe
GIS Officer
Forest Products Commission WA
1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

Ah, and the spatial join doesn't update, didn't know that. OK, then let's try doing it in Dynamic Text and Arcade.

 

I've tried using Intersects() and the $map and $datastore profiles to lookup my plantation layer, but my understanding is the dynamic text doesn't recognise the $map profile and the $datastore profile only returns layers in a feature service. 

Correct, the Arcade Layout profile doesn't recognize the $map global (which is a bit weird, because you specify the map frame you want to extract the table attribute from). But $datastore will work as long as Plantations and Lots are in the same database / feature service.

 

This will list all Lots numbers (TextField1 in my layer) intersected by Plantations (note that you insert a table attribute for the plantation layer):

JohannesLindner_0-1691576316446.png

 

var lots = FeaturesetByName($datastore, "Lots")
var i_lots = Intersects($feature, lots)
var lot_names = []
for(var lot in i_lots) {
    Push(lot_names, lot.TextField1)
}
return Concatenate(lot_names, ", ")

 

This works fine if you have only one plantation:

JohannesLindner_1-1691576422087.png

 

With multiple plantations on different lots, the lot numbers will be unsorted:

JohannesLindner_2-1691576510964.png

 

 

With multiple plantations on the same lots, the lot numbers will be duplicated:

JohannesLindner_3-1691576573555.png

 

 


Have a great day!
Johannes

View solution in original post

4 Replies
JohannesLindner
MVP Frequent Contributor

Aren't you describing a Spatial Join?

  • add a Spatial Join to your Lots layer (intersect with Plantation layer, keep all features)
    JohannesLindner_3-1691535130065.png

     

  • This will add a column "Join_Count"
    JohannesLindner_4-1691535165189.png

     

  • in the layout, add a table frame for the joined Lots layer, filter by Join_Count
    JohannesLindner_5-1691535228639.png

     

JohannesLindner_2-1691534778431.png

 


Have a great day!
Johannes
0 Kudos
LindsayRaabe_FPCWA
Occasional Contributor III

Correct, and I would do this if it were a one off project - my desire is to create an automated solution for a template which can be opened, a definition query set for a plantation, zoom to the plantation and the layout information updates automatically based on the returned information. We have dynamic text returning simple information from visible rows of that layer (i.e. Plantation Name), but this obviously extends to other layers that we want to return information for, but require further filtering beyond the simple "Visible Rows" setting. 

Lindsay Raabe
GIS Officer
Forest Products Commission WA
0 Kudos
JohannesLindner
MVP Frequent Contributor

Ah, and the spatial join doesn't update, didn't know that. OK, then let's try doing it in Dynamic Text and Arcade.

 

I've tried using Intersects() and the $map and $datastore profiles to lookup my plantation layer, but my understanding is the dynamic text doesn't recognise the $map profile and the $datastore profile only returns layers in a feature service. 

Correct, the Arcade Layout profile doesn't recognize the $map global (which is a bit weird, because you specify the map frame you want to extract the table attribute from). But $datastore will work as long as Plantations and Lots are in the same database / feature service.

 

This will list all Lots numbers (TextField1 in my layer) intersected by Plantations (note that you insert a table attribute for the plantation layer):

JohannesLindner_0-1691576316446.png

 

var lots = FeaturesetByName($datastore, "Lots")
var i_lots = Intersects($feature, lots)
var lot_names = []
for(var lot in i_lots) {
    Push(lot_names, lot.TextField1)
}
return Concatenate(lot_names, ", ")

 

This works fine if you have only one plantation:

JohannesLindner_1-1691576422087.png

 

With multiple plantations on different lots, the lot numbers will be unsorted:

JohannesLindner_2-1691576510964.png

 

 

With multiple plantations on the same lots, the lot numbers will be duplicated:

JohannesLindner_3-1691576573555.png

 

 


Have a great day!
Johannes
LindsayRaabe_FPCWA
Occasional Contributor III

Thanks for your explanation. I've accepted it as the solution, because I'm sure it works as you've stated - just not in my particular case as the 2 layers are not in the same database. Will think on it some more to see if I can work around that, but for now, will accept a manual step in my map automation process! I'm sure this code will still prove useful in the future!

Lindsay Raabe
GIS Officer
Forest Products Commission WA
0 Kudos