In ArcGIS Pro, I have a map with a polygon layer, called Cont_Freg_CAOP2022, which has a text-type attribute, 6 characters long, called DICOFRE (e.g. "010121").
In addition to this, I have another layer of points, called Arvores_PGIFU, which has a text attribute, also called Dicofre.
I want to intersect the point layer with the polygon layer, return the value of the DICOFRE attribute of the intersected polygon and write this value in the point Dicofre field.
To do this, I created the expression:
// Determines the DICOFRE attribute of the Cont_Freg_CAOP2022 layer
// identified by the intersection with a point in the Arvores_PGIFU layer
var Dicofre_Fregs = FeatureSetByName($map, 'Cont_Freg_CAOP2022', ['DICOFRE'])
// Intersect the current location with the polygons and return the dicofre
var Dicofre_Int = First(Intersects($feature, Dicofre_Fregs))
// If the current location intersects a polygon, return DICOFRE, otherwise return null.
if (!IsEmpty(Dicofre_Int)) {
return Dicofre_Int['DICOFRE']
} else {
return null
}
When checking the expression I get the error message:
Invalid expression.
Error on line 4.
Object not found $map
Any help?
Might be simpler to split it into a couple steps.
Try spatial join to get the polygon layer attributes on the points
https://pro.arcgis.com/en/pro-app/latest/tool-reference/analysis/spatial-join.htm
and then use the field calculator to update the values on the target field.
Dear Friend
Thank you for your contribution.
Doing it manually is no problem. The aim is to do it automatically by applying a rule to the attribute.
Any ideas on how to resolve the error?
Best regards
Ah, I did not see that you wanted to do this with attribute rules.
This thread seems to show something like what you want:
Thank you!
Continues to generate an error, this time:
// Determines the DICOFRE attribute of the Cont_Freg_CAOP2022 layer
// identified by the intersection with a point in the Arvores_PGIFU layer
var Dicofre_Fregs = FeatureClassByName($map, 'Cont_Freg_CAOP2022', ['DICOFRE'])
// Intersect the current location with the polygons and return the dicofre
var Dicofre_Int = First(Intersects($feature, Dicofre_Fregs))
// If the current location intersects a polygon, return DICOFRE, otherwise return null.
if (!IsEmpty(Dicofre_Int)) {
return Dicofre_Int['DICOFRE']
} else {
return null
}
Invalid expression.
Error on line 4.
Unknown function