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
Solved! Go to Solution.
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
}
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}
}
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.
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
}
And I'm learning something new also! I didn't think it would work properly on a FeatureSet like that.
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.