Attribute Rule Intersects by subtype

317
2
Jump to solution
11-17-2021 07:56 PM
Labels (2)
AaronCRose
New Contributor II

I am wondering if it is possible to use the Intersects function at the subtype level instead of the feature level. I have a feature class with several subtypes and am trying to return an attribute value into the target layer. However, the attribute is picking up values from other subtypes of the same feature class. Is there a way to point the $datastore at a subtype of a feature or filter it by subtype code?

1 Solution

Accepted Solutions
JohannesLindner
MVP Regular Contributor
var fs = FeatureSetByName($datastore, "FeatureClassWithSubtypes", ["*"], true)
// filter for subtype
// if you only care for a specific subtype:
fs = Filter(fs, "SubtypeField = 2")
// if you care for variable subtypes (different for each $feature):
var subtype = $feature.TargetSubtype
fs = Filter(fs, "SubtypeField = @subtype")
// intersect
var intersect_fs = Intersects(fs, $feature)
// return
if(Count(intersect_fs) > 0) {
  return First(intersect_fs).Attribute
}
return null

Have a great day!
Johannes

View solution in original post

2 Replies
JohannesLindner
MVP Regular Contributor
var fs = FeatureSetByName($datastore, "FeatureClassWithSubtypes", ["*"], true)
// filter for subtype
// if you only care for a specific subtype:
fs = Filter(fs, "SubtypeField = 2")
// if you care for variable subtypes (different for each $feature):
var subtype = $feature.TargetSubtype
fs = Filter(fs, "SubtypeField = @subtype")
// intersect
var intersect_fs = Intersects(fs, $feature)
// return
if(Count(intersect_fs) > 0) {
  return First(intersect_fs).Attribute
}
return null

Have a great day!
Johannes
AaronCRose
New Contributor II

Worked perfect! Thank you.

0 Kudos