Select to view content in your preferred language

Having problems using arcade to Field Calculate values only at intersection of two layers

1066
5
Jump to solution
06-06-2023 01:58 PM
DaleJackan_work
Occasional Contributor

  I have two layers, zoning and plans, and where the polygons intersect I need to copy the SAP_NAME value from plans and paste it into the zoning field plan_names. I have found some posts that are similar, but when I try to code the arcade it says valid but never shows any intersection. The two layers are in the same coordinate system and they definitely intersect. Understand that I am using Field Calculate so I am not specifying in code the values need to go into zoning.plan_names because it's already specified in the tool  Some of the variations in code I have used are as follows:

var plan= FeatureSetByName($datastore, "county_editors.GISL.Plan")
var intersect= Intersects(plan,$feature)
for (var i in intersect){
if(i==true){plan.SAP_Name}
}

var zoning=FeatureSetByName($datastore, "county_editors.GISL.Zoning")
var geom_zoning= Geometry(zoning)
var plan= FeatureSetByName($datastore, "county_editors.GISL.Plan")
var geom_plan= Geometry(plan)
IIf(Intersects(geom_zoning, geom_plan), plan.SAP_NAME,'')

None of these appear to show any intersection between the layers when there definitely is. Thank you for any help you can provide.

Cheers,

Dale Jackan

 

 

0 Kudos
1 Solution

Accepted Solutions
DaleJackan_work
Occasional Contributor

Just to follow up I figured out the solution. My issue was that I misread the documentation and thought you had to call Geometry() in order to make it available and instead, it wasn't available. I also thought the Calculate Field tool handled the looping and it doesn't.:

var small_area= FeatureSetByName($datastore,"county_editors.GISL.Plan",['*'], true)

for (var i in (Intersects(small_area, $feature))){
return i.SAP_NAME
}

View solution in original post

0 Kudos
5 Replies
KenBuja
MVP Esteemed Contributor

The Intersects function evaluates two individual geometries, not an entire FeatureSet. What you have to do is loop through the plans FeatureSet and see if each feature intersects with the zone feature.

var plan = FeatureSetByName($datastore, "county_editors.GISL.Plan")
for (var f in plan){
  if(Intersects(f, $feature)){plan.SAP_Name}
}

 

0 Kudos
DaleJackan_work
Occasional Contributor

Yes, I thought that part of the code was unnecessary because I thought the Calculate Field tool handled the looping for you, but I was obviously wrong on that point.

0 Kudos
DaleJackan_work
Occasional Contributor

Just to follow up I figured out the solution. My issue was that I misread the documentation and thought you had to call Geometry() in order to make it available and instead, it wasn't available. I also thought the Calculate Field tool handled the looping and it doesn't.:

var small_area= FeatureSetByName($datastore,"county_editors.GISL.Plan",['*'], true)

for (var i in (Intersects(small_area, $feature))){
return i.SAP_NAME
}

0 Kudos
KenBuja
MVP Esteemed Contributor

And I'm learning something new also! I didn't think it would work properly on a FeatureSet like that.

0 Kudos
DaleJackan_work
Occasional Contributor

There is a caveat to this, the features must be in the same Feature dataset/Set. That is why I was able to call $datastore on it. Field Calculate has it's own profile restrictions and will only work with $feature or $datastore. $feature was what I was working in and needed to use Field Calculate on, but I needed to access another feature class within the same Feature Dataset and used $datastore to access it.

0 Kudos