FeatureSetByName for multiple Polygon Layers

471
2
02-07-2023 05:06 PM
Labels (2)
FrancisHourigan1
Occasional Contributor

I want to create a pop-up that shows the zoning type within a polygon boundary from multiple different county zoning layers.

So far I have found a lot of examples online of using Arcade FeatureSetByName to call one layer that intersects a polygon layer. However, is there a way to access attributes in different layers that intersect the original polygon layer?

Here is the scenario, I have a polygon boundary that is national (USA) and is an ownership boundary. I have in my map 5 other layers that are not owned by me because they are county parcel/zoning layers. I want to call all 5 layers that intersect with a particular ownership polygon. So ideally when I click the ownership polygon it will show me a list of zoning codes that are within it (no matter which county I am in it will pull only the zones that intersect my original polygon layer).

Is there a way to loop through the 5 layers and their zoning attributes to display only the zone that is currently intersecting the polygon boundary I click on?

@XanderBakker I'm looking at you 😉

Tags (2)
0 Kudos
2 Replies
JohannesLindner
MVP Frequent Contributor

Probably not the most efficient way, but it gets the job done:

// define the zoning layers and their zone fields
var zoning_layers = [
    FeaturesetByName($datastore, "TestPolygons", ["*"], false),
    FeaturesetByName($datastore, "TestPolygons", ["*"], false),
    FeaturesetByName($datastore, "TestPolygons", ["*"], false),
    FeaturesetByName($datastore, "TestPolygons", ["*"], false),
    ]
var zoning_fields = [
    "TextField",
    "IntegerField",
    "GlobalID",
    "OBJECTID",
    ]

var zones = []
// loop through the layers
for(var i in zoning_layers) {
    // get the first intersecting zone, abort if none found
    var zone = First(Intersects(zoning_layers[i], $feature))
    if(zone == null) { continue }
    // append the zone's zoning field value
    Push(zones, zone[zoning_fields[i]])
}
// concatenate and return
return Concatenate(zones, ", ")

Have a great day!
Johannes
0 Kudos
FrancisHourigan1
Occasional Contributor

Thank you Johannes,

What is the difference between $datastore and $map...? Does that address the fact that the layers are not my own?

 

Here is the code with the layers i am using:

//define the zoning layers and their zone fields
var zone_layers = [
FeatureSetByName($map,"Mendocino County Parcels w Ownership", ["*"], false),
FeatureSetByName($map,"Lake County Parcels w Ownership", ["*"], false),
FeatureSetByName($map,"Napa County Parcels with Ownership", ["*"], false),
FeatureSetByName($map,"Monterey County Parcels", ["*"], false),
FeatureSetByName($map,"Santa Barbara County Parcels w Ownership", ["*"], false),
FeatureSetByName($map,"Sonoma County Parcels with Ownership", ["*"], false),
]
var zone_fields = [
"BASEZONE1",
"base_zone",
"Land_Use",
"landuse",
"usectype",
]
var zones = []
// loop through the layers
for(var i in zone_layers) {
//get the first intersecting zone, abort if none found
var zone = first(intersects(zone_layers[i], $feature))
if(zone == null) {continue}
//append the zone's zone field value
Push(zones, zone[zone_fields[i]])
}
//concatenate and return
return Concatenate(zones, ", ")

 

Some of the fields do display such as the "Base Zones" but for a couple of the county layers the "landuse and usetype" are blank, but in the layer there is a value for those fields. 

are my zone_fields list not correct?

0 Kudos