Select to view content in your preferred language

Configuring popups using Arcade geometry functions

11-07-2022 01:37 PM
Labels (2)
New Contributor

I’m trying to configure a pop-up in a web map that will show the total area owned by my organization within a given county. I want the popup to say something like, “This Organization owns x acres in this County.” I would like to use arcade to make it dynamic. The ownership layer is a Feature Service on our portal that is split into parcels. Some of the parcels straddle county lines, so it would be better to use the Clip function over the Intersection function.
My arcade expression initially looked like this:



var own = Clip(FeatureSetByName($map, 'View_Ownership', ['*'], true), $feature)
Area(own, 'acres')



When I validated it, I got an error message that said, "Invalid Expression. Error on line 1. Expected convertable to geometry

I rewrote it like this: 



var own = Clip(Geometry(FeatureSetByName($map, 'ResBoundaries', ['*'], true)), $feature)
Area (own, 'acres')



The expression builder says its valid, but the results in the pop-up are just 0.00. I feel like I must be missing something obvious. I'm pretty new to arcade.

0 Kudos
2 Replies
MVP Esteemed Contributor

The Clip function is expecting a single feature or geometry but you're providing it with a FeatureSet. You would have to loop through the FeatureSet and clip each feature. However, the function appears to only work only with an envelope as the cutting feature, so this probably isn't the result you're looking for.

0 Kudos
MVP Frequent Contributor

As Ken said, Clip() only works with an Envelope. You actually do want Intersection(). Maybe you confused it with Intersects(), which you will need, too.

  • Intersects() has 2 signatures:
    • Intersects(geometry1, geometry2) returns a boolean, depending on whether both geometries intersect.
    • Intersects(geometry, featureset) returns a featureset of all features in the original featureset that intersect the query feature.
  • Intersection() takes 2 input geometries and returns the intersection geometry.


You can achieve what you want with something like this expression:

// load the ownership polygons
var own = FeatureSetByName($map, 'EZG_Einleitungen', ['*'], true)

// get all features intersecting this county $feature
var i_own = Intersects(own, $feature)

// for each of those features, get the area of the intersection, accumulate
var total = 0
for(var o in i_own) {
    total += Area(Intersection(o, $feature), "Acres")
total = Round(total, 1)
return `This organization owns ${total} acres in this county.`




Have a great day!
0 Kudos