HOW TO
In ArcGIS Pro, the Spatial Join and Add Spatial Join geoprocessing tools apply fixed, parameter-based logic to populate point attribute values based on spatial relationships with polygon features. However, these tools provide limited support for applying conditional logic during the operation. In this workflow, Python is used within the Calculate Field geoprocessing tool to apply user-defined conditional logic, allowing control over how and when point attribute values are overwritten using values from intersecting polygon features.


getPolyValue(<field1>,<field2>)

Note: The full script must be run at once.
import arcpy
Polygon_functionName = arcpy.Describe("Polygon_fc").catalogPath
def getPolyValue(pt, current_value):
with arcpy.da.SearchCursor(
polygon_fc,
("<Target_field>",),
spatial_filter=pt,
spatial_relationship="INTERSECTS"
)
as cursor:
for row in cursor:
return row[0]
return current_value
The code below shows the full sample script.
import arcpy
# Get the feature class path (not the layer name)
polygon_fc = arcpy.Describe("Polygon_Test").catalogPath
def getPolyValue(pt, current_value):
with arcpy.da.SearchCursor(
polygon_fc,
("Region",),
spatial_filter=pt,
spatial_relationship="INTERSECTS"
) as cursor:
for row in cursor:
# Overwrite when polygon intersects
return row[0]
# No intersecting polygon → keep original point value
return current_value
to validate the expression.The attribute table below displays the updated point attribute values from the intersecting polygons.

Article ID: 000041646
Get help from ArcGIS experts
Start chatting now